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