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