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