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.setOrganizationId(orgLabor.getOrganizationId());
852                    orgLaborImpl.setTypeId(orgLabor.getTypeId());
853                    orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
854                    orgLaborImpl.setSunClose(orgLabor.getSunClose());
855                    orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
856                    orgLaborImpl.setMonClose(orgLabor.getMonClose());
857                    orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
858                    orgLaborImpl.setTueClose(orgLabor.getTueClose());
859                    orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
860                    orgLaborImpl.setWedClose(orgLabor.getWedClose());
861                    orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
862                    orgLaborImpl.setThuClose(orgLabor.getThuClose());
863                    orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
864                    orgLaborImpl.setFriClose(orgLabor.getFriClose());
865                    orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
866                    orgLaborImpl.setSatClose(orgLabor.getSatClose());
867    
868                    return orgLaborImpl;
869            }
870    
871            /**
872             * Returns the org labor with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
873             *
874             * @param primaryKey the primary key of the org labor
875             * @return the org labor
876             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
877             */
878            @Override
879            public OrgLabor findByPrimaryKey(Serializable primaryKey)
880                    throws NoSuchOrgLaborException {
881                    OrgLabor orgLabor = fetchByPrimaryKey(primaryKey);
882    
883                    if (orgLabor == null) {
884                            if (_log.isWarnEnabled()) {
885                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
886                            }
887    
888                            throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
889                                    primaryKey);
890                    }
891    
892                    return orgLabor;
893            }
894    
895            /**
896             * Returns the org labor with the primary key or throws a {@link NoSuchOrgLaborException} if it could not be found.
897             *
898             * @param orgLaborId the primary key of the org labor
899             * @return the org labor
900             * @throws NoSuchOrgLaborException if a org labor with the primary key could not be found
901             */
902            @Override
903            public OrgLabor findByPrimaryKey(long orgLaborId)
904                    throws NoSuchOrgLaborException {
905                    return findByPrimaryKey((Serializable)orgLaborId);
906            }
907    
908            /**
909             * Returns the org labor with the primary key or returns <code>null</code> if it could not be found.
910             *
911             * @param primaryKey the primary key of the org labor
912             * @return the org labor, or <code>null</code> if a org labor with the primary key could not be found
913             */
914            @Override
915            public OrgLabor fetchByPrimaryKey(Serializable primaryKey) {
916                    OrgLabor orgLabor = (OrgLabor)entityCache.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
917                                    OrgLaborImpl.class, primaryKey);
918    
919                    if (orgLabor == _nullOrgLabor) {
920                            return null;
921                    }
922    
923                    if (orgLabor == null) {
924                            Session session = null;
925    
926                            try {
927                                    session = openSession();
928    
929                                    orgLabor = (OrgLabor)session.get(OrgLaborImpl.class, primaryKey);
930    
931                                    if (orgLabor != null) {
932                                            cacheResult(orgLabor);
933                                    }
934                                    else {
935                                            entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
936                                                    OrgLaborImpl.class, primaryKey, _nullOrgLabor);
937                                    }
938                            }
939                            catch (Exception e) {
940                                    entityCache.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
941                                            OrgLaborImpl.class, primaryKey);
942    
943                                    throw processException(e);
944                            }
945                            finally {
946                                    closeSession(session);
947                            }
948                    }
949    
950                    return orgLabor;
951            }
952    
953            /**
954             * Returns the org labor with the primary key or returns <code>null</code> if it could not be found.
955             *
956             * @param orgLaborId the primary key of the org labor
957             * @return the org labor, or <code>null</code> if a org labor with the primary key could not be found
958             */
959            @Override
960            public OrgLabor fetchByPrimaryKey(long orgLaborId) {
961                    return fetchByPrimaryKey((Serializable)orgLaborId);
962            }
963    
964            @Override
965            public Map<Serializable, OrgLabor> fetchByPrimaryKeys(
966                    Set<Serializable> primaryKeys) {
967                    if (primaryKeys.isEmpty()) {
968                            return Collections.emptyMap();
969                    }
970    
971                    Map<Serializable, OrgLabor> map = new HashMap<Serializable, OrgLabor>();
972    
973                    if (primaryKeys.size() == 1) {
974                            Iterator<Serializable> iterator = primaryKeys.iterator();
975    
976                            Serializable primaryKey = iterator.next();
977    
978                            OrgLabor orgLabor = fetchByPrimaryKey(primaryKey);
979    
980                            if (orgLabor != null) {
981                                    map.put(primaryKey, orgLabor);
982                            }
983    
984                            return map;
985                    }
986    
987                    Set<Serializable> uncachedPrimaryKeys = null;
988    
989                    for (Serializable primaryKey : primaryKeys) {
990                            OrgLabor orgLabor = (OrgLabor)entityCache.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
991                                            OrgLaborImpl.class, primaryKey);
992    
993                            if (orgLabor == null) {
994                                    if (uncachedPrimaryKeys == null) {
995                                            uncachedPrimaryKeys = new HashSet<Serializable>();
996                                    }
997    
998                                    uncachedPrimaryKeys.add(primaryKey);
999                            }
1000                            else {
1001                                    map.put(primaryKey, orgLabor);
1002                            }
1003                    }
1004    
1005                    if (uncachedPrimaryKeys == null) {
1006                            return map;
1007                    }
1008    
1009                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1010                                    1);
1011    
1012                    query.append(_SQL_SELECT_ORGLABOR_WHERE_PKS_IN);
1013    
1014                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1015                            query.append(String.valueOf(primaryKey));
1016    
1017                            query.append(StringPool.COMMA);
1018                    }
1019    
1020                    query.setIndex(query.index() - 1);
1021    
1022                    query.append(StringPool.CLOSE_PARENTHESIS);
1023    
1024                    String sql = query.toString();
1025    
1026                    Session session = null;
1027    
1028                    try {
1029                            session = openSession();
1030    
1031                            Query q = session.createQuery(sql);
1032    
1033                            for (OrgLabor orgLabor : (List<OrgLabor>)q.list()) {
1034                                    map.put(orgLabor.getPrimaryKeyObj(), orgLabor);
1035    
1036                                    cacheResult(orgLabor);
1037    
1038                                    uncachedPrimaryKeys.remove(orgLabor.getPrimaryKeyObj());
1039                            }
1040    
1041                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1042                                    entityCache.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
1043                                            OrgLaborImpl.class, primaryKey, _nullOrgLabor);
1044                            }
1045                    }
1046                    catch (Exception e) {
1047                            throw processException(e);
1048                    }
1049                    finally {
1050                            closeSession(session);
1051                    }
1052    
1053                    return map;
1054            }
1055    
1056            /**
1057             * Returns all the org labors.
1058             *
1059             * @return the org labors
1060             */
1061            @Override
1062            public List<OrgLabor> findAll() {
1063                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1064            }
1065    
1066            /**
1067             * Returns a range of all the org labors.
1068             *
1069             * <p>
1070             * 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.
1071             * </p>
1072             *
1073             * @param start the lower bound of the range of org labors
1074             * @param end the upper bound of the range of org labors (not inclusive)
1075             * @return the range of org labors
1076             */
1077            @Override
1078            public List<OrgLabor> findAll(int start, int end) {
1079                    return findAll(start, end, null);
1080            }
1081    
1082            /**
1083             * Returns an ordered range of all the org labors.
1084             *
1085             * <p>
1086             * 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.
1087             * </p>
1088             *
1089             * @param start the lower bound of the range of org labors
1090             * @param end the upper bound of the range of org labors (not inclusive)
1091             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1092             * @return the ordered range of org labors
1093             */
1094            @Override
1095            public List<OrgLabor> findAll(int start, int end,
1096                    OrderByComparator<OrgLabor> orderByComparator) {
1097                    return findAll(start, end, orderByComparator, true);
1098            }
1099    
1100            /**
1101             * Returns an ordered range of all the org labors.
1102             *
1103             * <p>
1104             * 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.
1105             * </p>
1106             *
1107             * @param start the lower bound of the range of org labors
1108             * @param end the upper bound of the range of org labors (not inclusive)
1109             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1110             * @param retrieveFromCache whether to retrieve from the finder cache
1111             * @return the ordered range of org labors
1112             */
1113            @Override
1114            public List<OrgLabor> findAll(int start, int end,
1115                    OrderByComparator<OrgLabor> orderByComparator, boolean retrieveFromCache) {
1116                    boolean pagination = true;
1117                    FinderPath finderPath = null;
1118                    Object[] finderArgs = null;
1119    
1120                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1121                                    (orderByComparator == null)) {
1122                            pagination = false;
1123                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1124                            finderArgs = FINDER_ARGS_EMPTY;
1125                    }
1126                    else {
1127                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1128                            finderArgs = new Object[] { start, end, orderByComparator };
1129                    }
1130    
1131                    List<OrgLabor> list = null;
1132    
1133                    if (retrieveFromCache) {
1134                            list = (List<OrgLabor>)finderCache.getResult(finderPath,
1135                                            finderArgs, this);
1136                    }
1137    
1138                    if (list == null) {
1139                            StringBundler query = null;
1140                            String sql = null;
1141    
1142                            if (orderByComparator != null) {
1143                                    query = new StringBundler(2 +
1144                                                    (orderByComparator.getOrderByFields().length * 3));
1145    
1146                                    query.append(_SQL_SELECT_ORGLABOR);
1147    
1148                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1149                                            orderByComparator);
1150    
1151                                    sql = query.toString();
1152                            }
1153                            else {
1154                                    sql = _SQL_SELECT_ORGLABOR;
1155    
1156                                    if (pagination) {
1157                                            sql = sql.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
1158                                    }
1159                            }
1160    
1161                            Session session = null;
1162    
1163                            try {
1164                                    session = openSession();
1165    
1166                                    Query q = session.createQuery(sql);
1167    
1168                                    if (!pagination) {
1169                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
1170                                                            start, end, false);
1171    
1172                                            Collections.sort(list);
1173    
1174                                            list = Collections.unmodifiableList(list);
1175                                    }
1176                                    else {
1177                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
1178                                                            start, end);
1179                                    }
1180    
1181                                    cacheResult(list);
1182    
1183                                    finderCache.putResult(finderPath, finderArgs, list);
1184                            }
1185                            catch (Exception e) {
1186                                    finderCache.removeResult(finderPath, finderArgs);
1187    
1188                                    throw processException(e);
1189                            }
1190                            finally {
1191                                    closeSession(session);
1192                            }
1193                    }
1194    
1195                    return list;
1196            }
1197    
1198            /**
1199             * Removes all the org labors from the database.
1200             *
1201             */
1202            @Override
1203            public void removeAll() {
1204                    for (OrgLabor orgLabor : findAll()) {
1205                            remove(orgLabor);
1206                    }
1207            }
1208    
1209            /**
1210             * Returns the number of org labors.
1211             *
1212             * @return the number of org labors
1213             */
1214            @Override
1215            public int countAll() {
1216                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1217                                    FINDER_ARGS_EMPTY, this);
1218    
1219                    if (count == null) {
1220                            Session session = null;
1221    
1222                            try {
1223                                    session = openSession();
1224    
1225                                    Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
1226    
1227                                    count = (Long)q.uniqueResult();
1228    
1229                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1230                                            count);
1231                            }
1232                            catch (Exception e) {
1233                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1234                                            FINDER_ARGS_EMPTY);
1235    
1236                                    throw processException(e);
1237                            }
1238                            finally {
1239                                    closeSession(session);
1240                            }
1241                    }
1242    
1243                    return count.intValue();
1244            }
1245    
1246            @Override
1247            protected Map<String, Integer> getTableColumnsMap() {
1248                    return OrgLaborModelImpl.TABLE_COLUMNS_MAP;
1249            }
1250    
1251            /**
1252             * Initializes the org labor persistence.
1253             */
1254            public void afterPropertiesSet() {
1255            }
1256    
1257            public void destroy() {
1258                    entityCache.removeCache(OrgLaborImpl.class.getName());
1259                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1260                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1261                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1262            }
1263    
1264            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1265            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1266            private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
1267            private static final String _SQL_SELECT_ORGLABOR_WHERE_PKS_IN = "SELECT orgLabor FROM OrgLabor orgLabor WHERE orgLaborId IN (";
1268            private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
1269            private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
1270            private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
1271            private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
1272            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
1273            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
1274            private static final Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
1275            private static final OrgLabor _nullOrgLabor = new OrgLaborImpl() {
1276                            @Override
1277                            public Object clone() {
1278                                    return this;
1279                            }
1280    
1281                            @Override
1282                            public CacheModel<OrgLabor> toCacheModel() {
1283                                    return _nullOrgLaborCacheModel;
1284                            }
1285                    };
1286    
1287            private static final CacheModel<OrgLabor> _nullOrgLaborCacheModel = new NullCacheModel();
1288    
1289            private static class NullCacheModel implements CacheModel<OrgLabor>,
1290                    MVCCModel {
1291                    @Override
1292                    public long getMvccVersion() {
1293                            return -1;
1294                    }
1295    
1296                    @Override
1297                    public void setMvccVersion(long mvccVersion) {
1298                    }
1299    
1300                    @Override
1301                    public OrgLabor toEntityModel() {
1302                            return _nullOrgLabor;
1303                    }
1304            }
1305    }