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.DynamicQuery;
23  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25  import com.liferay.portal.kernel.dao.orm.FinderPath;
26  import com.liferay.portal.kernel.dao.orm.Query;
27  import com.liferay.portal.kernel.dao.orm.QueryPos;
28  import com.liferay.portal.kernel.dao.orm.QueryUtil;
29  import com.liferay.portal.kernel.dao.orm.Session;
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     /**
208      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
209      */
210     public OrgLabor update(OrgLabor orgLabor) throws SystemException {
211         if (_log.isWarnEnabled()) {
212             _log.warn(
213                 "Using the deprecated update(OrgLabor orgLabor) method. Use update(OrgLabor orgLabor, boolean merge) instead.");
214         }
215 
216         return update(orgLabor, false);
217     }
218 
219     public OrgLabor updateImpl(com.liferay.portal.model.OrgLabor orgLabor,
220         boolean merge) throws SystemException {
221         orgLabor = toUnwrappedModel(orgLabor);
222 
223         Session session = null;
224 
225         try {
226             session = openSession();
227 
228             BatchSessionUtil.update(session, orgLabor, merge);
229 
230             orgLabor.setNew(false);
231         }
232         catch (Exception e) {
233             throw processException(e);
234         }
235         finally {
236             closeSession(session);
237         }
238 
239         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
240 
241         EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
242             OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
243 
244         return orgLabor;
245     }
246 
247     protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
248         if (orgLabor instanceof OrgLaborImpl) {
249             return orgLabor;
250         }
251 
252         OrgLaborImpl orgLaborImpl = new OrgLaborImpl();
253 
254         orgLaborImpl.setNew(orgLabor.isNew());
255         orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());
256 
257         orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
258         orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
259         orgLaborImpl.setTypeId(orgLabor.getTypeId());
260         orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
261         orgLaborImpl.setSunClose(orgLabor.getSunClose());
262         orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
263         orgLaborImpl.setMonClose(orgLabor.getMonClose());
264         orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
265         orgLaborImpl.setTueClose(orgLabor.getTueClose());
266         orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
267         orgLaborImpl.setWedClose(orgLabor.getWedClose());
268         orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
269         orgLaborImpl.setThuClose(orgLabor.getThuClose());
270         orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
271         orgLaborImpl.setFriClose(orgLabor.getFriClose());
272         orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
273         orgLaborImpl.setSatClose(orgLabor.getSatClose());
274 
275         return orgLaborImpl;
276     }
277 
278     public OrgLabor findByPrimaryKey(Serializable primaryKey)
279         throws NoSuchModelException, SystemException {
280         return findByPrimaryKey(((Long)primaryKey).longValue());
281     }
282 
283     public OrgLabor findByPrimaryKey(long orgLaborId)
284         throws NoSuchOrgLaborException, SystemException {
285         OrgLabor orgLabor = fetchByPrimaryKey(orgLaborId);
286 
287         if (orgLabor == null) {
288             if (_log.isWarnEnabled()) {
289                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
290             }
291 
292             throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
293                 orgLaborId);
294         }
295 
296         return orgLabor;
297     }
298 
299     public OrgLabor fetchByPrimaryKey(Serializable primaryKey)
300         throws SystemException {
301         return fetchByPrimaryKey(((Long)primaryKey).longValue());
302     }
303 
304     public OrgLabor fetchByPrimaryKey(long orgLaborId)
305         throws SystemException {
306         OrgLabor orgLabor = (OrgLabor)EntityCacheUtil.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
307                 OrgLaborImpl.class, orgLaborId, this);
308 
309         if (orgLabor == null) {
310             Session session = null;
311 
312             try {
313                 session = openSession();
314 
315                 orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
316                         new Long(orgLaborId));
317             }
318             catch (Exception e) {
319                 throw processException(e);
320             }
321             finally {
322                 if (orgLabor != null) {
323                     cacheResult(orgLabor);
324                 }
325 
326                 closeSession(session);
327             }
328         }
329 
330         return orgLabor;
331     }
332 
333     public List<OrgLabor> findByOrganizationId(long organizationId)
334         throws SystemException {
335         Object[] finderArgs = new Object[] { new Long(organizationId) };
336 
337         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
338                 finderArgs, this);
339 
340         if (list == null) {
341             Session session = null;
342 
343             try {
344                 session = openSession();
345 
346                 StringBundler query = new StringBundler(3);
347 
348                 query.append(_SQL_SELECT_ORGLABOR_WHERE);
349 
350                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
351 
352                 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
353 
354                 String sql = query.toString();
355 
356                 Query q = session.createQuery(sql);
357 
358                 QueryPos qPos = QueryPos.getInstance(q);
359 
360                 qPos.add(organizationId);
361 
362                 list = q.list();
363             }
364             catch (Exception e) {
365                 throw processException(e);
366             }
367             finally {
368                 if (list == null) {
369                     list = new ArrayList<OrgLabor>();
370                 }
371 
372                 cacheResult(list);
373 
374                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
375                     finderArgs, list);
376 
377                 closeSession(session);
378             }
379         }
380 
381         return list;
382     }
383 
384     public List<OrgLabor> findByOrganizationId(long organizationId, int start,
385         int end) throws SystemException {
386         return findByOrganizationId(organizationId, start, end, null);
387     }
388 
389     public List<OrgLabor> findByOrganizationId(long organizationId, int start,
390         int end, OrderByComparator obc) throws SystemException {
391         Object[] finderArgs = new Object[] {
392                 new Long(organizationId),
393                 
394                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
395             };
396 
397         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ORGANIZATIONID,
398                 finderArgs, this);
399 
400         if (list == null) {
401             Session session = null;
402 
403             try {
404                 session = openSession();
405 
406                 StringBundler query = null;
407 
408                 if (obc != null) {
409                     query = new StringBundler(3 +
410                             (obc.getOrderByFields().length * 3));
411                 }
412                 else {
413                     query = new StringBundler(3);
414                 }
415 
416                 query.append(_SQL_SELECT_ORGLABOR_WHERE);
417 
418                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
419 
420                 if (obc != null) {
421                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
422                 }
423 
424                 else {
425                     query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
426                 }
427 
428                 String sql = query.toString();
429 
430                 Query q = session.createQuery(sql);
431 
432                 QueryPos qPos = QueryPos.getInstance(q);
433 
434                 qPos.add(organizationId);
435 
436                 list = (List<OrgLabor>)QueryUtil.list(q, getDialect(), start,
437                         end);
438             }
439             catch (Exception e) {
440                 throw processException(e);
441             }
442             finally {
443                 if (list == null) {
444                     list = new ArrayList<OrgLabor>();
445                 }
446 
447                 cacheResult(list);
448 
449                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ORGANIZATIONID,
450                     finderArgs, list);
451 
452                 closeSession(session);
453             }
454         }
455 
456         return list;
457     }
458 
459     public OrgLabor findByOrganizationId_First(long organizationId,
460         OrderByComparator obc) throws NoSuchOrgLaborException, SystemException {
461         List<OrgLabor> list = findByOrganizationId(organizationId, 0, 1, obc);
462 
463         if (list.isEmpty()) {
464             StringBundler msg = new StringBundler(4);
465 
466             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
467 
468             msg.append("organizationId=");
469             msg.append(organizationId);
470 
471             msg.append(StringPool.CLOSE_CURLY_BRACE);
472 
473             throw new NoSuchOrgLaborException(msg.toString());
474         }
475         else {
476             return list.get(0);
477         }
478     }
479 
480     public OrgLabor findByOrganizationId_Last(long organizationId,
481         OrderByComparator obc) throws NoSuchOrgLaborException, SystemException {
482         int count = countByOrganizationId(organizationId);
483 
484         List<OrgLabor> list = findByOrganizationId(organizationId, count - 1,
485                 count, obc);
486 
487         if (list.isEmpty()) {
488             StringBundler msg = new StringBundler(4);
489 
490             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
491 
492             msg.append("organizationId=");
493             msg.append(organizationId);
494 
495             msg.append(StringPool.CLOSE_CURLY_BRACE);
496 
497             throw new NoSuchOrgLaborException(msg.toString());
498         }
499         else {
500             return list.get(0);
501         }
502     }
503 
504     public OrgLabor[] findByOrganizationId_PrevAndNext(long orgLaborId,
505         long organizationId, OrderByComparator obc)
506         throws NoSuchOrgLaborException, SystemException {
507         OrgLabor orgLabor = findByPrimaryKey(orgLaborId);
508 
509         int count = countByOrganizationId(organizationId);
510 
511         Session session = null;
512 
513         try {
514             session = openSession();
515 
516             StringBundler query = null;
517 
518             if (obc != null) {
519                 query = new StringBundler(3 +
520                         (obc.getOrderByFields().length * 3));
521             }
522             else {
523                 query = new StringBundler(3);
524             }
525 
526             query.append(_SQL_SELECT_ORGLABOR_WHERE);
527 
528             query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
529 
530             if (obc != null) {
531                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
532             }
533 
534             else {
535                 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
536             }
537 
538             String sql = query.toString();
539 
540             Query q = session.createQuery(sql);
541 
542             QueryPos qPos = QueryPos.getInstance(q);
543 
544             qPos.add(organizationId);
545 
546             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, orgLabor);
547 
548             OrgLabor[] array = new OrgLaborImpl[3];
549 
550             array[0] = (OrgLabor)objArray[0];
551             array[1] = (OrgLabor)objArray[1];
552             array[2] = (OrgLabor)objArray[2];
553 
554             return array;
555         }
556         catch (Exception e) {
557             throw processException(e);
558         }
559         finally {
560             closeSession(session);
561         }
562     }
563 
564     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
565         throws SystemException {
566         Session session = null;
567 
568         try {
569             session = openSession();
570 
571             dynamicQuery.compile(session);
572 
573             return dynamicQuery.list();
574         }
575         catch (Exception e) {
576             throw processException(e);
577         }
578         finally {
579             closeSession(session);
580         }
581     }
582 
583     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
584         int start, int end) throws SystemException {
585         Session session = null;
586 
587         try {
588             session = openSession();
589 
590             dynamicQuery.setLimit(start, end);
591 
592             dynamicQuery.compile(session);
593 
594             return dynamicQuery.list();
595         }
596         catch (Exception e) {
597             throw processException(e);
598         }
599         finally {
600             closeSession(session);
601         }
602     }
603 
604     public List<OrgLabor> findAll() throws SystemException {
605         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
606     }
607 
608     public List<OrgLabor> findAll(int start, int end) throws SystemException {
609         return findAll(start, end, null);
610     }
611 
612     public List<OrgLabor> findAll(int start, int end, OrderByComparator obc)
613         throws SystemException {
614         Object[] finderArgs = new Object[] {
615                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
616             };
617 
618         List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
619                 finderArgs, this);
620 
621         if (list == null) {
622             Session session = null;
623 
624             try {
625                 session = openSession();
626 
627                 StringBundler query = null;
628                 String sql = null;
629 
630                 if (obc != null) {
631                     query = new StringBundler(2 +
632                             (obc.getOrderByFields().length * 3));
633 
634                     query.append(_SQL_SELECT_ORGLABOR);
635 
636                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
637 
638                     sql = query.toString();
639                 }
640 
641                 else {
642                     sql = _SQL_SELECT_ORGLABOR.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
643                 }
644 
645                 Query q = session.createQuery(sql);
646 
647                 if (obc == null) {
648                     list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
649                             start, end, false);
650 
651                     Collections.sort(list);
652                 }
653                 else {
654                     list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
655                             start, end);
656                 }
657             }
658             catch (Exception e) {
659                 throw processException(e);
660             }
661             finally {
662                 if (list == null) {
663                     list = new ArrayList<OrgLabor>();
664                 }
665 
666                 cacheResult(list);
667 
668                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
669 
670                 closeSession(session);
671             }
672         }
673 
674         return list;
675     }
676 
677     public void removeByOrganizationId(long organizationId)
678         throws SystemException {
679         for (OrgLabor orgLabor : findByOrganizationId(organizationId)) {
680             remove(orgLabor);
681         }
682     }
683 
684     public void removeAll() throws SystemException {
685         for (OrgLabor orgLabor : findAll()) {
686             remove(orgLabor);
687         }
688     }
689 
690     public int countByOrganizationId(long organizationId)
691         throws SystemException {
692         Object[] finderArgs = new Object[] { new Long(organizationId) };
693 
694         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
695                 finderArgs, this);
696 
697         if (count == null) {
698             Session session = null;
699 
700             try {
701                 session = openSession();
702 
703                 StringBundler query = new StringBundler(2);
704 
705                 query.append(_SQL_COUNT_ORGLABOR_WHERE);
706 
707                 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
708 
709                 String sql = query.toString();
710 
711                 Query q = session.createQuery(sql);
712 
713                 QueryPos qPos = QueryPos.getInstance(q);
714 
715                 qPos.add(organizationId);
716 
717                 count = (Long)q.uniqueResult();
718             }
719             catch (Exception e) {
720                 throw processException(e);
721             }
722             finally {
723                 if (count == null) {
724                     count = Long.valueOf(0);
725                 }
726 
727                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
728                     finderArgs, count);
729 
730                 closeSession(session);
731             }
732         }
733 
734         return count.intValue();
735     }
736 
737     public int countAll() throws SystemException {
738         Object[] finderArgs = new Object[0];
739 
740         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
741                 finderArgs, this);
742 
743         if (count == null) {
744             Session session = null;
745 
746             try {
747                 session = openSession();
748 
749                 Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
750 
751                 count = (Long)q.uniqueResult();
752             }
753             catch (Exception e) {
754                 throw processException(e);
755             }
756             finally {
757                 if (count == null) {
758                     count = Long.valueOf(0);
759                 }
760 
761                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
762                     count);
763 
764                 closeSession(session);
765             }
766         }
767 
768         return count.intValue();
769     }
770 
771     public void afterPropertiesSet() {
772         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
773                     com.liferay.portal.util.PropsUtil.get(
774                         "value.object.listener.com.liferay.portal.model.OrgLabor")));
775 
776         if (listenerClassNames.length > 0) {
777             try {
778                 List<ModelListener<OrgLabor>> listenersList = new ArrayList<ModelListener<OrgLabor>>();
779 
780                 for (String listenerClassName : listenerClassNames) {
781                     listenersList.add((ModelListener<OrgLabor>)Class.forName(
782                             listenerClassName).newInstance());
783                 }
784 
785                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
786             }
787             catch (Exception e) {
788                 _log.error(e);
789             }
790         }
791     }
792 
793     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
794     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
795     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
796     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
797     @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
798     protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
799     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
800     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
801     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
802     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
803     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
804     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
805     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
806     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
807     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
808     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
809     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
810     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
811     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
812     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
813     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
814     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
815     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
816     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
817     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
818     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
819     @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
820     protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
821     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
822     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
823     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
824     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
825     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
826     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
827     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
828     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
829     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
830     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
831     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
832     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
833     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
834     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
835     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
836     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
837     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
838     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
839     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
840     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
841     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
842     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
843     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
844     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
845     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
846     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
847     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
848     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
849     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
850     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
851     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
852     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
853     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
854     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
855     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
856     protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
857     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
858     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
859     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
860     protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
861     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
862     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
863     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
864     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
865     @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
866     protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
867     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
868     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
869     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
870     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
871     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
872     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
873     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
874     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
875     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
876     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
877     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
878     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
879     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
880     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
881     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
882     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
883     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
884     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
885     private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
886     private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
887     private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
888     private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
889     private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "orgLabor.organizationId = ?";
890     private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
891     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
892     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
893     private static Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
894 }