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