001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchOrgLaborException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.OrgLabor;
040 import com.liferay.portal.model.impl.OrgLaborImpl;
041 import com.liferay.portal.model.impl.OrgLaborModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class OrgLaborPersistenceImpl extends BasePersistenceImpl<OrgLabor>
063 implements OrgLaborPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = OrgLaborImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONID =
075 new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
076 OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByOrganizationId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID =
085 new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
086 OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByOrganizationId",
088 new String[] { Long.class.getName() },
089 OrgLaborModelImpl.ORGANIZATIONID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
091 OrgLaborModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByOrganizationId",
093 new String[] { Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
095 OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
098 OrgLaborModelImpl.FINDER_CACHE_ENABLED, OrgLaborImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
100 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
101 OrgLaborModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
103
104
109 public void cacheResult(OrgLabor orgLabor) {
110 EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
111 OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
112
113 orgLabor.resetOriginalValues();
114 }
115
116
121 public void cacheResult(List<OrgLabor> orgLabors) {
122 for (OrgLabor orgLabor : orgLabors) {
123 if (EntityCacheUtil.getResult(
124 OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
125 OrgLaborImpl.class, orgLabor.getPrimaryKey()) == null) {
126 cacheResult(orgLabor);
127 }
128 else {
129 orgLabor.resetOriginalValues();
130 }
131 }
132 }
133
134
141 @Override
142 public void clearCache() {
143 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
144 CacheRegistryUtil.clear(OrgLaborImpl.class.getName());
145 }
146
147 EntityCacheUtil.clearCache(OrgLaborImpl.class.getName());
148
149 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
150 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
151 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
152 }
153
154
161 @Override
162 public void clearCache(OrgLabor orgLabor) {
163 EntityCacheUtil.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
164 OrgLaborImpl.class, orgLabor.getPrimaryKey());
165
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
168 }
169
170 @Override
171 public void clearCache(List<OrgLabor> orgLabors) {
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
174
175 for (OrgLabor orgLabor : orgLabors) {
176 EntityCacheUtil.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
177 OrgLaborImpl.class, orgLabor.getPrimaryKey());
178 }
179 }
180
181
187 public OrgLabor create(long orgLaborId) {
188 OrgLabor orgLabor = new OrgLaborImpl();
189
190 orgLabor.setNew(true);
191 orgLabor.setPrimaryKey(orgLaborId);
192
193 return orgLabor;
194 }
195
196
204 public OrgLabor remove(long orgLaborId)
205 throws NoSuchOrgLaborException, SystemException {
206 return remove(Long.valueOf(orgLaborId));
207 }
208
209
217 @Override
218 public OrgLabor remove(Serializable primaryKey)
219 throws NoSuchOrgLaborException, SystemException {
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 OrgLabor orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
226 primaryKey);
227
228 if (orgLabor == null) {
229 if (_log.isWarnEnabled()) {
230 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
231 }
232
233 throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
234 primaryKey);
235 }
236
237 return remove(orgLabor);
238 }
239 catch (NoSuchOrgLaborException nsee) {
240 throw nsee;
241 }
242 catch (Exception e) {
243 throw processException(e);
244 }
245 finally {
246 closeSession(session);
247 }
248 }
249
250 @Override
251 protected OrgLabor removeImpl(OrgLabor orgLabor) throws SystemException {
252 orgLabor = toUnwrappedModel(orgLabor);
253
254 Session session = null;
255
256 try {
257 session = openSession();
258
259 BatchSessionUtil.delete(session, orgLabor);
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267
268 clearCache(orgLabor);
269
270 return orgLabor;
271 }
272
273 @Override
274 public OrgLabor updateImpl(com.liferay.portal.model.OrgLabor orgLabor,
275 boolean merge) throws SystemException {
276 orgLabor = toUnwrappedModel(orgLabor);
277
278 boolean isNew = orgLabor.isNew();
279
280 OrgLaborModelImpl orgLaborModelImpl = (OrgLaborModelImpl)orgLabor;
281
282 Session session = null;
283
284 try {
285 session = openSession();
286
287 BatchSessionUtil.update(session, orgLabor, merge);
288
289 orgLabor.setNew(false);
290 }
291 catch (Exception e) {
292 throw processException(e);
293 }
294 finally {
295 closeSession(session);
296 }
297
298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
299
300 if (isNew || !OrgLaborModelImpl.COLUMN_BITMASK_ENABLED) {
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
302 }
303
304 else {
305 if ((orgLaborModelImpl.getColumnBitmask() &
306 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID.getColumnBitmask()) != 0) {
307 Object[] args = new Object[] {
308 Long.valueOf(orgLaborModelImpl.getOriginalOrganizationId())
309 };
310
311 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
312 args);
313 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID,
314 args);
315
316 args = new Object[] {
317 Long.valueOf(orgLaborModelImpl.getOrganizationId())
318 };
319
320 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
321 args);
322 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID,
323 args);
324 }
325 }
326
327 EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
328 OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
329
330 return orgLabor;
331 }
332
333 protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
334 if (orgLabor instanceof OrgLaborImpl) {
335 return orgLabor;
336 }
337
338 OrgLaborImpl orgLaborImpl = new OrgLaborImpl();
339
340 orgLaborImpl.setNew(orgLabor.isNew());
341 orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());
342
343 orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
344 orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
345 orgLaborImpl.setTypeId(orgLabor.getTypeId());
346 orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
347 orgLaborImpl.setSunClose(orgLabor.getSunClose());
348 orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
349 orgLaborImpl.setMonClose(orgLabor.getMonClose());
350 orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
351 orgLaborImpl.setTueClose(orgLabor.getTueClose());
352 orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
353 orgLaborImpl.setWedClose(orgLabor.getWedClose());
354 orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
355 orgLaborImpl.setThuClose(orgLabor.getThuClose());
356 orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
357 orgLaborImpl.setFriClose(orgLabor.getFriClose());
358 orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
359 orgLaborImpl.setSatClose(orgLabor.getSatClose());
360
361 return orgLaborImpl;
362 }
363
364
372 @Override
373 public OrgLabor findByPrimaryKey(Serializable primaryKey)
374 throws NoSuchModelException, SystemException {
375 return findByPrimaryKey(((Long)primaryKey).longValue());
376 }
377
378
386 public OrgLabor findByPrimaryKey(long orgLaborId)
387 throws NoSuchOrgLaborException, SystemException {
388 OrgLabor orgLabor = fetchByPrimaryKey(orgLaborId);
389
390 if (orgLabor == null) {
391 if (_log.isWarnEnabled()) {
392 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
393 }
394
395 throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
396 orgLaborId);
397 }
398
399 return orgLabor;
400 }
401
402
409 @Override
410 public OrgLabor fetchByPrimaryKey(Serializable primaryKey)
411 throws SystemException {
412 return fetchByPrimaryKey(((Long)primaryKey).longValue());
413 }
414
415
422 public OrgLabor fetchByPrimaryKey(long orgLaborId)
423 throws SystemException {
424 OrgLabor orgLabor = (OrgLabor)EntityCacheUtil.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
425 OrgLaborImpl.class, orgLaborId);
426
427 if (orgLabor == _nullOrgLabor) {
428 return null;
429 }
430
431 if (orgLabor == null) {
432 Session session = null;
433
434 boolean hasException = false;
435
436 try {
437 session = openSession();
438
439 orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
440 Long.valueOf(orgLaborId));
441 }
442 catch (Exception e) {
443 hasException = true;
444
445 throw processException(e);
446 }
447 finally {
448 if (orgLabor != null) {
449 cacheResult(orgLabor);
450 }
451 else if (!hasException) {
452 EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
453 OrgLaborImpl.class, orgLaborId, _nullOrgLabor);
454 }
455
456 closeSession(session);
457 }
458 }
459
460 return orgLabor;
461 }
462
463
470 public List<OrgLabor> findByOrganizationId(long organizationId)
471 throws SystemException {
472 return findByOrganizationId(organizationId, QueryUtil.ALL_POS,
473 QueryUtil.ALL_POS, null);
474 }
475
476
489 public List<OrgLabor> findByOrganizationId(long organizationId, int start,
490 int end) throws SystemException {
491 return findByOrganizationId(organizationId, start, end, null);
492 }
493
494
508 public List<OrgLabor> findByOrganizationId(long organizationId, int start,
509 int end, OrderByComparator orderByComparator) throws SystemException {
510 FinderPath finderPath = null;
511 Object[] finderArgs = null;
512
513 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
514 (orderByComparator == null)) {
515 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID;
516 finderArgs = new Object[] { organizationId };
517 }
518 else {
519 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONID;
520 finderArgs = new Object[] {
521 organizationId,
522
523 start, end, orderByComparator
524 };
525 }
526
527 List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(finderPath,
528 finderArgs, this);
529
530 if (list == null) {
531 StringBundler query = null;
532
533 if (orderByComparator != null) {
534 query = new StringBundler(3 +
535 (orderByComparator.getOrderByFields().length * 3));
536 }
537 else {
538 query = new StringBundler(3);
539 }
540
541 query.append(_SQL_SELECT_ORGLABOR_WHERE);
542
543 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
544
545 if (orderByComparator != null) {
546 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
547 orderByComparator);
548 }
549
550 else {
551 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
552 }
553
554 String sql = query.toString();
555
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 Query q = session.createQuery(sql);
562
563 QueryPos qPos = QueryPos.getInstance(q);
564
565 qPos.add(organizationId);
566
567 list = (List<OrgLabor>)QueryUtil.list(q, getDialect(), start,
568 end);
569 }
570 catch (Exception e) {
571 throw processException(e);
572 }
573 finally {
574 if (list == null) {
575 FinderCacheUtil.removeResult(finderPath, finderArgs);
576 }
577 else {
578 cacheResult(list);
579
580 FinderCacheUtil.putResult(finderPath, finderArgs, list);
581 }
582
583 closeSession(session);
584 }
585 }
586
587 return list;
588 }
589
590
603 public OrgLabor findByOrganizationId_First(long organizationId,
604 OrderByComparator orderByComparator)
605 throws NoSuchOrgLaborException, SystemException {
606 List<OrgLabor> list = findByOrganizationId(organizationId, 0, 1,
607 orderByComparator);
608
609 if (list.isEmpty()) {
610 StringBundler msg = new StringBundler(4);
611
612 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
613
614 msg.append("organizationId=");
615 msg.append(organizationId);
616
617 msg.append(StringPool.CLOSE_CURLY_BRACE);
618
619 throw new NoSuchOrgLaborException(msg.toString());
620 }
621 else {
622 return list.get(0);
623 }
624 }
625
626
639 public OrgLabor findByOrganizationId_Last(long organizationId,
640 OrderByComparator orderByComparator)
641 throws NoSuchOrgLaborException, SystemException {
642 int count = countByOrganizationId(organizationId);
643
644 List<OrgLabor> list = findByOrganizationId(organizationId, count - 1,
645 count, orderByComparator);
646
647 if (list.isEmpty()) {
648 StringBundler msg = new StringBundler(4);
649
650 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
651
652 msg.append("organizationId=");
653 msg.append(organizationId);
654
655 msg.append(StringPool.CLOSE_CURLY_BRACE);
656
657 throw new NoSuchOrgLaborException(msg.toString());
658 }
659 else {
660 return list.get(0);
661 }
662 }
663
664
678 public OrgLabor[] findByOrganizationId_PrevAndNext(long orgLaborId,
679 long organizationId, OrderByComparator orderByComparator)
680 throws NoSuchOrgLaborException, SystemException {
681 OrgLabor orgLabor = findByPrimaryKey(orgLaborId);
682
683 Session session = null;
684
685 try {
686 session = openSession();
687
688 OrgLabor[] array = new OrgLaborImpl[3];
689
690 array[0] = getByOrganizationId_PrevAndNext(session, orgLabor,
691 organizationId, orderByComparator, true);
692
693 array[1] = orgLabor;
694
695 array[2] = getByOrganizationId_PrevAndNext(session, orgLabor,
696 organizationId, orderByComparator, false);
697
698 return array;
699 }
700 catch (Exception e) {
701 throw processException(e);
702 }
703 finally {
704 closeSession(session);
705 }
706 }
707
708 protected OrgLabor getByOrganizationId_PrevAndNext(Session session,
709 OrgLabor orgLabor, long organizationId,
710 OrderByComparator orderByComparator, boolean previous) {
711 StringBundler query = null;
712
713 if (orderByComparator != null) {
714 query = new StringBundler(6 +
715 (orderByComparator.getOrderByFields().length * 6));
716 }
717 else {
718 query = new StringBundler(3);
719 }
720
721 query.append(_SQL_SELECT_ORGLABOR_WHERE);
722
723 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
724
725 if (orderByComparator != null) {
726 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
727
728 if (orderByConditionFields.length > 0) {
729 query.append(WHERE_AND);
730 }
731
732 for (int i = 0; i < orderByConditionFields.length; i++) {
733 query.append(_ORDER_BY_ENTITY_ALIAS);
734 query.append(orderByConditionFields[i]);
735
736 if ((i + 1) < orderByConditionFields.length) {
737 if (orderByComparator.isAscending() ^ previous) {
738 query.append(WHERE_GREATER_THAN_HAS_NEXT);
739 }
740 else {
741 query.append(WHERE_LESSER_THAN_HAS_NEXT);
742 }
743 }
744 else {
745 if (orderByComparator.isAscending() ^ previous) {
746 query.append(WHERE_GREATER_THAN);
747 }
748 else {
749 query.append(WHERE_LESSER_THAN);
750 }
751 }
752 }
753
754 query.append(ORDER_BY_CLAUSE);
755
756 String[] orderByFields = orderByComparator.getOrderByFields();
757
758 for (int i = 0; i < orderByFields.length; i++) {
759 query.append(_ORDER_BY_ENTITY_ALIAS);
760 query.append(orderByFields[i]);
761
762 if ((i + 1) < orderByFields.length) {
763 if (orderByComparator.isAscending() ^ previous) {
764 query.append(ORDER_BY_ASC_HAS_NEXT);
765 }
766 else {
767 query.append(ORDER_BY_DESC_HAS_NEXT);
768 }
769 }
770 else {
771 if (orderByComparator.isAscending() ^ previous) {
772 query.append(ORDER_BY_ASC);
773 }
774 else {
775 query.append(ORDER_BY_DESC);
776 }
777 }
778 }
779 }
780
781 else {
782 query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
783 }
784
785 String sql = query.toString();
786
787 Query q = session.createQuery(sql);
788
789 q.setFirstResult(0);
790 q.setMaxResults(2);
791
792 QueryPos qPos = QueryPos.getInstance(q);
793
794 qPos.add(organizationId);
795
796 if (orderByComparator != null) {
797 Object[] values = orderByComparator.getOrderByConditionValues(orgLabor);
798
799 for (Object value : values) {
800 qPos.add(value);
801 }
802 }
803
804 List<OrgLabor> list = q.list();
805
806 if (list.size() == 2) {
807 return list.get(1);
808 }
809 else {
810 return null;
811 }
812 }
813
814
820 public List<OrgLabor> findAll() throws SystemException {
821 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
822 }
823
824
836 public List<OrgLabor> findAll(int start, int end) throws SystemException {
837 return findAll(start, end, null);
838 }
839
840
853 public List<OrgLabor> findAll(int start, int end,
854 OrderByComparator orderByComparator) throws SystemException {
855 FinderPath finderPath = null;
856 Object[] finderArgs = new Object[] { start, end, orderByComparator };
857
858 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
859 (orderByComparator == null)) {
860 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
861 finderArgs = FINDER_ARGS_EMPTY;
862 }
863 else {
864 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
865 finderArgs = new Object[] { start, end, orderByComparator };
866 }
867
868 List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(finderPath,
869 finderArgs, this);
870
871 if (list == null) {
872 StringBundler query = null;
873 String sql = null;
874
875 if (orderByComparator != null) {
876 query = new StringBundler(2 +
877 (orderByComparator.getOrderByFields().length * 3));
878
879 query.append(_SQL_SELECT_ORGLABOR);
880
881 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
882 orderByComparator);
883
884 sql = query.toString();
885 }
886 else {
887 sql = _SQL_SELECT_ORGLABOR.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
888 }
889
890 Session session = null;
891
892 try {
893 session = openSession();
894
895 Query q = session.createQuery(sql);
896
897 if (orderByComparator == null) {
898 list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
899 start, end, false);
900
901 Collections.sort(list);
902 }
903 else {
904 list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
905 start, end);
906 }
907 }
908 catch (Exception e) {
909 throw processException(e);
910 }
911 finally {
912 if (list == null) {
913 FinderCacheUtil.removeResult(finderPath, finderArgs);
914 }
915 else {
916 cacheResult(list);
917
918 FinderCacheUtil.putResult(finderPath, finderArgs, list);
919 }
920
921 closeSession(session);
922 }
923 }
924
925 return list;
926 }
927
928
934 public void removeByOrganizationId(long organizationId)
935 throws SystemException {
936 for (OrgLabor orgLabor : findByOrganizationId(organizationId)) {
937 remove(orgLabor);
938 }
939 }
940
941
946 public void removeAll() throws SystemException {
947 for (OrgLabor orgLabor : findAll()) {
948 remove(orgLabor);
949 }
950 }
951
952
959 public int countByOrganizationId(long organizationId)
960 throws SystemException {
961 Object[] finderArgs = new Object[] { organizationId };
962
963 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
964 finderArgs, this);
965
966 if (count == null) {
967 StringBundler query = new StringBundler(2);
968
969 query.append(_SQL_COUNT_ORGLABOR_WHERE);
970
971 query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
972
973 String sql = query.toString();
974
975 Session session = null;
976
977 try {
978 session = openSession();
979
980 Query q = session.createQuery(sql);
981
982 QueryPos qPos = QueryPos.getInstance(q);
983
984 qPos.add(organizationId);
985
986 count = (Long)q.uniqueResult();
987 }
988 catch (Exception e) {
989 throw processException(e);
990 }
991 finally {
992 if (count == null) {
993 count = Long.valueOf(0);
994 }
995
996 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
997 finderArgs, count);
998
999 closeSession(session);
1000 }
1001 }
1002
1003 return count.intValue();
1004 }
1005
1006
1012 public int countAll() throws SystemException {
1013 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1014 FINDER_ARGS_EMPTY, this);
1015
1016 if (count == null) {
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
1023
1024 count = (Long)q.uniqueResult();
1025 }
1026 catch (Exception e) {
1027 throw processException(e);
1028 }
1029 finally {
1030 if (count == null) {
1031 count = Long.valueOf(0);
1032 }
1033
1034 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1035 FINDER_ARGS_EMPTY, count);
1036
1037 closeSession(session);
1038 }
1039 }
1040
1041 return count.intValue();
1042 }
1043
1044
1047 public void afterPropertiesSet() {
1048 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1049 com.liferay.portal.util.PropsUtil.get(
1050 "value.object.listener.com.liferay.portal.model.OrgLabor")));
1051
1052 if (listenerClassNames.length > 0) {
1053 try {
1054 List<ModelListener<OrgLabor>> listenersList = new ArrayList<ModelListener<OrgLabor>>();
1055
1056 for (String listenerClassName : listenerClassNames) {
1057 listenersList.add((ModelListener<OrgLabor>)InstanceFactory.newInstance(
1058 listenerClassName));
1059 }
1060
1061 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1062 }
1063 catch (Exception e) {
1064 _log.error(e);
1065 }
1066 }
1067 }
1068
1069 public void destroy() {
1070 EntityCacheUtil.removeCache(OrgLaborImpl.class.getName());
1071 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1072 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1073 }
1074
1075 @BeanReference(type = AccountPersistence.class)
1076 protected AccountPersistence accountPersistence;
1077 @BeanReference(type = AddressPersistence.class)
1078 protected AddressPersistence addressPersistence;
1079 @BeanReference(type = BrowserTrackerPersistence.class)
1080 protected BrowserTrackerPersistence browserTrackerPersistence;
1081 @BeanReference(type = ClassNamePersistence.class)
1082 protected ClassNamePersistence classNamePersistence;
1083 @BeanReference(type = ClusterGroupPersistence.class)
1084 protected ClusterGroupPersistence clusterGroupPersistence;
1085 @BeanReference(type = CompanyPersistence.class)
1086 protected CompanyPersistence companyPersistence;
1087 @BeanReference(type = ContactPersistence.class)
1088 protected ContactPersistence contactPersistence;
1089 @BeanReference(type = CountryPersistence.class)
1090 protected CountryPersistence countryPersistence;
1091 @BeanReference(type = EmailAddressPersistence.class)
1092 protected EmailAddressPersistence emailAddressPersistence;
1093 @BeanReference(type = GroupPersistence.class)
1094 protected GroupPersistence groupPersistence;
1095 @BeanReference(type = ImagePersistence.class)
1096 protected ImagePersistence imagePersistence;
1097 @BeanReference(type = LayoutPersistence.class)
1098 protected LayoutPersistence layoutPersistence;
1099 @BeanReference(type = LayoutBranchPersistence.class)
1100 protected LayoutBranchPersistence layoutBranchPersistence;
1101 @BeanReference(type = LayoutPrototypePersistence.class)
1102 protected LayoutPrototypePersistence layoutPrototypePersistence;
1103 @BeanReference(type = LayoutRevisionPersistence.class)
1104 protected LayoutRevisionPersistence layoutRevisionPersistence;
1105 @BeanReference(type = LayoutSetPersistence.class)
1106 protected LayoutSetPersistence layoutSetPersistence;
1107 @BeanReference(type = LayoutSetBranchPersistence.class)
1108 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1109 @BeanReference(type = LayoutSetPrototypePersistence.class)
1110 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1111 @BeanReference(type = ListTypePersistence.class)
1112 protected ListTypePersistence listTypePersistence;
1113 @BeanReference(type = LockPersistence.class)
1114 protected LockPersistence lockPersistence;
1115 @BeanReference(type = MembershipRequestPersistence.class)
1116 protected MembershipRequestPersistence membershipRequestPersistence;
1117 @BeanReference(type = OrganizationPersistence.class)
1118 protected OrganizationPersistence organizationPersistence;
1119 @BeanReference(type = OrgGroupPermissionPersistence.class)
1120 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1121 @BeanReference(type = OrgGroupRolePersistence.class)
1122 protected OrgGroupRolePersistence orgGroupRolePersistence;
1123 @BeanReference(type = OrgLaborPersistence.class)
1124 protected OrgLaborPersistence orgLaborPersistence;
1125 @BeanReference(type = PasswordPolicyPersistence.class)
1126 protected PasswordPolicyPersistence passwordPolicyPersistence;
1127 @BeanReference(type = PasswordPolicyRelPersistence.class)
1128 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1129 @BeanReference(type = PasswordTrackerPersistence.class)
1130 protected PasswordTrackerPersistence passwordTrackerPersistence;
1131 @BeanReference(type = PermissionPersistence.class)
1132 protected PermissionPersistence permissionPersistence;
1133 @BeanReference(type = PhonePersistence.class)
1134 protected PhonePersistence phonePersistence;
1135 @BeanReference(type = PluginSettingPersistence.class)
1136 protected PluginSettingPersistence pluginSettingPersistence;
1137 @BeanReference(type = PortalPreferencesPersistence.class)
1138 protected PortalPreferencesPersistence portalPreferencesPersistence;
1139 @BeanReference(type = PortletPersistence.class)
1140 protected PortletPersistence portletPersistence;
1141 @BeanReference(type = PortletItemPersistence.class)
1142 protected PortletItemPersistence portletItemPersistence;
1143 @BeanReference(type = PortletPreferencesPersistence.class)
1144 protected PortletPreferencesPersistence portletPreferencesPersistence;
1145 @BeanReference(type = RegionPersistence.class)
1146 protected RegionPersistence regionPersistence;
1147 @BeanReference(type = ReleasePersistence.class)
1148 protected ReleasePersistence releasePersistence;
1149 @BeanReference(type = RepositoryPersistence.class)
1150 protected RepositoryPersistence repositoryPersistence;
1151 @BeanReference(type = RepositoryEntryPersistence.class)
1152 protected RepositoryEntryPersistence repositoryEntryPersistence;
1153 @BeanReference(type = ResourcePersistence.class)
1154 protected ResourcePersistence resourcePersistence;
1155 @BeanReference(type = ResourceActionPersistence.class)
1156 protected ResourceActionPersistence resourceActionPersistence;
1157 @BeanReference(type = ResourceBlockPersistence.class)
1158 protected ResourceBlockPersistence resourceBlockPersistence;
1159 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1160 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1161 @BeanReference(type = ResourceCodePersistence.class)
1162 protected ResourceCodePersistence resourceCodePersistence;
1163 @BeanReference(type = ResourcePermissionPersistence.class)
1164 protected ResourcePermissionPersistence resourcePermissionPersistence;
1165 @BeanReference(type = ResourceTypePermissionPersistence.class)
1166 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1167 @BeanReference(type = RolePersistence.class)
1168 protected RolePersistence rolePersistence;
1169 @BeanReference(type = ServiceComponentPersistence.class)
1170 protected ServiceComponentPersistence serviceComponentPersistence;
1171 @BeanReference(type = ShardPersistence.class)
1172 protected ShardPersistence shardPersistence;
1173 @BeanReference(type = SubscriptionPersistence.class)
1174 protected SubscriptionPersistence subscriptionPersistence;
1175 @BeanReference(type = TeamPersistence.class)
1176 protected TeamPersistence teamPersistence;
1177 @BeanReference(type = TicketPersistence.class)
1178 protected TicketPersistence ticketPersistence;
1179 @BeanReference(type = UserPersistence.class)
1180 protected UserPersistence userPersistence;
1181 @BeanReference(type = UserGroupPersistence.class)
1182 protected UserGroupPersistence userGroupPersistence;
1183 @BeanReference(type = UserGroupGroupRolePersistence.class)
1184 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1185 @BeanReference(type = UserGroupRolePersistence.class)
1186 protected UserGroupRolePersistence userGroupRolePersistence;
1187 @BeanReference(type = UserIdMapperPersistence.class)
1188 protected UserIdMapperPersistence userIdMapperPersistence;
1189 @BeanReference(type = UserNotificationEventPersistence.class)
1190 protected UserNotificationEventPersistence userNotificationEventPersistence;
1191 @BeanReference(type = UserTrackerPersistence.class)
1192 protected UserTrackerPersistence userTrackerPersistence;
1193 @BeanReference(type = UserTrackerPathPersistence.class)
1194 protected UserTrackerPathPersistence userTrackerPathPersistence;
1195 @BeanReference(type = VirtualHostPersistence.class)
1196 protected VirtualHostPersistence virtualHostPersistence;
1197 @BeanReference(type = WebDAVPropsPersistence.class)
1198 protected WebDAVPropsPersistence webDAVPropsPersistence;
1199 @BeanReference(type = WebsitePersistence.class)
1200 protected WebsitePersistence websitePersistence;
1201 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1202 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1203 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1204 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1205 private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
1206 private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
1207 private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
1208 private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
1209 private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "orgLabor.organizationId = ?";
1210 private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
1211 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
1212 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
1213 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1214 private static Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
1215 private static OrgLabor _nullOrgLabor = new OrgLaborImpl() {
1216 @Override
1217 public Object clone() {
1218 return this;
1219 }
1220
1221 @Override
1222 public CacheModel<OrgLabor> toCacheModel() {
1223 return _nullOrgLaborCacheModel;
1224 }
1225 };
1226
1227 private static CacheModel<OrgLabor> _nullOrgLaborCacheModel = new CacheModel<OrgLabor>() {
1228 public OrgLabor toEntityModel() {
1229 return _nullOrgLabor;
1230 }
1231 };
1232 }