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