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