1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.NoSuchOrgLaborException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
29  import com.liferay.portal.kernel.exception.SystemException;
30  import com.liferay.portal.kernel.log.Log;
31  import com.liferay.portal.kernel.log.LogFactoryUtil;
32  import com.liferay.portal.kernel.util.GetterUtil;
33  import com.liferay.portal.kernel.util.OrderByComparator;
34  import com.liferay.portal.kernel.util.StringBundler;
35  import com.liferay.portal.kernel.util.StringPool;
36  import com.liferay.portal.kernel.util.StringUtil;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.model.OrgLabor;
39  import com.liferay.portal.model.impl.OrgLaborImpl;
40  import com.liferay.portal.model.impl.OrgLaborModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="OrgLaborPersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       OrgLaborPersistence
59   * @see       OrgLaborUtil
60   * @generated
61   */
62  public class OrgLaborPersistenceImpl extends BasePersistenceImpl<OrgLabor>
63      implements OrgLaborPersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = OrgLaborImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
68              OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69              "findByOrganizationId", new String[] { Long.class.getName() });
70      public static final FinderPath FINDER_PATH_FIND_BY_OBC_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
71              OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
72              "findByOrganizationId",
73              new String[] {
74                  Long.class.getName(),
75                  
76              "java.lang.Integer", "java.lang.Integer",
77                  "com.liferay.portal.kernel.util.OrderByComparator"
78              });
79      public static final FinderPath FINDER_PATH_COUNT_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
80              OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81              "countByOrganizationId", new String[] { Long.class.getName() });
82      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
83              OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84              "findAll", new String[0]);
85      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
86              OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87              "countAll", new String[0]);
88  
89      public void cacheResult(OrgLabor orgLabor) {
90          EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
91              OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
92      }
93  
94      public void cacheResult(List<OrgLabor> orgLabors) {
95          for (OrgLabor orgLabor : orgLabors) {
96              if (EntityCacheUtil.getResult(
97                          OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
98                          OrgLaborImpl.class, orgLabor.getPrimaryKey(), this) == null) {
99                  cacheResult(orgLabor);
100             }
101         }
102     }
103 
104     public void clearCache() {
105         CacheRegistry.clear(OrgLaborImpl.class.getName());
106         EntityCacheUtil.clearCache(OrgLaborImpl.class.getName());
107         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
108         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
109     }
110 
111     public OrgLabor create(long orgLaborId) {
112         OrgLabor orgLabor = new OrgLaborImpl();
113 
114         orgLabor.setNew(true);
115         orgLabor.setPrimaryKey(orgLaborId);
116 
117         return orgLabor;
118     }
119 
120     public OrgLabor remove(Serializable primaryKey)
121         throws NoSuchModelException, SystemException {
122         return remove(((Long)primaryKey).longValue());
123     }
124 
125     public OrgLabor remove(long orgLaborId)
126         throws NoSuchOrgLaborException, SystemException {
127         Session session = null;
128 
129         try {
130             session = openSession();
131 
132             OrgLabor orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
133                     new Long(orgLaborId));
134 
135             if (orgLabor == null) {
136                 if (_log.isWarnEnabled()) {
137                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
138                 }
139 
140                 throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
141                     orgLaborId);
142             }
143 
144             return remove(orgLabor);
145         }
146         catch (NoSuchOrgLaborException nsee) {
147             throw nsee;
148         }
149         catch (Exception e) {
150             throw processException(e);
151         }
152         finally {
153             closeSession(session);
154         }
155     }
156 
157     public OrgLabor remove(OrgLabor orgLabor) throws SystemException {
158         for (ModelListener<OrgLabor> listener : listeners) {
159             listener.onBeforeRemove(orgLabor);
160         }
161 
162         orgLabor = removeImpl(orgLabor);
163 
164         for (ModelListener<OrgLabor> listener : listeners) {
165             listener.onAfterRemove(orgLabor);
166         }
167 
168         return orgLabor;
169     }
170 
171     protected OrgLabor removeImpl(OrgLabor orgLabor) throws SystemException {
172         orgLabor = toUnwrappedModel(orgLabor);
173 
174         Session session = null;
175 
176         try {
177             session = openSession();
178 
179             if (orgLabor.isCachedModel() || BatchSessionUtil.isEnabled()) {
180                 Object staleObject = session.get(OrgLaborImpl.class,
181                         orgLabor.getPrimaryKeyObj());
182 
183                 if (staleObject != null) {
184                     session.evict(staleObject);
185                 }
186             }
187 
188             session.delete(orgLabor);
189 
190             session.flush();
191         }
192         catch (Exception e) {
193             throw processException(e);
194         }
195         finally {
196             closeSession(session);
197         }
198 
199         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
200 
201         EntityCacheUtil.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
202             OrgLaborImpl.class, orgLabor.getPrimaryKey());
203 
204         return orgLabor;
205     }
206 
207     public OrgLabor updateImpl(com.liferay.portal.model.OrgLabor orgLabor,
208         boolean merge) throws SystemException {
209         orgLabor = toUnwrappedModel(orgLabor);
210 
211         Session session = null;
212 
213         try {
214             session = openSession();
215 
216             BatchSessionUtil.update(session, orgLabor, merge);
217 
218             orgLabor.setNew(false);
219         }
220         catch (Exception e) {
221             throw processException(e);
222         }
223         finally {
224             closeSession(session);
225         }
226 
227         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
228 
229         EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
230             OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
231 
232         return orgLabor;
233     }
234 
235     protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
236         if (orgLabor instanceof OrgLaborImpl) {
237             return orgLabor;
238         }
239 
240         OrgLaborImpl orgLaborImpl = new OrgLaborImpl();
241 
242         orgLaborImpl.setNew(orgLabor.isNew());
243         orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());
244 
245         orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
246         orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
247         orgLaborImpl.setTypeId(orgLabor.getTypeId());
248         orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
249         orgLaborImpl.setSunClose(orgLabor.getSunClose());
250         orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
251         orgLaborImpl.setMonClose(orgLabor.getMonClose());
252         orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
253         orgLaborImpl.setTueClose(orgLabor.getTueClose());
254         orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
255         orgLaborImpl.setWedClose(orgLabor.getWedClose());
256         orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
257         orgLaborImpl.setThuClose(orgLabor.getThuClose());
258         orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
259         orgLaborImpl.setFriClose(orgLabor.getFriClose());
260         orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
261         orgLaborImpl.setSatClose(orgLabor.getSatClose());
262 
263         return orgLaborImpl;
264     }
265 
266     public OrgLabor findByPrimaryKey(Serializable primaryKey)
267         throws NoSuchModelException, SystemException {
268         return findByPrimaryKey(((Long)primaryKey).longValue());
269     }
270 
271     public OrgLabor findByPrimaryKey(long orgLaborId)
272         throws NoSuchOrgLaborException, SystemException {
273         OrgLabor orgLabor = fetchByPrimaryKey(orgLaborId);
274 
275         if (orgLabor == null) {
276             if (_log.isWarnEnabled()) {
277                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
278             }
279 
280             throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
281                 orgLaborId);
282         }
283 
284         return orgLabor;
285     }
286 
287     public OrgLabor fetchByPrimaryKey(Serializable primaryKey)
288         throws SystemException {
289         return fetchByPrimaryKey(((Long)primaryKey).longValue());
290     }
291 
292     public OrgLabor fetchByPrimaryKey(long orgLaborId)
293         throws SystemException {
294         OrgLabor orgLabor = (OrgLabor)EntityCacheUtil.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
295                 OrgLaborImpl.class, orgLaborId, this);
296 
297         if (orgLabor == null) {
298             Session session = null;
299 
300             try {
301                 session = openSession();
302 
303                 orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
304                         new Long(orgLaborId));
305             }
306             catch (Exception e) {
307                 throw processException(e);
308             }
309             finally {
310                 if (orgLabor != null) {
311                     cacheResult(orgLabor);
312                 }
313 
314                 closeSession(session);
315             }
316         }
317 
318         return orgLabor;
319     }
320 
321     public List<OrgLabor> findByOrganizationId(long organizationId)
322         throws SystemException {
323         Object[] finderArgs = new Object[] { new Long(organizationId) };
324 
325         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
326                 finderArgs, this);
327 
328         if (list == null) {
329             Session session = null;
330 
331             try {
332                 session = openSession();
333 
334                 StringBundler query = new StringBundler(3);
335 
336                 query.append(_SQL_SELECT_ORGLABOR_WHERE);
337 
338                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
339 
340                 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
341 
342                 String sql = query.toString();
343 
344                 Query q = session.createQuery(sql);
345 
346                 QueryPos qPos = QueryPos.getInstance(q);
347 
348                 qPos.add(organizationId);
349 
350                 list = q.list();
351             }
352             catch (Exception e) {
353                 throw processException(e);
354             }
355             finally {
356                 if (list == null) {
357                     list = new ArrayList<OrgLabor>();
358                 }
359 
360                 cacheResult(list);
361 
362                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
363                     finderArgs, list);
364 
365                 closeSession(session);
366             }
367         }
368 
369         return list;
370     }
371 
372     public List<OrgLabor> findByOrganizationId(long organizationId, int start,
373         int end) throws SystemException {
374         return findByOrganizationId(organizationId, start, end, null);
375     }
376 
377     public List<OrgLabor> findByOrganizationId(long organizationId, int start,
378         int end, OrderByComparator obc) throws SystemException {
379         Object[] finderArgs = new Object[] {
380                 new Long(organizationId),
381                 
382                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
383             };
384 
385         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ORGANIZATIONID,
386                 finderArgs, this);
387 
388         if (list == null) {
389             Session session = null;
390 
391             try {
392                 session = openSession();
393 
394                 StringBundler query = null;
395 
396                 if (obc != null) {
397                     query = new StringBundler(3 +
398                             (obc.getOrderByFields().length * 3));
399                 }
400                 else {
401                     query = new StringBundler(3);
402                 }
403 
404                 query.append(_SQL_SELECT_ORGLABOR_WHERE);
405 
406                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
407 
408                 if (obc != null) {
409                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
410                 }
411 
412                 else {
413                     query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
414                 }
415 
416                 String sql = query.toString();
417 
418                 Query q = session.createQuery(sql);
419 
420                 QueryPos qPos = QueryPos.getInstance(q);
421 
422                 qPos.add(organizationId);
423 
424                 list = (List<OrgLabor>)QueryUtil.list(q, getDialect(), start,
425                         end);
426             }
427             catch (Exception e) {
428                 throw processException(e);
429             }
430             finally {
431                 if (list == null) {
432                     list = new ArrayList<OrgLabor>();
433                 }
434 
435                 cacheResult(list);
436 
437                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ORGANIZATIONID,
438                     finderArgs, list);
439 
440                 closeSession(session);
441             }
442         }
443 
444         return list;
445     }
446 
447     public OrgLabor findByOrganizationId_First(long organizationId,
448         OrderByComparator obc) throws NoSuchOrgLaborException, SystemException {
449         List<OrgLabor> list = findByOrganizationId(organizationId, 0, 1, obc);
450 
451         if (list.isEmpty()) {
452             StringBundler msg = new StringBundler(4);
453 
454             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
455 
456             msg.append("organizationId=");
457             msg.append(organizationId);
458 
459             msg.append(StringPool.CLOSE_CURLY_BRACE);
460 
461             throw new NoSuchOrgLaborException(msg.toString());
462         }
463         else {
464             return list.get(0);
465         }
466     }
467 
468     public OrgLabor findByOrganizationId_Last(long organizationId,
469         OrderByComparator obc) throws NoSuchOrgLaborException, SystemException {
470         int count = countByOrganizationId(organizationId);
471 
472         List<OrgLabor> list = findByOrganizationId(organizationId, count - 1,
473                 count, obc);
474 
475         if (list.isEmpty()) {
476             StringBundler msg = new StringBundler(4);
477 
478             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
479 
480             msg.append("organizationId=");
481             msg.append(organizationId);
482 
483             msg.append(StringPool.CLOSE_CURLY_BRACE);
484 
485             throw new NoSuchOrgLaborException(msg.toString());
486         }
487         else {
488             return list.get(0);
489         }
490     }
491 
492     public OrgLabor[] findByOrganizationId_PrevAndNext(long orgLaborId,
493         long organizationId, OrderByComparator obc)
494         throws NoSuchOrgLaborException, SystemException {
495         OrgLabor orgLabor = findByPrimaryKey(orgLaborId);
496 
497         int count = countByOrganizationId(organizationId);
498 
499         Session session = null;
500 
501         try {
502             session = openSession();
503 
504             StringBundler query = null;
505 
506             if (obc != null) {
507                 query = new StringBundler(3 +
508                         (obc.getOrderByFields().length * 3));
509             }
510             else {
511                 query = new StringBundler(3);
512             }
513 
514             query.append(_SQL_SELECT_ORGLABOR_WHERE);
515 
516             query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
517 
518             if (obc != null) {
519                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
520             }
521 
522             else {
523                 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
524             }
525 
526             String sql = query.toString();
527 
528             Query q = session.createQuery(sql);
529 
530             QueryPos qPos = QueryPos.getInstance(q);
531 
532             qPos.add(organizationId);
533 
534             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, orgLabor);
535 
536             OrgLabor[] array = new OrgLaborImpl[3];
537 
538             array[0] = (OrgLabor)objArray[0];
539             array[1] = (OrgLabor)objArray[1];
540             array[2] = (OrgLabor)objArray[2];
541 
542             return array;
543         }
544         catch (Exception e) {
545             throw processException(e);
546         }
547         finally {
548             closeSession(session);
549         }
550     }
551 
552     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
553         throws SystemException {
554         Session session = null;
555 
556         try {
557             session = openSession();
558 
559             dynamicQuery.compile(session);
560 
561             return dynamicQuery.list();
562         }
563         catch (Exception e) {
564             throw processException(e);
565         }
566         finally {
567             closeSession(session);
568         }
569     }
570 
571     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
572         int start, int end) throws SystemException {
573         Session session = null;
574 
575         try {
576             session = openSession();
577 
578             dynamicQuery.setLimit(start, end);
579 
580             dynamicQuery.compile(session);
581 
582             return dynamicQuery.list();
583         }
584         catch (Exception e) {
585             throw processException(e);
586         }
587         finally {
588             closeSession(session);
589         }
590     }
591 
592     public List<OrgLabor> findAll() throws SystemException {
593         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
594     }
595 
596     public List<OrgLabor> findAll(int start, int end) throws SystemException {
597         return findAll(start, end, null);
598     }
599 
600     public List<OrgLabor> findAll(int start, int end, OrderByComparator obc)
601         throws SystemException {
602         Object[] finderArgs = new Object[] {
603                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
604             };
605 
606         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
607                 finderArgs, this);
608 
609         if (list == null) {
610             Session session = null;
611 
612             try {
613                 session = openSession();
614 
615                 StringBundler query = null;
616                 String sql = null;
617 
618                 if (obc != null) {
619                     query = new StringBundler(2 +
620                             (obc.getOrderByFields().length * 3));
621 
622                     query.append(_SQL_SELECT_ORGLABOR);
623 
624                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
625 
626                     sql = query.toString();
627                 }
628 
629                 else {
630                     sql = _SQL_SELECT_ORGLABOR.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
631                 }
632 
633                 Query q = session.createQuery(sql);
634 
635                 if (obc == null) {
636                     list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
637                             start, end, false);
638 
639                     Collections.sort(list);
640                 }
641                 else {
642                     list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
643                             start, end);
644                 }
645             }
646             catch (Exception e) {
647                 throw processException(e);
648             }
649             finally {
650                 if (list == null) {
651                     list = new ArrayList<OrgLabor>();
652                 }
653 
654                 cacheResult(list);
655 
656                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
657 
658                 closeSession(session);
659             }
660         }
661 
662         return list;
663     }
664 
665     public void removeByOrganizationId(long organizationId)
666         throws SystemException {
667         for (OrgLabor orgLabor : findByOrganizationId(organizationId)) {
668             remove(orgLabor);
669         }
670     }
671 
672     public void removeAll() throws SystemException {
673         for (OrgLabor orgLabor : findAll()) {
674             remove(orgLabor);
675         }
676     }
677 
678     public int countByOrganizationId(long organizationId)
679         throws SystemException {
680         Object[] finderArgs = new Object[] { new Long(organizationId) };
681 
682         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
683                 finderArgs, this);
684 
685         if (count == null) {
686             Session session = null;
687 
688             try {
689                 session = openSession();
690 
691                 StringBundler query = new StringBundler(2);
692 
693                 query.append(_SQL_COUNT_ORGLABOR_WHERE);
694 
695                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
696 
697                 String sql = query.toString();
698 
699                 Query q = session.createQuery(sql);
700 
701                 QueryPos qPos = QueryPos.getInstance(q);
702 
703                 qPos.add(organizationId);
704 
705                 count = (Long)q.uniqueResult();
706             }
707             catch (Exception e) {
708                 throw processException(e);
709             }
710             finally {
711                 if (count == null) {
712                     count = Long.valueOf(0);
713                 }
714 
715                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
716                     finderArgs, count);
717 
718                 closeSession(session);
719             }
720         }
721 
722         return count.intValue();
723     }
724 
725     public int countAll() throws SystemException {
726         Object[] finderArgs = new Object[0];
727 
728         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
729                 finderArgs, this);
730 
731         if (count == null) {
732             Session session = null;
733 
734             try {
735                 session = openSession();
736 
737                 Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
738 
739                 count = (Long)q.uniqueResult();
740             }
741             catch (Exception e) {
742                 throw processException(e);
743             }
744             finally {
745                 if (count == null) {
746                     count = Long.valueOf(0);
747                 }
748 
749                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
750                     count);
751 
752                 closeSession(session);
753             }
754         }
755 
756         return count.intValue();
757     }
758 
759     public void afterPropertiesSet() {
760         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
761                     com.liferay.portal.util.PropsUtil.get(
762                         "value.object.listener.com.liferay.portal.model.OrgLabor")));
763 
764         if (listenerClassNames.length > 0) {
765             try {
766                 List<ModelListener<OrgLabor>> listenersList = new ArrayList<ModelListener<OrgLabor>>();
767 
768                 for (String listenerClassName : listenerClassNames) {
769                     listenersList.add((ModelListener<OrgLabor>)Class.forName(
770                             listenerClassName).newInstance());
771                 }
772 
773                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
774             }
775             catch (Exception e) {
776                 _log.error(e);
777             }
778         }
779     }
780 
781     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
782     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
783     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
784     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
785     @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
786     protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
787     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
788     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
789     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
790     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
791     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
792     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
793     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
794     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
795     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
796     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
797     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
798     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
799     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
800     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
801     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
802     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
803     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPrototypePersistence")
804     protected com.liferay.portal.service.persistence.LayoutPrototypePersistence layoutPrototypePersistence;
805     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
806     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
807     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPrototypePersistence")
808     protected com.liferay.portal.service.persistence.LayoutSetPrototypePersistence layoutSetPrototypePersistence;
809     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
810     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
811     @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
812     protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
813     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
814     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
815     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
816     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
817     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
818     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
819     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
820     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
821     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
822     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
823     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
824     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
825     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
826     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
827     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
828     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
829     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
830     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
831     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
832     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
833     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
834     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
835     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
836     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
837     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
838     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
839     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
840     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
841     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
842     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
843     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
844     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
845     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
846     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
847     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
848     protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
849     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
850     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
851     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
852     protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
853     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
854     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
855     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
856     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
857     @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
858     protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
859     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
860     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
861     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
862     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
863     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
864     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
865     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
866     protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
867     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
868     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
869     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
870     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
871     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
872     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
873     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
874     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
875     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
876     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
877     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
878     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
879     @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence")
880     protected com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
881     @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence")
882     protected com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
883     private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
884     private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
885     private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
886     private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
887     private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "orgLabor.organizationId = ?";
888     private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
889     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
890     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
891     private static Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
892 }