001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchOrgLaborException;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.model.CacheModel;
035    import com.liferay.portal.model.MVCCModel;
036    import com.liferay.portal.model.OrgLabor;
037    import com.liferay.portal.model.impl.OrgLaborImpl;
038    import com.liferay.portal.model.impl.OrgLaborModelImpl;
039    import com.liferay.portal.service.persistence.OrgLaborPersistence;
040    
041    import java.io.Serializable;
042    
043    import java.util.Collections;
044    import java.util.HashMap;
045    import java.util.HashSet;
046    import java.util.Iterator;
047    import java.util.List;
048    import java.util.Map;
049    import java.util.Set;
050    
051    /**
052     * The persistence implementation for the org labor service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see OrgLaborPersistence
060     * @see com.liferay.portal.service.persistence.OrgLaborUtil
061     * @generated
062     */
063    @ProviderType
064    public class OrgLaborPersistenceImpl extends BasePersistenceImpl<OrgLabor>
065            implements OrgLaborPersistence {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link OrgLaborUtil} to access the org labor persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
070             */
071            public static final String FINDER_CLASS_NAME_ENTITY = OrgLaborImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List1";
074            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List2";
076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
077                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
079            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
080                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
083                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, Long.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONID =
086                    new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
087                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByOrganizationId",
089                            new String[] {
090                                    Long.class.getName(),
091                                    
092                            Integer.class.getName(), Integer.class.getName(),
093                                    OrderByComparator.class.getName()
094                            });
095            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID =
096                    new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
097                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByOrganizationId",
099                            new String[] { Long.class.getName() },
100                            OrgLaborModelImpl.ORGANIZATIONID_COLUMN_BITMASK |
101                            OrgLaborModelImpl.TYPEID_COLUMN_BITMASK);
102            public static final FinderPath FINDER_PATH_COUNT_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
103                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, Long.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByOrganizationId",
105                            new String[] { Long.class.getName() });
106    
107            /**
108             * Returns all the org labors where organizationId = &#63;.
109             *
110             * @param organizationId the organization ID
111             * @return the matching org labors
112             */
113            @Override
114            public List<OrgLabor> findByOrganizationId(long organizationId) {
115                    return findByOrganizationId(organizationId, QueryUtil.ALL_POS,
116                            QueryUtil.ALL_POS, null);
117            }
118    
119            /**
120             * Returns a range of all the org labors where organizationId = &#63;.
121             *
122             * <p>
123             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
124             * </p>
125             *
126             * @param organizationId the organization ID
127             * @param start the lower bound of the range of org labors
128             * @param end the upper bound of the range of org labors (not inclusive)
129             * @return the range of matching org labors
130             */
131            @Override
132            public List<OrgLabor> findByOrganizationId(long organizationId, int start,
133                    int end) {
134                    return findByOrganizationId(organizationId, start, end, null);
135            }
136    
137            /**
138             * Returns an ordered range of all the org labors where organizationId = &#63;.
139             *
140             * <p>
141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
142             * </p>
143             *
144             * @param organizationId the organization ID
145             * @param start the lower bound of the range of org labors
146             * @param end the upper bound of the range of org labors (not inclusive)
147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
148             * @return the ordered range of matching org labors
149             */
150            @Override
151            public List<OrgLabor> findByOrganizationId(long organizationId, int start,
152                    int end, OrderByComparator<OrgLabor> orderByComparator) {
153                    return findByOrganizationId(organizationId, start, end,
154                            orderByComparator, true);
155            }
156    
157            /**
158             * Returns an ordered range of all the org labors where organizationId = &#63;.
159             *
160             * <p>
161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
162             * </p>
163             *
164             * @param organizationId the organization ID
165             * @param start the lower bound of the range of org labors
166             * @param end the upper bound of the range of org labors (not inclusive)
167             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
168             * @param retrieveFromCache whether to retrieve from the finder cache
169             * @return the ordered range of matching org labors
170             */
171            @Override
172            public List<OrgLabor> findByOrganizationId(long organizationId, int start,
173                    int end, OrderByComparator<OrgLabor> orderByComparator,
174                    boolean retrieveFromCache) {
175                    boolean pagination = true;
176                    FinderPath finderPath = null;
177                    Object[] finderArgs = null;
178    
179                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
180                                    (orderByComparator == null)) {
181                            pagination = false;
182                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID;
183                            finderArgs = new Object[] { organizationId };
184                    }
185                    else {
186                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONID;
187                            finderArgs = new Object[] {
188                                            organizationId,
189                                            
190                                            start, end, orderByComparator
191                                    };
192                    }
193    
194                    List<OrgLabor> list = null;
195    
196                    if (retrieveFromCache) {
197                            list = (List<OrgLabor>)finderCache.getResult(finderPath,
198                                            finderArgs, this);
199    
200                            if ((list != null) && !list.isEmpty()) {
201                                    for (OrgLabor orgLabor : list) {
202                                            if ((organizationId != orgLabor.getOrganizationId())) {
203                                                    list = null;
204    
205                                                    break;
206                                            }
207                                    }
208                            }
209                    }
210    
211                    if (list == null) {
212                            StringBundler query = null;
213    
214                            if (orderByComparator != null) {
215                                    query = new StringBundler(3 +
216                                                    (orderByComparator.getOrderByFields().length * 3));
217                            }
218                            else {
219                                    query = new StringBundler(3);
220                            }
221    
222                            query.append(_SQL_SELECT_ORGLABOR_WHERE);
223    
224                            query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
225    
226                            if (orderByComparator != null) {
227                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
228                                            orderByComparator);
229                            }
230                            else
231                             if (pagination) {
232                                    query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
233                            }
234    
235                            String sql = query.toString();
236    
237                            Session session = null;
238    
239                            try {
240                                    session = openSession();
241    
242                                    Query q = session.createQuery(sql);
243    
244                                    QueryPos qPos = QueryPos.getInstance(q);
245    
246                                    qPos.add(organizationId);
247    
248                                    if (!pagination) {
249                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
250                                                            start, end, false);
251    
252                                            Collections.sort(list);
253    
254                                            list = Collections.unmodifiableList(list);
255                                    }
256                                    else {
257                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
258                                                            start, end);
259                                    }
260    
261                                    cacheResult(list);
262    
263                                    finderCache.putResult(finderPath, finderArgs, list);
264                            }
265                            catch (Exception e) {
266                                    finderCache.removeResult(finderPath, finderArgs);
267    
268                                    throw processException(e);
269                            }
270                            finally {
271                                    closeSession(session);
272                            }
273                    }
274    
275                    return list;
276            }
277    
278            /**
279             * Returns the first org labor in the ordered set where organizationId = &#63;.
280             *
281             * @param organizationId the organization ID
282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
283             * @return the first matching org labor
284             * @throws NoSuchOrgLaborException if a matching org labor could not be found
285             */
286            @Override
287            public OrgLabor findByOrganizationId_First(long organizationId,
288                    OrderByComparator<OrgLabor> orderByComparator)
289                    throws NoSuchOrgLaborException {
290                    OrgLabor orgLabor = fetchByOrganizationId_First(organizationId,
291                                    orderByComparator);
292    
293                    if (orgLabor != null) {
294                            return orgLabor;
295                    }
296    
297                    StringBundler msg = new StringBundler(4);
298    
299                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
300    
301                    msg.append("organizationId=");
302                    msg.append(organizationId);
303    
304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
305    
306                    throw new NoSuchOrgLaborException(msg.toString());
307            }
308    
309            /**
310             * Returns the first org labor in the ordered set where organizationId = &#63;.
311             *
312             * @param organizationId the organization ID
313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
314             * @return the first matching org labor, or <code>null</code> if a matching org labor could not be found
315             */
316            @Override
317            public OrgLabor fetchByOrganizationId_First(long organizationId,
318                    OrderByComparator<OrgLabor> orderByComparator) {
319                    List<OrgLabor> list = findByOrganizationId(organizationId, 0, 1,
320                                    orderByComparator);
321    
322                    if (!list.isEmpty()) {
323                            return list.get(0);
324                    }
325    
326                    return null;
327            }
328    
329            /**
330             * Returns the last org labor in the ordered set where organizationId = &#63;.
331             *
332             * @param organizationId the organization ID
333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
334             * @return the last matching org labor
335             * @throws NoSuchOrgLaborException if a matching org labor could not be found
336             */
337            @Override
338            public OrgLabor findByOrganizationId_Last(long organizationId,
339                    OrderByComparator<OrgLabor> orderByComparator)
340                    throws NoSuchOrgLaborException {
341                    OrgLabor orgLabor = fetchByOrganizationId_Last(organizationId,
342                                    orderByComparator);
343    
344                    if (orgLabor != null) {
345                            return orgLabor;
346                    }
347    
348                    StringBundler msg = new StringBundler(4);
349    
350                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
351    
352                    msg.append("organizationId=");
353                    msg.append(organizationId);
354    
355                    msg.append(StringPool.CLOSE_CURLY_BRACE);
356    
357                    throw new NoSuchOrgLaborException(msg.toString());
358            }
359    
360            /**
361             * Returns the last org labor in the ordered set where organizationId = &#63;.
362             *
363             * @param organizationId the organization ID
364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
365             * @return the last matching org labor, or <code>null</code> if a matching org labor could not be found
366             */
367            @Override
368            public OrgLabor fetchByOrganizationId_Last(long organizationId,
369                    OrderByComparator<OrgLabor> orderByComparator) {
370                    int count = countByOrganizationId(organizationId);
371    
372                    if (count == 0) {
373                            return null;
374                    }
375    
376                    List<OrgLabor> list = findByOrganizationId(organizationId, count - 1,
377                                    count, orderByComparator);
378    
379                    if (!list.isEmpty()) {
380                            return list.get(0);
381                    }
382    
383                    return null;
384            }
385    
386            /**
387             * Returns the org labors before and after the current org labor in the ordered set where organizationId = &#63;.
388             *
389             * @param orgLaborId the primary key of the current org labor
390             * @param organizationId the organization ID
391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
392             * @return the previous, current, and next org labor
393             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
394             */
395            @Override
396            public OrgLabor[] findByOrganizationId_PrevAndNext(long orgLaborId,
397                    long organizationId, OrderByComparator<OrgLabor> orderByComparator)
398                    throws NoSuchOrgLaborException {
399                    OrgLabor orgLabor = findByPrimaryKey(orgLaborId);
400    
401                    Session session = null;
402    
403                    try {
404                            session = openSession();
405    
406                            OrgLabor[] array = new OrgLaborImpl[3];
407    
408                            array[0] = getByOrganizationId_PrevAndNext(session, orgLabor,
409                                            organizationId, orderByComparator, true);
410    
411                            array[1] = orgLabor;
412    
413                            array[2] = getByOrganizationId_PrevAndNext(session, orgLabor,
414                                            organizationId, orderByComparator, false);
415    
416                            return array;
417                    }
418                    catch (Exception e) {
419                            throw processException(e);
420                    }
421                    finally {
422                            closeSession(session);
423                    }
424            }
425    
426            protected OrgLabor getByOrganizationId_PrevAndNext(Session session,
427                    OrgLabor orgLabor, long organizationId,
428                    OrderByComparator<OrgLabor> orderByComparator, boolean previous) {
429                    StringBundler query = null;
430    
431                    if (orderByComparator != null) {
432                            query = new StringBundler(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_ORGLABOR_WHERE);
440    
441                    query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
442    
443                    if (orderByComparator != null) {
444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445    
446                            if (orderByConditionFields.length > 0) {
447                                    query.append(WHERE_AND);
448                            }
449    
450                            for (int i = 0; i < orderByConditionFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByConditionFields[i]);
453    
454                                    if ((i + 1) < orderByConditionFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN);
468                                            }
469                                    }
470                            }
471    
472                            query.append(ORDER_BY_CLAUSE);
473    
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            for (int i = 0; i < orderByFields.length; i++) {
477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
478                                    query.append(orderByFields[i]);
479    
480                                    if ((i + 1) < orderByFields.length) {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
486                                            }
487                                    }
488                                    else {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC);
494                                            }
495                                    }
496                            }
497                    }
498                    else {
499                            query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
500                    }
501    
502                    String sql = query.toString();
503    
504                    Query q = session.createQuery(sql);
505    
506                    q.setFirstResult(0);
507                    q.setMaxResults(2);
508    
509                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                    qPos.add(organizationId);
512    
513                    if (orderByComparator != null) {
514                            Object[] values = orderByComparator.getOrderByConditionValues(orgLabor);
515    
516                            for (Object value : values) {
517                                    qPos.add(value);
518                            }
519                    }
520    
521                    List<OrgLabor> list = q.list();
522    
523                    if (list.size() == 2) {
524                            return list.get(1);
525                    }
526                    else {
527                            return null;
528                    }
529            }
530    
531            /**
532             * Removes all the org labors where organizationId = &#63; from the database.
533             *
534             * @param organizationId the organization ID
535             */
536            @Override
537            public void removeByOrganizationId(long organizationId) {
538                    for (OrgLabor orgLabor : findByOrganizationId(organizationId,
539                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
540                            remove(orgLabor);
541                    }
542            }
543    
544            /**
545             * Returns the number of org labors where organizationId = &#63;.
546             *
547             * @param organizationId the organization ID
548             * @return the number of matching org labors
549             */
550            @Override
551            public int countByOrganizationId(long organizationId) {
552                    FinderPath finderPath = FINDER_PATH_COUNT_BY_ORGANIZATIONID;
553    
554                    Object[] finderArgs = new Object[] { organizationId };
555    
556                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
557    
558                    if (count == null) {
559                            StringBundler query = new StringBundler(2);
560    
561                            query.append(_SQL_COUNT_ORGLABOR_WHERE);
562    
563                            query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
564    
565                            String sql = query.toString();
566    
567                            Session session = null;
568    
569                            try {
570                                    session = openSession();
571    
572                                    Query q = session.createQuery(sql);
573    
574                                    QueryPos qPos = QueryPos.getInstance(q);
575    
576                                    qPos.add(organizationId);
577    
578                                    count = (Long)q.uniqueResult();
579    
580                                    finderCache.putResult(finderPath, finderArgs, count);
581                            }
582                            catch (Exception e) {
583                                    finderCache.removeResult(finderPath, finderArgs);
584    
585                                    throw processException(e);
586                            }
587                            finally {
588                                    closeSession(session);
589                            }
590                    }
591    
592                    return count.intValue();
593            }
594    
595            private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "orgLabor.organizationId = ?";
596    
597            public OrgLaborPersistenceImpl() {
598                    setModelClass(OrgLabor.class);
599            }
600    
601            /**
602             * Caches the org labor in the entity cache if it is enabled.
603             *
604             * @param orgLabor the org labor
605             */
606            @Override
607            public void cacheResult(OrgLabor orgLabor) {
608                    entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
609                            OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
610    
611                    orgLabor.resetOriginalValues();
612            }
613    
614            /**
615             * Caches the org labors in the entity cache if it is enabled.
616             *
617             * @param orgLabors the org labors
618             */
619            @Override
620            public void cacheResult(List<OrgLabor> orgLabors) {
621                    for (OrgLabor orgLabor : orgLabors) {
622                            if (entityCache.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
623                                                    OrgLaborImpl.class, orgLabor.getPrimaryKey()) == null) {
624                                    cacheResult(orgLabor);
625                            }
626                            else {
627                                    orgLabor.resetOriginalValues();
628                            }
629                    }
630            }
631    
632            /**
633             * Clears the cache for all org labors.
634             *
635             * <p>
636             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
637             * </p>
638             */
639            @Override
640            public void clearCache() {
641                    entityCache.clearCache(OrgLaborImpl.class);
642    
643                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
644                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
645                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
646            }
647    
648            /**
649             * Clears the cache for the org labor.
650             *
651             * <p>
652             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
653             * </p>
654             */
655            @Override
656            public void clearCache(OrgLabor orgLabor) {
657                    entityCache.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
658                            OrgLaborImpl.class, orgLabor.getPrimaryKey());
659    
660                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
661                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
662            }
663    
664            @Override
665            public void clearCache(List<OrgLabor> orgLabors) {
666                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
667                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
668    
669                    for (OrgLabor orgLabor : orgLabors) {
670                            entityCache.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
671                                    OrgLaborImpl.class, orgLabor.getPrimaryKey());
672                    }
673            }
674    
675            /**
676             * Creates a new org labor with the primary key. Does not add the org labor to the database.
677             *
678             * @param orgLaborId the primary key for the new org labor
679             * @return the new org labor
680             */
681            @Override
682            public OrgLabor create(long orgLaborId) {
683                    OrgLabor orgLabor = new OrgLaborImpl();
684    
685                    orgLabor.setNew(true);
686                    orgLabor.setPrimaryKey(orgLaborId);
687    
688                    return orgLabor;
689            }
690    
691            /**
692             * Removes the org labor with the primary key from the database. Also notifies the appropriate model listeners.
693             *
694             * @param orgLaborId the primary key of the org labor
695             * @return the org labor that was removed
696             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
697             */
698            @Override
699            public OrgLabor remove(long orgLaborId) throws NoSuchOrgLaborException {
700                    return remove((Serializable)orgLaborId);
701            }
702    
703            /**
704             * Removes the org labor with the primary key from the database. Also notifies the appropriate model listeners.
705             *
706             * @param primaryKey the primary key of the org labor
707             * @return the org labor that was removed
708             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
709             */
710            @Override
711            public OrgLabor remove(Serializable primaryKey)
712                    throws NoSuchOrgLaborException {
713                    Session session = null;
714    
715                    try {
716                            session = openSession();
717    
718                            OrgLabor orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
719                                            primaryKey);
720    
721                            if (orgLabor == null) {
722                                    if (_log.isWarnEnabled()) {
723                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
724                                    }
725    
726                                    throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
727                                            primaryKey);
728                            }
729    
730                            return remove(orgLabor);
731                    }
732                    catch (NoSuchOrgLaborException nsee) {
733                            throw nsee;
734                    }
735                    catch (Exception e) {
736                            throw processException(e);
737                    }
738                    finally {
739                            closeSession(session);
740                    }
741            }
742    
743            @Override
744            protected OrgLabor removeImpl(OrgLabor orgLabor) {
745                    orgLabor = toUnwrappedModel(orgLabor);
746    
747                    Session session = null;
748    
749                    try {
750                            session = openSession();
751    
752                            if (!session.contains(orgLabor)) {
753                                    orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
754                                                    orgLabor.getPrimaryKeyObj());
755                            }
756    
757                            if (orgLabor != null) {
758                                    session.delete(orgLabor);
759                            }
760                    }
761                    catch (Exception e) {
762                            throw processException(e);
763                    }
764                    finally {
765                            closeSession(session);
766                    }
767    
768                    if (orgLabor != null) {
769                            clearCache(orgLabor);
770                    }
771    
772                    return orgLabor;
773            }
774    
775            @Override
776            public OrgLabor updateImpl(OrgLabor orgLabor) {
777                    orgLabor = toUnwrappedModel(orgLabor);
778    
779                    boolean isNew = orgLabor.isNew();
780    
781                    OrgLaborModelImpl orgLaborModelImpl = (OrgLaborModelImpl)orgLabor;
782    
783                    Session session = null;
784    
785                    try {
786                            session = openSession();
787    
788                            if (orgLabor.isNew()) {
789                                    session.save(orgLabor);
790    
791                                    orgLabor.setNew(false);
792                            }
793                            else {
794                                    orgLabor = (OrgLabor)session.merge(orgLabor);
795                            }
796                    }
797                    catch (Exception e) {
798                            throw processException(e);
799                    }
800                    finally {
801                            closeSession(session);
802                    }
803    
804                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
805    
806                    if (isNew || !OrgLaborModelImpl.COLUMN_BITMASK_ENABLED) {
807                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
808                    }
809    
810                    else {
811                            if ((orgLaborModelImpl.getColumnBitmask() &
812                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID.getColumnBitmask()) != 0) {
813                                    Object[] args = new Object[] {
814                                                    orgLaborModelImpl.getOriginalOrganizationId()
815                                            };
816    
817                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
818                                            args);
819                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID,
820                                            args);
821    
822                                    args = new Object[] { orgLaborModelImpl.getOrganizationId() };
823    
824                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
825                                            args);
826                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID,
827                                            args);
828                            }
829                    }
830    
831                    entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
832                            OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor, false);
833    
834                    orgLabor.resetOriginalValues();
835    
836                    return orgLabor;
837            }
838    
839            protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
840                    if (orgLabor instanceof OrgLaborImpl) {
841                            return orgLabor;
842                    }
843    
844                    OrgLaborImpl orgLaborImpl = new OrgLaborImpl();
845    
846                    orgLaborImpl.setNew(orgLabor.isNew());
847                    orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());
848    
849                    orgLaborImpl.setMvccVersion(orgLabor.getMvccVersion());
850                    orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
851                    orgLaborImpl.setCompanyId(orgLabor.getCompanyId());
852                    orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
853                    orgLaborImpl.setTypeId(orgLabor.getTypeId());
854                    orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
855                    orgLaborImpl.setSunClose(orgLabor.getSunClose());
856                    orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
857                    orgLaborImpl.setMonClose(orgLabor.getMonClose());
858                    orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
859                    orgLaborImpl.setTueClose(orgLabor.getTueClose());
860                    orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
861                    orgLaborImpl.setWedClose(orgLabor.getWedClose());
862                    orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
863                    orgLaborImpl.setThuClose(orgLabor.getThuClose());
864                    orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
865                    orgLaborImpl.setFriClose(orgLabor.getFriClose());
866                    orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
867                    orgLaborImpl.setSatClose(orgLabor.getSatClose());
868    
869                    return orgLaborImpl;
870            }
871    
872            /**
873             * Returns the org labor with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
874             *
875             * @param primaryKey the primary key of the org labor
876             * @return the org labor
877             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
878             */
879            @Override
880            public OrgLabor findByPrimaryKey(Serializable primaryKey)
881                    throws NoSuchOrgLaborException {
882                    OrgLabor orgLabor = fetchByPrimaryKey(primaryKey);
883    
884                    if (orgLabor == null) {
885                            if (_log.isWarnEnabled()) {
886                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
887                            }
888    
889                            throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
890                                    primaryKey);
891                    }
892    
893                    return orgLabor;
894            }
895    
896            /**
897             * Returns the org labor with the primary key or throws a {@link NoSuchOrgLaborException} if it could not be found.
898             *
899             * @param orgLaborId the primary key of the org labor
900             * @return the org labor
901             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
902             */
903            @Override
904            public OrgLabor findByPrimaryKey(long orgLaborId)
905                    throws NoSuchOrgLaborException {
906                    return findByPrimaryKey((Serializable)orgLaborId);
907            }
908    
909            /**
910             * Returns the org labor with the primary key or returns <code>null</code> if it could not be found.
911             *
912             * @param primaryKey the primary key of the org labor
913             * @return the org labor, or <code>null</code> if a org labor with the primary key could not be found
914             */
915            @Override
916            public OrgLabor fetchByPrimaryKey(Serializable primaryKey) {
917                    OrgLabor orgLabor = (OrgLabor)entityCache.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
918                                    OrgLaborImpl.class, primaryKey);
919    
920                    if (orgLabor == _nullOrgLabor) {
921                            return null;
922                    }
923    
924                    if (orgLabor == null) {
925                            Session session = null;
926    
927                            try {
928                                    session = openSession();
929    
930                                    orgLabor = (OrgLabor)session.get(OrgLaborImpl.class, primaryKey);
931    
932                                    if (orgLabor != null) {
933                                            cacheResult(orgLabor);
934                                    }
935                                    else {
936                                            entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
937                                                    OrgLaborImpl.class, primaryKey, _nullOrgLabor);
938                                    }
939                            }
940                            catch (Exception e) {
941                                    entityCache.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
942                                            OrgLaborImpl.class, primaryKey);
943    
944                                    throw processException(e);
945                            }
946                            finally {
947                                    closeSession(session);
948                            }
949                    }
950    
951                    return orgLabor;
952            }
953    
954            /**
955             * Returns the org labor with the primary key or returns <code>null</code> if it could not be found.
956             *
957             * @param orgLaborId the primary key of the org labor
958             * @return the org labor, or <code>null</code> if a org labor with the primary key could not be found
959             */
960            @Override
961            public OrgLabor fetchByPrimaryKey(long orgLaborId) {
962                    return fetchByPrimaryKey((Serializable)orgLaborId);
963            }
964    
965            @Override
966            public Map<Serializable, OrgLabor> fetchByPrimaryKeys(
967                    Set<Serializable> primaryKeys) {
968                    if (primaryKeys.isEmpty()) {
969                            return Collections.emptyMap();
970                    }
971    
972                    Map<Serializable, OrgLabor> map = new HashMap<Serializable, OrgLabor>();
973    
974                    if (primaryKeys.size() == 1) {
975                            Iterator<Serializable> iterator = primaryKeys.iterator();
976    
977                            Serializable primaryKey = iterator.next();
978    
979                            OrgLabor orgLabor = fetchByPrimaryKey(primaryKey);
980    
981                            if (orgLabor != null) {
982                                    map.put(primaryKey, orgLabor);
983                            }
984    
985                            return map;
986                    }
987    
988                    Set<Serializable> uncachedPrimaryKeys = null;
989    
990                    for (Serializable primaryKey : primaryKeys) {
991                            OrgLabor orgLabor = (OrgLabor)entityCache.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
992                                            OrgLaborImpl.class, primaryKey);
993    
994                            if (orgLabor == null) {
995                                    if (uncachedPrimaryKeys == null) {
996                                            uncachedPrimaryKeys = new HashSet<Serializable>();
997                                    }
998    
999                                    uncachedPrimaryKeys.add(primaryKey);
1000                            }
1001                            else {
1002                                    map.put(primaryKey, orgLabor);
1003                            }
1004                    }
1005    
1006                    if (uncachedPrimaryKeys == null) {
1007                            return map;
1008                    }
1009    
1010                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1011                                    1);
1012    
1013                    query.append(_SQL_SELECT_ORGLABOR_WHERE_PKS_IN);
1014    
1015                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1016                            query.append(String.valueOf(primaryKey));
1017    
1018                            query.append(StringPool.COMMA);
1019                    }
1020    
1021                    query.setIndex(query.index() - 1);
1022    
1023                    query.append(StringPool.CLOSE_PARENTHESIS);
1024    
1025                    String sql = query.toString();
1026    
1027                    Session session = null;
1028    
1029                    try {
1030                            session = openSession();
1031    
1032                            Query q = session.createQuery(sql);
1033    
1034                            for (OrgLabor orgLabor : (List<OrgLabor>)q.list()) {
1035                                    map.put(orgLabor.getPrimaryKeyObj(), orgLabor);
1036    
1037                                    cacheResult(orgLabor);
1038    
1039                                    uncachedPrimaryKeys.remove(orgLabor.getPrimaryKeyObj());
1040                            }
1041    
1042                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1043                                    entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
1044                                            OrgLaborImpl.class, primaryKey, _nullOrgLabor);
1045                            }
1046                    }
1047                    catch (Exception e) {
1048                            throw processException(e);
1049                    }
1050                    finally {
1051                            closeSession(session);
1052                    }
1053    
1054                    return map;
1055            }
1056    
1057            /**
1058             * Returns all the org labors.
1059             *
1060             * @return the org labors
1061             */
1062            @Override
1063            public List<OrgLabor> findAll() {
1064                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1065            }
1066    
1067            /**
1068             * Returns a range of all the org labors.
1069             *
1070             * <p>
1071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1072             * </p>
1073             *
1074             * @param start the lower bound of the range of org labors
1075             * @param end the upper bound of the range of org labors (not inclusive)
1076             * @return the range of org labors
1077             */
1078            @Override
1079            public List<OrgLabor> findAll(int start, int end) {
1080                    return findAll(start, end, null);
1081            }
1082    
1083            /**
1084             * Returns an ordered range of all the org labors.
1085             *
1086             * <p>
1087             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1088             * </p>
1089             *
1090             * @param start the lower bound of the range of org labors
1091             * @param end the upper bound of the range of org labors (not inclusive)
1092             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1093             * @return the ordered range of org labors
1094             */
1095            @Override
1096            public List<OrgLabor> findAll(int start, int end,
1097                    OrderByComparator<OrgLabor> orderByComparator) {
1098                    return findAll(start, end, orderByComparator, true);
1099            }
1100    
1101            /**
1102             * Returns an ordered range of all the org labors.
1103             *
1104             * <p>
1105             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link OrgLaborModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1106             * </p>
1107             *
1108             * @param start the lower bound of the range of org labors
1109             * @param end the upper bound of the range of org labors (not inclusive)
1110             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1111             * @param retrieveFromCache whether to retrieve from the finder cache
1112             * @return the ordered range of org labors
1113             */
1114            @Override
1115            public List<OrgLabor> findAll(int start, int end,
1116                    OrderByComparator<OrgLabor> orderByComparator, boolean retrieveFromCache) {
1117                    boolean pagination = true;
1118                    FinderPath finderPath = null;
1119                    Object[] finderArgs = null;
1120    
1121                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1122                                    (orderByComparator == null)) {
1123                            pagination = false;
1124                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1125                            finderArgs = FINDER_ARGS_EMPTY;
1126                    }
1127                    else {
1128                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1129                            finderArgs = new Object[] { start, end, orderByComparator };
1130                    }
1131    
1132                    List<OrgLabor> list = null;
1133    
1134                    if (retrieveFromCache) {
1135                            list = (List<OrgLabor>)finderCache.getResult(finderPath,
1136                                            finderArgs, this);
1137                    }
1138    
1139                    if (list == null) {
1140                            StringBundler query = null;
1141                            String sql = null;
1142    
1143                            if (orderByComparator != null) {
1144                                    query = new StringBundler(2 +
1145                                                    (orderByComparator.getOrderByFields().length * 3));
1146    
1147                                    query.append(_SQL_SELECT_ORGLABOR);
1148    
1149                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1150                                            orderByComparator);
1151    
1152                                    sql = query.toString();
1153                            }
1154                            else {
1155                                    sql = _SQL_SELECT_ORGLABOR;
1156    
1157                                    if (pagination) {
1158                                            sql = sql.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
1159                                    }
1160                            }
1161    
1162                            Session session = null;
1163    
1164                            try {
1165                                    session = openSession();
1166    
1167                                    Query q = session.createQuery(sql);
1168    
1169                                    if (!pagination) {
1170                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
1171                                                            start, end, false);
1172    
1173                                            Collections.sort(list);
1174    
1175                                            list = Collections.unmodifiableList(list);
1176                                    }
1177                                    else {
1178                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
1179                                                            start, end);
1180                                    }
1181    
1182                                    cacheResult(list);
1183    
1184                                    finderCache.putResult(finderPath, finderArgs, list);
1185                            }
1186                            catch (Exception e) {
1187                                    finderCache.removeResult(finderPath, finderArgs);
1188    
1189                                    throw processException(e);
1190                            }
1191                            finally {
1192                                    closeSession(session);
1193                            }
1194                    }
1195    
1196                    return list;
1197            }
1198    
1199            /**
1200             * Removes all the org labors from the database.
1201             *
1202             */
1203            @Override
1204            public void removeAll() {
1205                    for (OrgLabor orgLabor : findAll()) {
1206                            remove(orgLabor);
1207                    }
1208            }
1209    
1210            /**
1211             * Returns the number of org labors.
1212             *
1213             * @return the number of org labors
1214             */
1215            @Override
1216            public int countAll() {
1217                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1218                                    FINDER_ARGS_EMPTY, this);
1219    
1220                    if (count == null) {
1221                            Session session = null;
1222    
1223                            try {
1224                                    session = openSession();
1225    
1226                                    Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
1227    
1228                                    count = (Long)q.uniqueResult();
1229    
1230                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1231                                            count);
1232                            }
1233                            catch (Exception e) {
1234                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1235                                            FINDER_ARGS_EMPTY);
1236    
1237                                    throw processException(e);
1238                            }
1239                            finally {
1240                                    closeSession(session);
1241                            }
1242                    }
1243    
1244                    return count.intValue();
1245            }
1246    
1247            @Override
1248            protected Map<String, Integer> getTableColumnsMap() {
1249                    return OrgLaborModelImpl.TABLE_COLUMNS_MAP;
1250            }
1251    
1252            /**
1253             * Initializes the org labor persistence.
1254             */
1255            public void afterPropertiesSet() {
1256            }
1257    
1258            public void destroy() {
1259                    entityCache.removeCache(OrgLaborImpl.class.getName());
1260                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1261                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1262                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1263            }
1264    
1265            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1266            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1267            private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
1268            private static final String _SQL_SELECT_ORGLABOR_WHERE_PKS_IN = "SELECT orgLabor FROM OrgLabor orgLabor WHERE orgLaborId IN (";
1269            private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
1270            private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
1271            private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
1272            private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
1273            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
1274            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
1275            private static final Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
1276            private static final OrgLabor _nullOrgLabor = new OrgLaborImpl() {
1277                            @Override
1278                            public Object clone() {
1279                                    return this;
1280                            }
1281    
1282                            @Override
1283                            public CacheModel<OrgLabor> toCacheModel() {
1284                                    return _nullOrgLaborCacheModel;
1285                            }
1286                    };
1287    
1288            private static final CacheModel<OrgLabor> _nullOrgLaborCacheModel = new NullCacheModel();
1289    
1290            private static class NullCacheModel implements CacheModel<OrgLabor>,
1291                    MVCCModel {
1292                    @Override
1293                    public long getMvccVersion() {
1294                            return -1;
1295                    }
1296    
1297                    @Override
1298                    public void setMvccVersion(long mvccVersion) {
1299                    }
1300    
1301                    @Override
1302                    public OrgLabor toEntityModel() {
1303                            return _nullOrgLabor;
1304                    }
1305            }
1306    }