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