1
22
23 package com.liferay.portlet.expando.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.GetterUtil;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.kernel.util.StringUtil;
33 import com.liferay.portal.model.ModelListener;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37 import com.liferay.portal.util.PropsUtil;
38
39 import com.liferay.portlet.expando.NoSuchValueException;
40 import com.liferay.portlet.expando.model.ExpandoValue;
41 import com.liferay.portlet.expando.model.impl.ExpandoValueImpl;
42 import com.liferay.portlet.expando.model.impl.ExpandoValueModelImpl;
43
44 import com.liferay.util.dao.hibernate.QueryUtil;
45
46 import org.apache.commons.logging.Log;
47 import org.apache.commons.logging.LogFactory;
48
49 import org.hibernate.Query;
50 import org.hibernate.Session;
51
52 import java.util.ArrayList;
53 import java.util.Collections;
54 import java.util.Iterator;
55 import java.util.List;
56
57
63 public class ExpandoValuePersistenceImpl extends BasePersistence
64 implements ExpandoValuePersistence {
65 public ExpandoValue create(long valueId) {
66 ExpandoValue expandoValue = new ExpandoValueImpl();
67
68 expandoValue.setNew(true);
69 expandoValue.setPrimaryKey(valueId);
70
71 return expandoValue;
72 }
73
74 public ExpandoValue remove(long valueId)
75 throws NoSuchValueException, SystemException {
76 Session session = null;
77
78 try {
79 session = openSession();
80
81 ExpandoValue expandoValue = (ExpandoValue)session.get(ExpandoValueImpl.class,
82 new Long(valueId));
83
84 if (expandoValue == null) {
85 if (_log.isWarnEnabled()) {
86 _log.warn("No ExpandoValue exists with the primary key " +
87 valueId);
88 }
89
90 throw new NoSuchValueException(
91 "No ExpandoValue exists with the primary key " + valueId);
92 }
93
94 return remove(expandoValue);
95 }
96 catch (NoSuchValueException nsee) {
97 throw nsee;
98 }
99 catch (Exception e) {
100 throw HibernateUtil.processException(e);
101 }
102 finally {
103 closeSession(session);
104 }
105 }
106
107 public ExpandoValue remove(ExpandoValue expandoValue)
108 throws SystemException {
109 if (_listeners != null) {
110 for (ModelListener listener : _listeners) {
111 listener.onBeforeRemove(expandoValue);
112 }
113 }
114
115 expandoValue = removeImpl(expandoValue);
116
117 if (_listeners != null) {
118 for (ModelListener listener : _listeners) {
119 listener.onAfterRemove(expandoValue);
120 }
121 }
122
123 return expandoValue;
124 }
125
126 protected ExpandoValue removeImpl(ExpandoValue expandoValue)
127 throws SystemException {
128 Session session = null;
129
130 try {
131 session = openSession();
132
133 session.delete(expandoValue);
134
135 session.flush();
136
137 return expandoValue;
138 }
139 catch (Exception e) {
140 throw HibernateUtil.processException(e);
141 }
142 finally {
143 closeSession(session);
144
145 FinderCache.clearCache(ExpandoValue.class.getName());
146 }
147 }
148
149
152 public ExpandoValue update(ExpandoValue expandoValue)
153 throws SystemException {
154 if (_log.isWarnEnabled()) {
155 _log.warn(
156 "Using the deprecated update(ExpandoValue expandoValue) method. Use update(ExpandoValue expandoValue, boolean merge) instead.");
157 }
158
159 return update(expandoValue, false);
160 }
161
162
175 public ExpandoValue update(ExpandoValue expandoValue, boolean merge)
176 throws SystemException {
177 boolean isNew = expandoValue.isNew();
178
179 if (_listeners != null) {
180 for (ModelListener listener : _listeners) {
181 if (isNew) {
182 listener.onBeforeCreate(expandoValue);
183 }
184 else {
185 listener.onBeforeUpdate(expandoValue);
186 }
187 }
188 }
189
190 expandoValue = updateImpl(expandoValue, merge);
191
192 if (_listeners != null) {
193 for (ModelListener listener : _listeners) {
194 if (isNew) {
195 listener.onAfterCreate(expandoValue);
196 }
197 else {
198 listener.onAfterUpdate(expandoValue);
199 }
200 }
201 }
202
203 return expandoValue;
204 }
205
206 public ExpandoValue updateImpl(
207 com.liferay.portlet.expando.model.ExpandoValue expandoValue,
208 boolean merge) throws SystemException {
209 Session session = null;
210
211 try {
212 session = openSession();
213
214 if (merge) {
215 session.merge(expandoValue);
216 }
217 else {
218 if (expandoValue.isNew()) {
219 session.save(expandoValue);
220 }
221 }
222
223 session.flush();
224
225 expandoValue.setNew(false);
226
227 return expandoValue;
228 }
229 catch (Exception e) {
230 throw HibernateUtil.processException(e);
231 }
232 finally {
233 closeSession(session);
234
235 FinderCache.clearCache(ExpandoValue.class.getName());
236 }
237 }
238
239 public ExpandoValue findByPrimaryKey(long valueId)
240 throws NoSuchValueException, SystemException {
241 ExpandoValue expandoValue = fetchByPrimaryKey(valueId);
242
243 if (expandoValue == null) {
244 if (_log.isWarnEnabled()) {
245 _log.warn("No ExpandoValue exists with the primary key " +
246 valueId);
247 }
248
249 throw new NoSuchValueException(
250 "No ExpandoValue exists with the primary key " + valueId);
251 }
252
253 return expandoValue;
254 }
255
256 public ExpandoValue fetchByPrimaryKey(long valueId)
257 throws SystemException {
258 Session session = null;
259
260 try {
261 session = openSession();
262
263 return (ExpandoValue)session.get(ExpandoValueImpl.class,
264 new Long(valueId));
265 }
266 catch (Exception e) {
267 throw HibernateUtil.processException(e);
268 }
269 finally {
270 closeSession(session);
271 }
272 }
273
274 public List<ExpandoValue> findByTableId(long tableId)
275 throws SystemException {
276 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
277 String finderClassName = ExpandoValue.class.getName();
278 String finderMethodName = "findByTableId";
279 String[] finderParams = new String[] { Long.class.getName() };
280 Object[] finderArgs = new Object[] { new Long(tableId) };
281
282 Object result = null;
283
284 if (finderClassNameCacheEnabled) {
285 result = FinderCache.getResult(finderClassName, finderMethodName,
286 finderParams, finderArgs, getSessionFactory());
287 }
288
289 if (result == null) {
290 Session session = null;
291
292 try {
293 session = openSession();
294
295 StringMaker query = new StringMaker();
296
297 query.append(
298 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
299
300 query.append("tableId = ?");
301
302 query.append(" ");
303
304 query.append("ORDER BY ");
305
306 query.append("tableId ASC, ");
307 query.append("rowId ASC, ");
308 query.append("columnId ASC");
309
310 Query q = session.createQuery(query.toString());
311
312 int queryPos = 0;
313
314 q.setLong(queryPos++, tableId);
315
316 List<ExpandoValue> list = q.list();
317
318 FinderCache.putResult(finderClassNameCacheEnabled,
319 finderClassName, finderMethodName, finderParams,
320 finderArgs, list);
321
322 return list;
323 }
324 catch (Exception e) {
325 throw HibernateUtil.processException(e);
326 }
327 finally {
328 closeSession(session);
329 }
330 }
331 else {
332 return (List<ExpandoValue>)result;
333 }
334 }
335
336 public List<ExpandoValue> findByTableId(long tableId, int begin, int end)
337 throws SystemException {
338 return findByTableId(tableId, begin, end, null);
339 }
340
341 public List<ExpandoValue> findByTableId(long tableId, int begin, int end,
342 OrderByComparator obc) throws SystemException {
343 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
344 String finderClassName = ExpandoValue.class.getName();
345 String finderMethodName = "findByTableId";
346 String[] finderParams = new String[] {
347 Long.class.getName(),
348
349 "java.lang.Integer", "java.lang.Integer",
350 "com.liferay.portal.kernel.util.OrderByComparator"
351 };
352 Object[] finderArgs = new Object[] {
353 new Long(tableId),
354
355 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
356 };
357
358 Object result = null;
359
360 if (finderClassNameCacheEnabled) {
361 result = FinderCache.getResult(finderClassName, finderMethodName,
362 finderParams, finderArgs, getSessionFactory());
363 }
364
365 if (result == null) {
366 Session session = null;
367
368 try {
369 session = openSession();
370
371 StringMaker query = new StringMaker();
372
373 query.append(
374 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
375
376 query.append("tableId = ?");
377
378 query.append(" ");
379
380 if (obc != null) {
381 query.append("ORDER BY ");
382 query.append(obc.getOrderBy());
383 }
384
385 else {
386 query.append("ORDER BY ");
387
388 query.append("tableId ASC, ");
389 query.append("rowId ASC, ");
390 query.append("columnId ASC");
391 }
392
393 Query q = session.createQuery(query.toString());
394
395 int queryPos = 0;
396
397 q.setLong(queryPos++, tableId);
398
399 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
400 getDialect(), begin, end);
401
402 FinderCache.putResult(finderClassNameCacheEnabled,
403 finderClassName, finderMethodName, finderParams,
404 finderArgs, list);
405
406 return list;
407 }
408 catch (Exception e) {
409 throw HibernateUtil.processException(e);
410 }
411 finally {
412 closeSession(session);
413 }
414 }
415 else {
416 return (List<ExpandoValue>)result;
417 }
418 }
419
420 public ExpandoValue findByTableId_First(long tableId, OrderByComparator obc)
421 throws NoSuchValueException, SystemException {
422 List<ExpandoValue> list = findByTableId(tableId, 0, 1, obc);
423
424 if (list.size() == 0) {
425 StringMaker msg = new StringMaker();
426
427 msg.append("No ExpandoValue exists with the key {");
428
429 msg.append("tableId=" + tableId);
430
431 msg.append(StringPool.CLOSE_CURLY_BRACE);
432
433 throw new NoSuchValueException(msg.toString());
434 }
435 else {
436 return list.get(0);
437 }
438 }
439
440 public ExpandoValue findByTableId_Last(long tableId, OrderByComparator obc)
441 throws NoSuchValueException, SystemException {
442 int count = countByTableId(tableId);
443
444 List<ExpandoValue> list = findByTableId(tableId, count - 1, count, obc);
445
446 if (list.size() == 0) {
447 StringMaker msg = new StringMaker();
448
449 msg.append("No ExpandoValue exists with the key {");
450
451 msg.append("tableId=" + tableId);
452
453 msg.append(StringPool.CLOSE_CURLY_BRACE);
454
455 throw new NoSuchValueException(msg.toString());
456 }
457 else {
458 return list.get(0);
459 }
460 }
461
462 public ExpandoValue[] findByTableId_PrevAndNext(long valueId, long tableId,
463 OrderByComparator obc) throws NoSuchValueException, SystemException {
464 ExpandoValue expandoValue = findByPrimaryKey(valueId);
465
466 int count = countByTableId(tableId);
467
468 Session session = null;
469
470 try {
471 session = openSession();
472
473 StringMaker query = new StringMaker();
474
475 query.append(
476 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
477
478 query.append("tableId = ?");
479
480 query.append(" ");
481
482 if (obc != null) {
483 query.append("ORDER BY ");
484 query.append(obc.getOrderBy());
485 }
486
487 else {
488 query.append("ORDER BY ");
489
490 query.append("tableId ASC, ");
491 query.append("rowId ASC, ");
492 query.append("columnId ASC");
493 }
494
495 Query q = session.createQuery(query.toString());
496
497 int queryPos = 0;
498
499 q.setLong(queryPos++, tableId);
500
501 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
502 expandoValue);
503
504 ExpandoValue[] array = new ExpandoValueImpl[3];
505
506 array[0] = (ExpandoValue)objArray[0];
507 array[1] = (ExpandoValue)objArray[1];
508 array[2] = (ExpandoValue)objArray[2];
509
510 return array;
511 }
512 catch (Exception e) {
513 throw HibernateUtil.processException(e);
514 }
515 finally {
516 closeSession(session);
517 }
518 }
519
520 public List<ExpandoValue> findByColumnId(long columnId)
521 throws SystemException {
522 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
523 String finderClassName = ExpandoValue.class.getName();
524 String finderMethodName = "findByColumnId";
525 String[] finderParams = new String[] { Long.class.getName() };
526 Object[] finderArgs = new Object[] { new Long(columnId) };
527
528 Object result = null;
529
530 if (finderClassNameCacheEnabled) {
531 result = FinderCache.getResult(finderClassName, finderMethodName,
532 finderParams, finderArgs, getSessionFactory());
533 }
534
535 if (result == null) {
536 Session session = null;
537
538 try {
539 session = openSession();
540
541 StringMaker query = new StringMaker();
542
543 query.append(
544 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
545
546 query.append("columnId = ?");
547
548 query.append(" ");
549
550 query.append("ORDER BY ");
551
552 query.append("tableId ASC, ");
553 query.append("rowId ASC, ");
554 query.append("columnId ASC");
555
556 Query q = session.createQuery(query.toString());
557
558 int queryPos = 0;
559
560 q.setLong(queryPos++, columnId);
561
562 List<ExpandoValue> list = q.list();
563
564 FinderCache.putResult(finderClassNameCacheEnabled,
565 finderClassName, finderMethodName, finderParams,
566 finderArgs, list);
567
568 return list;
569 }
570 catch (Exception e) {
571 throw HibernateUtil.processException(e);
572 }
573 finally {
574 closeSession(session);
575 }
576 }
577 else {
578 return (List<ExpandoValue>)result;
579 }
580 }
581
582 public List<ExpandoValue> findByColumnId(long columnId, int begin, int end)
583 throws SystemException {
584 return findByColumnId(columnId, begin, end, null);
585 }
586
587 public List<ExpandoValue> findByColumnId(long columnId, int begin, int end,
588 OrderByComparator obc) throws SystemException {
589 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
590 String finderClassName = ExpandoValue.class.getName();
591 String finderMethodName = "findByColumnId";
592 String[] finderParams = new String[] {
593 Long.class.getName(),
594
595 "java.lang.Integer", "java.lang.Integer",
596 "com.liferay.portal.kernel.util.OrderByComparator"
597 };
598 Object[] finderArgs = new Object[] {
599 new Long(columnId),
600
601 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
602 };
603
604 Object result = null;
605
606 if (finderClassNameCacheEnabled) {
607 result = FinderCache.getResult(finderClassName, finderMethodName,
608 finderParams, finderArgs, getSessionFactory());
609 }
610
611 if (result == null) {
612 Session session = null;
613
614 try {
615 session = openSession();
616
617 StringMaker query = new StringMaker();
618
619 query.append(
620 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
621
622 query.append("columnId = ?");
623
624 query.append(" ");
625
626 if (obc != null) {
627 query.append("ORDER BY ");
628 query.append(obc.getOrderBy());
629 }
630
631 else {
632 query.append("ORDER BY ");
633
634 query.append("tableId ASC, ");
635 query.append("rowId ASC, ");
636 query.append("columnId ASC");
637 }
638
639 Query q = session.createQuery(query.toString());
640
641 int queryPos = 0;
642
643 q.setLong(queryPos++, columnId);
644
645 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
646 getDialect(), begin, end);
647
648 FinderCache.putResult(finderClassNameCacheEnabled,
649 finderClassName, finderMethodName, finderParams,
650 finderArgs, list);
651
652 return list;
653 }
654 catch (Exception e) {
655 throw HibernateUtil.processException(e);
656 }
657 finally {
658 closeSession(session);
659 }
660 }
661 else {
662 return (List<ExpandoValue>)result;
663 }
664 }
665
666 public ExpandoValue findByColumnId_First(long columnId,
667 OrderByComparator obc) throws NoSuchValueException, SystemException {
668 List<ExpandoValue> list = findByColumnId(columnId, 0, 1, obc);
669
670 if (list.size() == 0) {
671 StringMaker msg = new StringMaker();
672
673 msg.append("No ExpandoValue exists with the key {");
674
675 msg.append("columnId=" + columnId);
676
677 msg.append(StringPool.CLOSE_CURLY_BRACE);
678
679 throw new NoSuchValueException(msg.toString());
680 }
681 else {
682 return list.get(0);
683 }
684 }
685
686 public ExpandoValue findByColumnId_Last(long columnId, OrderByComparator obc)
687 throws NoSuchValueException, SystemException {
688 int count = countByColumnId(columnId);
689
690 List<ExpandoValue> list = findByColumnId(columnId, count - 1, count, obc);
691
692 if (list.size() == 0) {
693 StringMaker msg = new StringMaker();
694
695 msg.append("No ExpandoValue exists with the key {");
696
697 msg.append("columnId=" + columnId);
698
699 msg.append(StringPool.CLOSE_CURLY_BRACE);
700
701 throw new NoSuchValueException(msg.toString());
702 }
703 else {
704 return list.get(0);
705 }
706 }
707
708 public ExpandoValue[] findByColumnId_PrevAndNext(long valueId,
709 long columnId, OrderByComparator obc)
710 throws NoSuchValueException, SystemException {
711 ExpandoValue expandoValue = findByPrimaryKey(valueId);
712
713 int count = countByColumnId(columnId);
714
715 Session session = null;
716
717 try {
718 session = openSession();
719
720 StringMaker query = new StringMaker();
721
722 query.append(
723 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
724
725 query.append("columnId = ?");
726
727 query.append(" ");
728
729 if (obc != null) {
730 query.append("ORDER BY ");
731 query.append(obc.getOrderBy());
732 }
733
734 else {
735 query.append("ORDER BY ");
736
737 query.append("tableId ASC, ");
738 query.append("rowId ASC, ");
739 query.append("columnId ASC");
740 }
741
742 Query q = session.createQuery(query.toString());
743
744 int queryPos = 0;
745
746 q.setLong(queryPos++, columnId);
747
748 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
749 expandoValue);
750
751 ExpandoValue[] array = new ExpandoValueImpl[3];
752
753 array[0] = (ExpandoValue)objArray[0];
754 array[1] = (ExpandoValue)objArray[1];
755 array[2] = (ExpandoValue)objArray[2];
756
757 return array;
758 }
759 catch (Exception e) {
760 throw HibernateUtil.processException(e);
761 }
762 finally {
763 closeSession(session);
764 }
765 }
766
767 public List<ExpandoValue> findByRowId(long rowId) throws SystemException {
768 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
769 String finderClassName = ExpandoValue.class.getName();
770 String finderMethodName = "findByRowId";
771 String[] finderParams = new String[] { Long.class.getName() };
772 Object[] finderArgs = new Object[] { new Long(rowId) };
773
774 Object result = null;
775
776 if (finderClassNameCacheEnabled) {
777 result = FinderCache.getResult(finderClassName, finderMethodName,
778 finderParams, finderArgs, getSessionFactory());
779 }
780
781 if (result == null) {
782 Session session = null;
783
784 try {
785 session = openSession();
786
787 StringMaker query = new StringMaker();
788
789 query.append(
790 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
791
792 query.append("rowId = ?");
793
794 query.append(" ");
795
796 query.append("ORDER BY ");
797
798 query.append("tableId ASC, ");
799 query.append("rowId ASC, ");
800 query.append("columnId ASC");
801
802 Query q = session.createQuery(query.toString());
803
804 int queryPos = 0;
805
806 q.setLong(queryPos++, rowId);
807
808 List<ExpandoValue> list = q.list();
809
810 FinderCache.putResult(finderClassNameCacheEnabled,
811 finderClassName, finderMethodName, finderParams,
812 finderArgs, list);
813
814 return list;
815 }
816 catch (Exception e) {
817 throw HibernateUtil.processException(e);
818 }
819 finally {
820 closeSession(session);
821 }
822 }
823 else {
824 return (List<ExpandoValue>)result;
825 }
826 }
827
828 public List<ExpandoValue> findByRowId(long rowId, int begin, int end)
829 throws SystemException {
830 return findByRowId(rowId, begin, end, null);
831 }
832
833 public List<ExpandoValue> findByRowId(long rowId, int begin, int end,
834 OrderByComparator obc) throws SystemException {
835 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
836 String finderClassName = ExpandoValue.class.getName();
837 String finderMethodName = "findByRowId";
838 String[] finderParams = new String[] {
839 Long.class.getName(),
840
841 "java.lang.Integer", "java.lang.Integer",
842 "com.liferay.portal.kernel.util.OrderByComparator"
843 };
844 Object[] finderArgs = new Object[] {
845 new Long(rowId),
846
847 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
848 };
849
850 Object result = null;
851
852 if (finderClassNameCacheEnabled) {
853 result = FinderCache.getResult(finderClassName, finderMethodName,
854 finderParams, finderArgs, getSessionFactory());
855 }
856
857 if (result == null) {
858 Session session = null;
859
860 try {
861 session = openSession();
862
863 StringMaker query = new StringMaker();
864
865 query.append(
866 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
867
868 query.append("rowId = ?");
869
870 query.append(" ");
871
872 if (obc != null) {
873 query.append("ORDER BY ");
874 query.append(obc.getOrderBy());
875 }
876
877 else {
878 query.append("ORDER BY ");
879
880 query.append("tableId ASC, ");
881 query.append("rowId ASC, ");
882 query.append("columnId ASC");
883 }
884
885 Query q = session.createQuery(query.toString());
886
887 int queryPos = 0;
888
889 q.setLong(queryPos++, rowId);
890
891 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
892 getDialect(), begin, end);
893
894 FinderCache.putResult(finderClassNameCacheEnabled,
895 finderClassName, finderMethodName, finderParams,
896 finderArgs, list);
897
898 return list;
899 }
900 catch (Exception e) {
901 throw HibernateUtil.processException(e);
902 }
903 finally {
904 closeSession(session);
905 }
906 }
907 else {
908 return (List<ExpandoValue>)result;
909 }
910 }
911
912 public ExpandoValue findByRowId_First(long rowId, OrderByComparator obc)
913 throws NoSuchValueException, SystemException {
914 List<ExpandoValue> list = findByRowId(rowId, 0, 1, obc);
915
916 if (list.size() == 0) {
917 StringMaker msg = new StringMaker();
918
919 msg.append("No ExpandoValue exists with the key {");
920
921 msg.append("rowId=" + rowId);
922
923 msg.append(StringPool.CLOSE_CURLY_BRACE);
924
925 throw new NoSuchValueException(msg.toString());
926 }
927 else {
928 return list.get(0);
929 }
930 }
931
932 public ExpandoValue findByRowId_Last(long rowId, OrderByComparator obc)
933 throws NoSuchValueException, SystemException {
934 int count = countByRowId(rowId);
935
936 List<ExpandoValue> list = findByRowId(rowId, count - 1, count, obc);
937
938 if (list.size() == 0) {
939 StringMaker msg = new StringMaker();
940
941 msg.append("No ExpandoValue exists with the key {");
942
943 msg.append("rowId=" + rowId);
944
945 msg.append(StringPool.CLOSE_CURLY_BRACE);
946
947 throw new NoSuchValueException(msg.toString());
948 }
949 else {
950 return list.get(0);
951 }
952 }
953
954 public ExpandoValue[] findByRowId_PrevAndNext(long valueId, long rowId,
955 OrderByComparator obc) throws NoSuchValueException, SystemException {
956 ExpandoValue expandoValue = findByPrimaryKey(valueId);
957
958 int count = countByRowId(rowId);
959
960 Session session = null;
961
962 try {
963 session = openSession();
964
965 StringMaker query = new StringMaker();
966
967 query.append(
968 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
969
970 query.append("rowId = ?");
971
972 query.append(" ");
973
974 if (obc != null) {
975 query.append("ORDER BY ");
976 query.append(obc.getOrderBy());
977 }
978
979 else {
980 query.append("ORDER BY ");
981
982 query.append("tableId ASC, ");
983 query.append("rowId ASC, ");
984 query.append("columnId ASC");
985 }
986
987 Query q = session.createQuery(query.toString());
988
989 int queryPos = 0;
990
991 q.setLong(queryPos++, rowId);
992
993 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
994 expandoValue);
995
996 ExpandoValue[] array = new ExpandoValueImpl[3];
997
998 array[0] = (ExpandoValue)objArray[0];
999 array[1] = (ExpandoValue)objArray[1];
1000 array[2] = (ExpandoValue)objArray[2];
1001
1002 return array;
1003 }
1004 catch (Exception e) {
1005 throw HibernateUtil.processException(e);
1006 }
1007 finally {
1008 closeSession(session);
1009 }
1010 }
1011
1012 public List<ExpandoValue> findByT_R(long tableId, long rowId)
1013 throws SystemException {
1014 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1015 String finderClassName = ExpandoValue.class.getName();
1016 String finderMethodName = "findByT_R";
1017 String[] finderParams = new String[] {
1018 Long.class.getName(), Long.class.getName()
1019 };
1020 Object[] finderArgs = new Object[] { new Long(tableId), new Long(rowId) };
1021
1022 Object result = null;
1023
1024 if (finderClassNameCacheEnabled) {
1025 result = FinderCache.getResult(finderClassName, finderMethodName,
1026 finderParams, finderArgs, getSessionFactory());
1027 }
1028
1029 if (result == null) {
1030 Session session = null;
1031
1032 try {
1033 session = openSession();
1034
1035 StringMaker query = new StringMaker();
1036
1037 query.append(
1038 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1039
1040 query.append("tableId = ?");
1041
1042 query.append(" AND ");
1043
1044 query.append("rowId = ?");
1045
1046 query.append(" ");
1047
1048 query.append("ORDER BY ");
1049
1050 query.append("tableId ASC, ");
1051 query.append("rowId ASC, ");
1052 query.append("columnId ASC");
1053
1054 Query q = session.createQuery(query.toString());
1055
1056 int queryPos = 0;
1057
1058 q.setLong(queryPos++, tableId);
1059
1060 q.setLong(queryPos++, rowId);
1061
1062 List<ExpandoValue> list = q.list();
1063
1064 FinderCache.putResult(finderClassNameCacheEnabled,
1065 finderClassName, finderMethodName, finderParams,
1066 finderArgs, list);
1067
1068 return list;
1069 }
1070 catch (Exception e) {
1071 throw HibernateUtil.processException(e);
1072 }
1073 finally {
1074 closeSession(session);
1075 }
1076 }
1077 else {
1078 return (List<ExpandoValue>)result;
1079 }
1080 }
1081
1082 public List<ExpandoValue> findByT_R(long tableId, long rowId, int begin,
1083 int end) throws SystemException {
1084 return findByT_R(tableId, rowId, begin, end, null);
1085 }
1086
1087 public List<ExpandoValue> findByT_R(long tableId, long rowId, int begin,
1088 int end, OrderByComparator obc) throws SystemException {
1089 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1090 String finderClassName = ExpandoValue.class.getName();
1091 String finderMethodName = "findByT_R";
1092 String[] finderParams = new String[] {
1093 Long.class.getName(), Long.class.getName(),
1094
1095 "java.lang.Integer", "java.lang.Integer",
1096 "com.liferay.portal.kernel.util.OrderByComparator"
1097 };
1098 Object[] finderArgs = new Object[] {
1099 new Long(tableId), new Long(rowId),
1100
1101 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1102 };
1103
1104 Object result = null;
1105
1106 if (finderClassNameCacheEnabled) {
1107 result = FinderCache.getResult(finderClassName, finderMethodName,
1108 finderParams, finderArgs, getSessionFactory());
1109 }
1110
1111 if (result == null) {
1112 Session session = null;
1113
1114 try {
1115 session = openSession();
1116
1117 StringMaker query = new StringMaker();
1118
1119 query.append(
1120 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1121
1122 query.append("tableId = ?");
1123
1124 query.append(" AND ");
1125
1126 query.append("rowId = ?");
1127
1128 query.append(" ");
1129
1130 if (obc != null) {
1131 query.append("ORDER BY ");
1132 query.append(obc.getOrderBy());
1133 }
1134
1135 else {
1136 query.append("ORDER BY ");
1137
1138 query.append("tableId ASC, ");
1139 query.append("rowId ASC, ");
1140 query.append("columnId ASC");
1141 }
1142
1143 Query q = session.createQuery(query.toString());
1144
1145 int queryPos = 0;
1146
1147 q.setLong(queryPos++, tableId);
1148
1149 q.setLong(queryPos++, rowId);
1150
1151 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
1152 getDialect(), begin, end);
1153
1154 FinderCache.putResult(finderClassNameCacheEnabled,
1155 finderClassName, finderMethodName, finderParams,
1156 finderArgs, list);
1157
1158 return list;
1159 }
1160 catch (Exception e) {
1161 throw HibernateUtil.processException(e);
1162 }
1163 finally {
1164 closeSession(session);
1165 }
1166 }
1167 else {
1168 return (List<ExpandoValue>)result;
1169 }
1170 }
1171
1172 public ExpandoValue findByT_R_First(long tableId, long rowId,
1173 OrderByComparator obc) throws NoSuchValueException, SystemException {
1174 List<ExpandoValue> list = findByT_R(tableId, rowId, 0, 1, obc);
1175
1176 if (list.size() == 0) {
1177 StringMaker msg = new StringMaker();
1178
1179 msg.append("No ExpandoValue exists with the key {");
1180
1181 msg.append("tableId=" + tableId);
1182
1183 msg.append(", ");
1184 msg.append("rowId=" + rowId);
1185
1186 msg.append(StringPool.CLOSE_CURLY_BRACE);
1187
1188 throw new NoSuchValueException(msg.toString());
1189 }
1190 else {
1191 return list.get(0);
1192 }
1193 }
1194
1195 public ExpandoValue findByT_R_Last(long tableId, long rowId,
1196 OrderByComparator obc) throws NoSuchValueException, SystemException {
1197 int count = countByT_R(tableId, rowId);
1198
1199 List<ExpandoValue> list = findByT_R(tableId, rowId, count - 1, count,
1200 obc);
1201
1202 if (list.size() == 0) {
1203 StringMaker msg = new StringMaker();
1204
1205 msg.append("No ExpandoValue exists with the key {");
1206
1207 msg.append("tableId=" + tableId);
1208
1209 msg.append(", ");
1210 msg.append("rowId=" + rowId);
1211
1212 msg.append(StringPool.CLOSE_CURLY_BRACE);
1213
1214 throw new NoSuchValueException(msg.toString());
1215 }
1216 else {
1217 return list.get(0);
1218 }
1219 }
1220
1221 public ExpandoValue[] findByT_R_PrevAndNext(long valueId, long tableId,
1222 long rowId, OrderByComparator obc)
1223 throws NoSuchValueException, SystemException {
1224 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1225
1226 int count = countByT_R(tableId, rowId);
1227
1228 Session session = null;
1229
1230 try {
1231 session = openSession();
1232
1233 StringMaker query = new StringMaker();
1234
1235 query.append(
1236 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1237
1238 query.append("tableId = ?");
1239
1240 query.append(" AND ");
1241
1242 query.append("rowId = ?");
1243
1244 query.append(" ");
1245
1246 if (obc != null) {
1247 query.append("ORDER BY ");
1248 query.append(obc.getOrderBy());
1249 }
1250
1251 else {
1252 query.append("ORDER BY ");
1253
1254 query.append("tableId ASC, ");
1255 query.append("rowId ASC, ");
1256 query.append("columnId ASC");
1257 }
1258
1259 Query q = session.createQuery(query.toString());
1260
1261 int queryPos = 0;
1262
1263 q.setLong(queryPos++, tableId);
1264
1265 q.setLong(queryPos++, rowId);
1266
1267 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1268 expandoValue);
1269
1270 ExpandoValue[] array = new ExpandoValueImpl[3];
1271
1272 array[0] = (ExpandoValue)objArray[0];
1273 array[1] = (ExpandoValue)objArray[1];
1274 array[2] = (ExpandoValue)objArray[2];
1275
1276 return array;
1277 }
1278 catch (Exception e) {
1279 throw HibernateUtil.processException(e);
1280 }
1281 finally {
1282 closeSession(session);
1283 }
1284 }
1285
1286 public ExpandoValue findByC_R(long columnId, long rowId)
1287 throws NoSuchValueException, SystemException {
1288 ExpandoValue expandoValue = fetchByC_R(columnId, rowId);
1289
1290 if (expandoValue == null) {
1291 StringMaker msg = new StringMaker();
1292
1293 msg.append("No ExpandoValue exists with the key {");
1294
1295 msg.append("columnId=" + columnId);
1296
1297 msg.append(", ");
1298 msg.append("rowId=" + rowId);
1299
1300 msg.append(StringPool.CLOSE_CURLY_BRACE);
1301
1302 if (_log.isWarnEnabled()) {
1303 _log.warn(msg.toString());
1304 }
1305
1306 throw new NoSuchValueException(msg.toString());
1307 }
1308
1309 return expandoValue;
1310 }
1311
1312 public ExpandoValue fetchByC_R(long columnId, long rowId)
1313 throws SystemException {
1314 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1315 String finderClassName = ExpandoValue.class.getName();
1316 String finderMethodName = "fetchByC_R";
1317 String[] finderParams = new String[] {
1318 Long.class.getName(), Long.class.getName()
1319 };
1320 Object[] finderArgs = new Object[] { new Long(columnId), new Long(rowId) };
1321
1322 Object result = null;
1323
1324 if (finderClassNameCacheEnabled) {
1325 result = FinderCache.getResult(finderClassName, finderMethodName,
1326 finderParams, finderArgs, getSessionFactory());
1327 }
1328
1329 if (result == null) {
1330 Session session = null;
1331
1332 try {
1333 session = openSession();
1334
1335 StringMaker query = new StringMaker();
1336
1337 query.append(
1338 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1339
1340 query.append("columnId = ?");
1341
1342 query.append(" AND ");
1343
1344 query.append("rowId = ?");
1345
1346 query.append(" ");
1347
1348 query.append("ORDER BY ");
1349
1350 query.append("tableId ASC, ");
1351 query.append("rowId ASC, ");
1352 query.append("columnId ASC");
1353
1354 Query q = session.createQuery(query.toString());
1355
1356 int queryPos = 0;
1357
1358 q.setLong(queryPos++, columnId);
1359
1360 q.setLong(queryPos++, rowId);
1361
1362 List<ExpandoValue> list = q.list();
1363
1364 FinderCache.putResult(finderClassNameCacheEnabled,
1365 finderClassName, finderMethodName, finderParams,
1366 finderArgs, list);
1367
1368 if (list.size() == 0) {
1369 return null;
1370 }
1371 else {
1372 return list.get(0);
1373 }
1374 }
1375 catch (Exception e) {
1376 throw HibernateUtil.processException(e);
1377 }
1378 finally {
1379 closeSession(session);
1380 }
1381 }
1382 else {
1383 List<ExpandoValue> list = (List<ExpandoValue>)result;
1384
1385 if (list.size() == 0) {
1386 return null;
1387 }
1388 else {
1389 return list.get(0);
1390 }
1391 }
1392 }
1393
1394 public List<ExpandoValue> findByC_C(long classNameId, long classPK)
1395 throws SystemException {
1396 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1397 String finderClassName = ExpandoValue.class.getName();
1398 String finderMethodName = "findByC_C";
1399 String[] finderParams = new String[] {
1400 Long.class.getName(), Long.class.getName()
1401 };
1402 Object[] finderArgs = new Object[] {
1403 new Long(classNameId), new Long(classPK)
1404 };
1405
1406 Object result = null;
1407
1408 if (finderClassNameCacheEnabled) {
1409 result = FinderCache.getResult(finderClassName, finderMethodName,
1410 finderParams, finderArgs, getSessionFactory());
1411 }
1412
1413 if (result == null) {
1414 Session session = null;
1415
1416 try {
1417 session = openSession();
1418
1419 StringMaker query = new StringMaker();
1420
1421 query.append(
1422 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1423
1424 query.append("classNameId = ?");
1425
1426 query.append(" AND ");
1427
1428 query.append("classPK = ?");
1429
1430 query.append(" ");
1431
1432 query.append("ORDER BY ");
1433
1434 query.append("tableId ASC, ");
1435 query.append("rowId ASC, ");
1436 query.append("columnId ASC");
1437
1438 Query q = session.createQuery(query.toString());
1439
1440 int queryPos = 0;
1441
1442 q.setLong(queryPos++, classNameId);
1443
1444 q.setLong(queryPos++, classPK);
1445
1446 List<ExpandoValue> list = q.list();
1447
1448 FinderCache.putResult(finderClassNameCacheEnabled,
1449 finderClassName, finderMethodName, finderParams,
1450 finderArgs, list);
1451
1452 return list;
1453 }
1454 catch (Exception e) {
1455 throw HibernateUtil.processException(e);
1456 }
1457 finally {
1458 closeSession(session);
1459 }
1460 }
1461 else {
1462 return (List<ExpandoValue>)result;
1463 }
1464 }
1465
1466 public List<ExpandoValue> findByC_C(long classNameId, long classPK,
1467 int begin, int end) throws SystemException {
1468 return findByC_C(classNameId, classPK, begin, end, null);
1469 }
1470
1471 public List<ExpandoValue> findByC_C(long classNameId, long classPK,
1472 int begin, int end, OrderByComparator obc) throws SystemException {
1473 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1474 String finderClassName = ExpandoValue.class.getName();
1475 String finderMethodName = "findByC_C";
1476 String[] finderParams = new String[] {
1477 Long.class.getName(), Long.class.getName(),
1478
1479 "java.lang.Integer", "java.lang.Integer",
1480 "com.liferay.portal.kernel.util.OrderByComparator"
1481 };
1482 Object[] finderArgs = new Object[] {
1483 new Long(classNameId), new Long(classPK),
1484
1485 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1486 };
1487
1488 Object result = null;
1489
1490 if (finderClassNameCacheEnabled) {
1491 result = FinderCache.getResult(finderClassName, finderMethodName,
1492 finderParams, finderArgs, getSessionFactory());
1493 }
1494
1495 if (result == null) {
1496 Session session = null;
1497
1498 try {
1499 session = openSession();
1500
1501 StringMaker query = new StringMaker();
1502
1503 query.append(
1504 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1505
1506 query.append("classNameId = ?");
1507
1508 query.append(" AND ");
1509
1510 query.append("classPK = ?");
1511
1512 query.append(" ");
1513
1514 if (obc != null) {
1515 query.append("ORDER BY ");
1516 query.append(obc.getOrderBy());
1517 }
1518
1519 else {
1520 query.append("ORDER BY ");
1521
1522 query.append("tableId ASC, ");
1523 query.append("rowId ASC, ");
1524 query.append("columnId ASC");
1525 }
1526
1527 Query q = session.createQuery(query.toString());
1528
1529 int queryPos = 0;
1530
1531 q.setLong(queryPos++, classNameId);
1532
1533 q.setLong(queryPos++, classPK);
1534
1535 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
1536 getDialect(), begin, end);
1537
1538 FinderCache.putResult(finderClassNameCacheEnabled,
1539 finderClassName, finderMethodName, finderParams,
1540 finderArgs, list);
1541
1542 return list;
1543 }
1544 catch (Exception e) {
1545 throw HibernateUtil.processException(e);
1546 }
1547 finally {
1548 closeSession(session);
1549 }
1550 }
1551 else {
1552 return (List<ExpandoValue>)result;
1553 }
1554 }
1555
1556 public ExpandoValue findByC_C_First(long classNameId, long classPK,
1557 OrderByComparator obc) throws NoSuchValueException, SystemException {
1558 List<ExpandoValue> list = findByC_C(classNameId, classPK, 0, 1, obc);
1559
1560 if (list.size() == 0) {
1561 StringMaker msg = new StringMaker();
1562
1563 msg.append("No ExpandoValue exists with the key {");
1564
1565 msg.append("classNameId=" + classNameId);
1566
1567 msg.append(", ");
1568 msg.append("classPK=" + classPK);
1569
1570 msg.append(StringPool.CLOSE_CURLY_BRACE);
1571
1572 throw new NoSuchValueException(msg.toString());
1573 }
1574 else {
1575 return list.get(0);
1576 }
1577 }
1578
1579 public ExpandoValue findByC_C_Last(long classNameId, long classPK,
1580 OrderByComparator obc) throws NoSuchValueException, SystemException {
1581 int count = countByC_C(classNameId, classPK);
1582
1583 List<ExpandoValue> list = findByC_C(classNameId, classPK, count - 1,
1584 count, obc);
1585
1586 if (list.size() == 0) {
1587 StringMaker msg = new StringMaker();
1588
1589 msg.append("No ExpandoValue exists with the key {");
1590
1591 msg.append("classNameId=" + classNameId);
1592
1593 msg.append(", ");
1594 msg.append("classPK=" + classPK);
1595
1596 msg.append(StringPool.CLOSE_CURLY_BRACE);
1597
1598 throw new NoSuchValueException(msg.toString());
1599 }
1600 else {
1601 return list.get(0);
1602 }
1603 }
1604
1605 public ExpandoValue[] findByC_C_PrevAndNext(long valueId, long classNameId,
1606 long classPK, OrderByComparator obc)
1607 throws NoSuchValueException, SystemException {
1608 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1609
1610 int count = countByC_C(classNameId, classPK);
1611
1612 Session session = null;
1613
1614 try {
1615 session = openSession();
1616
1617 StringMaker query = new StringMaker();
1618
1619 query.append(
1620 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1621
1622 query.append("classNameId = ?");
1623
1624 query.append(" AND ");
1625
1626 query.append("classPK = ?");
1627
1628 query.append(" ");
1629
1630 if (obc != null) {
1631 query.append("ORDER BY ");
1632 query.append(obc.getOrderBy());
1633 }
1634
1635 else {
1636 query.append("ORDER BY ");
1637
1638 query.append("tableId ASC, ");
1639 query.append("rowId ASC, ");
1640 query.append("columnId ASC");
1641 }
1642
1643 Query q = session.createQuery(query.toString());
1644
1645 int queryPos = 0;
1646
1647 q.setLong(queryPos++, classNameId);
1648
1649 q.setLong(queryPos++, classPK);
1650
1651 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1652 expandoValue);
1653
1654 ExpandoValue[] array = new ExpandoValueImpl[3];
1655
1656 array[0] = (ExpandoValue)objArray[0];
1657 array[1] = (ExpandoValue)objArray[1];
1658 array[2] = (ExpandoValue)objArray[2];
1659
1660 return array;
1661 }
1662 catch (Exception e) {
1663 throw HibernateUtil.processException(e);
1664 }
1665 finally {
1666 closeSession(session);
1667 }
1668 }
1669
1670 public ExpandoValue findByT_C_R(long tableId, long columnId, long rowId)
1671 throws NoSuchValueException, SystemException {
1672 ExpandoValue expandoValue = fetchByT_C_R(tableId, columnId, rowId);
1673
1674 if (expandoValue == null) {
1675 StringMaker msg = new StringMaker();
1676
1677 msg.append("No ExpandoValue exists with the key {");
1678
1679 msg.append("tableId=" + tableId);
1680
1681 msg.append(", ");
1682 msg.append("columnId=" + columnId);
1683
1684 msg.append(", ");
1685 msg.append("rowId=" + rowId);
1686
1687 msg.append(StringPool.CLOSE_CURLY_BRACE);
1688
1689 if (_log.isWarnEnabled()) {
1690 _log.warn(msg.toString());
1691 }
1692
1693 throw new NoSuchValueException(msg.toString());
1694 }
1695
1696 return expandoValue;
1697 }
1698
1699 public ExpandoValue fetchByT_C_R(long tableId, long columnId, long rowId)
1700 throws SystemException {
1701 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1702 String finderClassName = ExpandoValue.class.getName();
1703 String finderMethodName = "fetchByT_C_R";
1704 String[] finderParams = new String[] {
1705 Long.class.getName(), Long.class.getName(), Long.class.getName()
1706 };
1707 Object[] finderArgs = new Object[] {
1708 new Long(tableId), new Long(columnId), new Long(rowId)
1709 };
1710
1711 Object result = null;
1712
1713 if (finderClassNameCacheEnabled) {
1714 result = FinderCache.getResult(finderClassName, finderMethodName,
1715 finderParams, finderArgs, getSessionFactory());
1716 }
1717
1718 if (result == null) {
1719 Session session = null;
1720
1721 try {
1722 session = openSession();
1723
1724 StringMaker query = new StringMaker();
1725
1726 query.append(
1727 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1728
1729 query.append("tableId = ?");
1730
1731 query.append(" AND ");
1732
1733 query.append("columnId = ?");
1734
1735 query.append(" AND ");
1736
1737 query.append("rowId = ?");
1738
1739 query.append(" ");
1740
1741 query.append("ORDER BY ");
1742
1743 query.append("tableId ASC, ");
1744 query.append("rowId ASC, ");
1745 query.append("columnId ASC");
1746
1747 Query q = session.createQuery(query.toString());
1748
1749 int queryPos = 0;
1750
1751 q.setLong(queryPos++, tableId);
1752
1753 q.setLong(queryPos++, columnId);
1754
1755 q.setLong(queryPos++, rowId);
1756
1757 List<ExpandoValue> list = q.list();
1758
1759 FinderCache.putResult(finderClassNameCacheEnabled,
1760 finderClassName, finderMethodName, finderParams,
1761 finderArgs, list);
1762
1763 if (list.size() == 0) {
1764 return null;
1765 }
1766 else {
1767 return list.get(0);
1768 }
1769 }
1770 catch (Exception e) {
1771 throw HibernateUtil.processException(e);
1772 }
1773 finally {
1774 closeSession(session);
1775 }
1776 }
1777 else {
1778 List<ExpandoValue> list = (List<ExpandoValue>)result;
1779
1780 if (list.size() == 0) {
1781 return null;
1782 }
1783 else {
1784 return list.get(0);
1785 }
1786 }
1787 }
1788
1789 public List<ExpandoValue> findByT_C_C_C(long tableId, long columnId,
1790 long classNameId, long classPK) throws SystemException {
1791 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1792 String finderClassName = ExpandoValue.class.getName();
1793 String finderMethodName = "findByT_C_C_C";
1794 String[] finderParams = new String[] {
1795 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1796 Long.class.getName()
1797 };
1798 Object[] finderArgs = new Object[] {
1799 new Long(tableId), new Long(columnId), new Long(classNameId),
1800 new Long(classPK)
1801 };
1802
1803 Object result = null;
1804
1805 if (finderClassNameCacheEnabled) {
1806 result = FinderCache.getResult(finderClassName, finderMethodName,
1807 finderParams, finderArgs, getSessionFactory());
1808 }
1809
1810 if (result == null) {
1811 Session session = null;
1812
1813 try {
1814 session = openSession();
1815
1816 StringMaker query = new StringMaker();
1817
1818 query.append(
1819 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1820
1821 query.append("tableId = ?");
1822
1823 query.append(" AND ");
1824
1825 query.append("columnId = ?");
1826
1827 query.append(" AND ");
1828
1829 query.append("classNameId = ?");
1830
1831 query.append(" AND ");
1832
1833 query.append("classPK = ?");
1834
1835 query.append(" ");
1836
1837 query.append("ORDER BY ");
1838
1839 query.append("tableId ASC, ");
1840 query.append("rowId ASC, ");
1841 query.append("columnId ASC");
1842
1843 Query q = session.createQuery(query.toString());
1844
1845 int queryPos = 0;
1846
1847 q.setLong(queryPos++, tableId);
1848
1849 q.setLong(queryPos++, columnId);
1850
1851 q.setLong(queryPos++, classNameId);
1852
1853 q.setLong(queryPos++, classPK);
1854
1855 List<ExpandoValue> list = q.list();
1856
1857 FinderCache.putResult(finderClassNameCacheEnabled,
1858 finderClassName, finderMethodName, finderParams,
1859 finderArgs, list);
1860
1861 return list;
1862 }
1863 catch (Exception e) {
1864 throw HibernateUtil.processException(e);
1865 }
1866 finally {
1867 closeSession(session);
1868 }
1869 }
1870 else {
1871 return (List<ExpandoValue>)result;
1872 }
1873 }
1874
1875 public List<ExpandoValue> findByT_C_C_C(long tableId, long columnId,
1876 long classNameId, long classPK, int begin, int end)
1877 throws SystemException {
1878 return findByT_C_C_C(tableId, columnId, classNameId, classPK, begin,
1879 end, null);
1880 }
1881
1882 public List<ExpandoValue> findByT_C_C_C(long tableId, long columnId,
1883 long classNameId, long classPK, int begin, int end,
1884 OrderByComparator obc) throws SystemException {
1885 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
1886 String finderClassName = ExpandoValue.class.getName();
1887 String finderMethodName = "findByT_C_C_C";
1888 String[] finderParams = new String[] {
1889 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1890 Long.class.getName(),
1891
1892 "java.lang.Integer", "java.lang.Integer",
1893 "com.liferay.portal.kernel.util.OrderByComparator"
1894 };
1895 Object[] finderArgs = new Object[] {
1896 new Long(tableId), new Long(columnId), new Long(classNameId),
1897 new Long(classPK),
1898
1899 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1900 };
1901
1902 Object result = null;
1903
1904 if (finderClassNameCacheEnabled) {
1905 result = FinderCache.getResult(finderClassName, finderMethodName,
1906 finderParams, finderArgs, getSessionFactory());
1907 }
1908
1909 if (result == null) {
1910 Session session = null;
1911
1912 try {
1913 session = openSession();
1914
1915 StringMaker query = new StringMaker();
1916
1917 query.append(
1918 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
1919
1920 query.append("tableId = ?");
1921
1922 query.append(" AND ");
1923
1924 query.append("columnId = ?");
1925
1926 query.append(" AND ");
1927
1928 query.append("classNameId = ?");
1929
1930 query.append(" AND ");
1931
1932 query.append("classPK = ?");
1933
1934 query.append(" ");
1935
1936 if (obc != null) {
1937 query.append("ORDER BY ");
1938 query.append(obc.getOrderBy());
1939 }
1940
1941 else {
1942 query.append("ORDER BY ");
1943
1944 query.append("tableId ASC, ");
1945 query.append("rowId ASC, ");
1946 query.append("columnId ASC");
1947 }
1948
1949 Query q = session.createQuery(query.toString());
1950
1951 int queryPos = 0;
1952
1953 q.setLong(queryPos++, tableId);
1954
1955 q.setLong(queryPos++, columnId);
1956
1957 q.setLong(queryPos++, classNameId);
1958
1959 q.setLong(queryPos++, classPK);
1960
1961 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
1962 getDialect(), begin, end);
1963
1964 FinderCache.putResult(finderClassNameCacheEnabled,
1965 finderClassName, finderMethodName, finderParams,
1966 finderArgs, list);
1967
1968 return list;
1969 }
1970 catch (Exception e) {
1971 throw HibernateUtil.processException(e);
1972 }
1973 finally {
1974 closeSession(session);
1975 }
1976 }
1977 else {
1978 return (List<ExpandoValue>)result;
1979 }
1980 }
1981
1982 public ExpandoValue findByT_C_C_C_First(long tableId, long columnId,
1983 long classNameId, long classPK, OrderByComparator obc)
1984 throws NoSuchValueException, SystemException {
1985 List<ExpandoValue> list = findByT_C_C_C(tableId, columnId, classNameId,
1986 classPK, 0, 1, obc);
1987
1988 if (list.size() == 0) {
1989 StringMaker msg = new StringMaker();
1990
1991 msg.append("No ExpandoValue exists with the key {");
1992
1993 msg.append("tableId=" + tableId);
1994
1995 msg.append(", ");
1996 msg.append("columnId=" + columnId);
1997
1998 msg.append(", ");
1999 msg.append("classNameId=" + classNameId);
2000
2001 msg.append(", ");
2002 msg.append("classPK=" + classPK);
2003
2004 msg.append(StringPool.CLOSE_CURLY_BRACE);
2005
2006 throw new NoSuchValueException(msg.toString());
2007 }
2008 else {
2009 return list.get(0);
2010 }
2011 }
2012
2013 public ExpandoValue findByT_C_C_C_Last(long tableId, long columnId,
2014 long classNameId, long classPK, OrderByComparator obc)
2015 throws NoSuchValueException, SystemException {
2016 int count = countByT_C_C_C(tableId, columnId, classNameId, classPK);
2017
2018 List<ExpandoValue> list = findByT_C_C_C(tableId, columnId, classNameId,
2019 classPK, count - 1, count, obc);
2020
2021 if (list.size() == 0) {
2022 StringMaker msg = new StringMaker();
2023
2024 msg.append("No ExpandoValue exists with the key {");
2025
2026 msg.append("tableId=" + tableId);
2027
2028 msg.append(", ");
2029 msg.append("columnId=" + columnId);
2030
2031 msg.append(", ");
2032 msg.append("classNameId=" + classNameId);
2033
2034 msg.append(", ");
2035 msg.append("classPK=" + classPK);
2036
2037 msg.append(StringPool.CLOSE_CURLY_BRACE);
2038
2039 throw new NoSuchValueException(msg.toString());
2040 }
2041 else {
2042 return list.get(0);
2043 }
2044 }
2045
2046 public ExpandoValue[] findByT_C_C_C_PrevAndNext(long valueId, long tableId,
2047 long columnId, long classNameId, long classPK, OrderByComparator obc)
2048 throws NoSuchValueException, SystemException {
2049 ExpandoValue expandoValue = findByPrimaryKey(valueId);
2050
2051 int count = countByT_C_C_C(tableId, columnId, classNameId, classPK);
2052
2053 Session session = null;
2054
2055 try {
2056 session = openSession();
2057
2058 StringMaker query = new StringMaker();
2059
2060 query.append(
2061 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2062
2063 query.append("tableId = ?");
2064
2065 query.append(" AND ");
2066
2067 query.append("columnId = ?");
2068
2069 query.append(" AND ");
2070
2071 query.append("classNameId = ?");
2072
2073 query.append(" AND ");
2074
2075 query.append("classPK = ?");
2076
2077 query.append(" ");
2078
2079 if (obc != null) {
2080 query.append("ORDER BY ");
2081 query.append(obc.getOrderBy());
2082 }
2083
2084 else {
2085 query.append("ORDER BY ");
2086
2087 query.append("tableId ASC, ");
2088 query.append("rowId ASC, ");
2089 query.append("columnId ASC");
2090 }
2091
2092 Query q = session.createQuery(query.toString());
2093
2094 int queryPos = 0;
2095
2096 q.setLong(queryPos++, tableId);
2097
2098 q.setLong(queryPos++, columnId);
2099
2100 q.setLong(queryPos++, classNameId);
2101
2102 q.setLong(queryPos++, classPK);
2103
2104 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2105 expandoValue);
2106
2107 ExpandoValue[] array = new ExpandoValueImpl[3];
2108
2109 array[0] = (ExpandoValue)objArray[0];
2110 array[1] = (ExpandoValue)objArray[1];
2111 array[2] = (ExpandoValue)objArray[2];
2112
2113 return array;
2114 }
2115 catch (Exception e) {
2116 throw HibernateUtil.processException(e);
2117 }
2118 finally {
2119 closeSession(session);
2120 }
2121 }
2122
2123 public List<ExpandoValue> findWithDynamicQuery(
2124 DynamicQueryInitializer queryInitializer) throws SystemException {
2125 Session session = null;
2126
2127 try {
2128 session = openSession();
2129
2130 DynamicQuery query = queryInitializer.initialize(session);
2131
2132 return query.list();
2133 }
2134 catch (Exception e) {
2135 throw HibernateUtil.processException(e);
2136 }
2137 finally {
2138 closeSession(session);
2139 }
2140 }
2141
2142 public List<ExpandoValue> findWithDynamicQuery(
2143 DynamicQueryInitializer queryInitializer, int begin, int end)
2144 throws SystemException {
2145 Session session = null;
2146
2147 try {
2148 session = openSession();
2149
2150 DynamicQuery query = queryInitializer.initialize(session);
2151
2152 query.setLimit(begin, end);
2153
2154 return query.list();
2155 }
2156 catch (Exception e) {
2157 throw HibernateUtil.processException(e);
2158 }
2159 finally {
2160 closeSession(session);
2161 }
2162 }
2163
2164 public List<ExpandoValue> findAll() throws SystemException {
2165 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2166 }
2167
2168 public List<ExpandoValue> findAll(int begin, int end)
2169 throws SystemException {
2170 return findAll(begin, end, null);
2171 }
2172
2173 public List<ExpandoValue> findAll(int begin, int end, OrderByComparator obc)
2174 throws SystemException {
2175 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2176 String finderClassName = ExpandoValue.class.getName();
2177 String finderMethodName = "findAll";
2178 String[] finderParams = new String[] {
2179 "java.lang.Integer", "java.lang.Integer",
2180 "com.liferay.portal.kernel.util.OrderByComparator"
2181 };
2182 Object[] finderArgs = new Object[] {
2183 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
2184 };
2185
2186 Object result = null;
2187
2188 if (finderClassNameCacheEnabled) {
2189 result = FinderCache.getResult(finderClassName, finderMethodName,
2190 finderParams, finderArgs, getSessionFactory());
2191 }
2192
2193 if (result == null) {
2194 Session session = null;
2195
2196 try {
2197 session = openSession();
2198
2199 StringMaker query = new StringMaker();
2200
2201 query.append(
2202 "FROM com.liferay.portlet.expando.model.ExpandoValue ");
2203
2204 if (obc != null) {
2205 query.append("ORDER BY ");
2206 query.append(obc.getOrderBy());
2207 }
2208
2209 else {
2210 query.append("ORDER BY ");
2211
2212 query.append("tableId ASC, ");
2213 query.append("rowId ASC, ");
2214 query.append("columnId ASC");
2215 }
2216
2217 Query q = session.createQuery(query.toString());
2218
2219 List<ExpandoValue> list = (List<ExpandoValue>)QueryUtil.list(q,
2220 getDialect(), begin, end);
2221
2222 if (obc == null) {
2223 Collections.sort(list);
2224 }
2225
2226 FinderCache.putResult(finderClassNameCacheEnabled,
2227 finderClassName, finderMethodName, finderParams,
2228 finderArgs, list);
2229
2230 return list;
2231 }
2232 catch (Exception e) {
2233 throw HibernateUtil.processException(e);
2234 }
2235 finally {
2236 closeSession(session);
2237 }
2238 }
2239 else {
2240 return (List<ExpandoValue>)result;
2241 }
2242 }
2243
2244 public void removeByTableId(long tableId) throws SystemException {
2245 for (ExpandoValue expandoValue : findByTableId(tableId)) {
2246 remove(expandoValue);
2247 }
2248 }
2249
2250 public void removeByColumnId(long columnId) throws SystemException {
2251 for (ExpandoValue expandoValue : findByColumnId(columnId)) {
2252 remove(expandoValue);
2253 }
2254 }
2255
2256 public void removeByRowId(long rowId) throws SystemException {
2257 for (ExpandoValue expandoValue : findByRowId(rowId)) {
2258 remove(expandoValue);
2259 }
2260 }
2261
2262 public void removeByT_R(long tableId, long rowId) throws SystemException {
2263 for (ExpandoValue expandoValue : findByT_R(tableId, rowId)) {
2264 remove(expandoValue);
2265 }
2266 }
2267
2268 public void removeByC_R(long columnId, long rowId)
2269 throws NoSuchValueException, SystemException {
2270 ExpandoValue expandoValue = findByC_R(columnId, rowId);
2271
2272 remove(expandoValue);
2273 }
2274
2275 public void removeByC_C(long classNameId, long classPK)
2276 throws SystemException {
2277 for (ExpandoValue expandoValue : findByC_C(classNameId, classPK)) {
2278 remove(expandoValue);
2279 }
2280 }
2281
2282 public void removeByT_C_R(long tableId, long columnId, long rowId)
2283 throws NoSuchValueException, SystemException {
2284 ExpandoValue expandoValue = findByT_C_R(tableId, columnId, rowId);
2285
2286 remove(expandoValue);
2287 }
2288
2289 public void removeByT_C_C_C(long tableId, long columnId, long classNameId,
2290 long classPK) throws SystemException {
2291 for (ExpandoValue expandoValue : findByT_C_C_C(tableId, columnId,
2292 classNameId, classPK)) {
2293 remove(expandoValue);
2294 }
2295 }
2296
2297 public void removeAll() throws SystemException {
2298 for (ExpandoValue expandoValue : findAll()) {
2299 remove(expandoValue);
2300 }
2301 }
2302
2303 public int countByTableId(long tableId) throws SystemException {
2304 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2305 String finderClassName = ExpandoValue.class.getName();
2306 String finderMethodName = "countByTableId";
2307 String[] finderParams = new String[] { Long.class.getName() };
2308 Object[] finderArgs = new Object[] { new Long(tableId) };
2309
2310 Object result = null;
2311
2312 if (finderClassNameCacheEnabled) {
2313 result = FinderCache.getResult(finderClassName, finderMethodName,
2314 finderParams, finderArgs, getSessionFactory());
2315 }
2316
2317 if (result == null) {
2318 Session session = null;
2319
2320 try {
2321 session = openSession();
2322
2323 StringMaker query = new StringMaker();
2324
2325 query.append("SELECT COUNT(*) ");
2326 query.append(
2327 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2328
2329 query.append("tableId = ?");
2330
2331 query.append(" ");
2332
2333 Query q = session.createQuery(query.toString());
2334
2335 int queryPos = 0;
2336
2337 q.setLong(queryPos++, tableId);
2338
2339 Long count = null;
2340
2341 Iterator<Long> itr = q.list().iterator();
2342
2343 if (itr.hasNext()) {
2344 count = itr.next();
2345 }
2346
2347 if (count == null) {
2348 count = new Long(0);
2349 }
2350
2351 FinderCache.putResult(finderClassNameCacheEnabled,
2352 finderClassName, finderMethodName, finderParams,
2353 finderArgs, count);
2354
2355 return count.intValue();
2356 }
2357 catch (Exception e) {
2358 throw HibernateUtil.processException(e);
2359 }
2360 finally {
2361 closeSession(session);
2362 }
2363 }
2364 else {
2365 return ((Long)result).intValue();
2366 }
2367 }
2368
2369 public int countByColumnId(long columnId) throws SystemException {
2370 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2371 String finderClassName = ExpandoValue.class.getName();
2372 String finderMethodName = "countByColumnId";
2373 String[] finderParams = new String[] { Long.class.getName() };
2374 Object[] finderArgs = new Object[] { new Long(columnId) };
2375
2376 Object result = null;
2377
2378 if (finderClassNameCacheEnabled) {
2379 result = FinderCache.getResult(finderClassName, finderMethodName,
2380 finderParams, finderArgs, getSessionFactory());
2381 }
2382
2383 if (result == null) {
2384 Session session = null;
2385
2386 try {
2387 session = openSession();
2388
2389 StringMaker query = new StringMaker();
2390
2391 query.append("SELECT COUNT(*) ");
2392 query.append(
2393 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2394
2395 query.append("columnId = ?");
2396
2397 query.append(" ");
2398
2399 Query q = session.createQuery(query.toString());
2400
2401 int queryPos = 0;
2402
2403 q.setLong(queryPos++, columnId);
2404
2405 Long count = null;
2406
2407 Iterator<Long> itr = q.list().iterator();
2408
2409 if (itr.hasNext()) {
2410 count = itr.next();
2411 }
2412
2413 if (count == null) {
2414 count = new Long(0);
2415 }
2416
2417 FinderCache.putResult(finderClassNameCacheEnabled,
2418 finderClassName, finderMethodName, finderParams,
2419 finderArgs, count);
2420
2421 return count.intValue();
2422 }
2423 catch (Exception e) {
2424 throw HibernateUtil.processException(e);
2425 }
2426 finally {
2427 closeSession(session);
2428 }
2429 }
2430 else {
2431 return ((Long)result).intValue();
2432 }
2433 }
2434
2435 public int countByRowId(long rowId) throws SystemException {
2436 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2437 String finderClassName = ExpandoValue.class.getName();
2438 String finderMethodName = "countByRowId";
2439 String[] finderParams = new String[] { Long.class.getName() };
2440 Object[] finderArgs = new Object[] { new Long(rowId) };
2441
2442 Object result = null;
2443
2444 if (finderClassNameCacheEnabled) {
2445 result = FinderCache.getResult(finderClassName, finderMethodName,
2446 finderParams, finderArgs, getSessionFactory());
2447 }
2448
2449 if (result == null) {
2450 Session session = null;
2451
2452 try {
2453 session = openSession();
2454
2455 StringMaker query = new StringMaker();
2456
2457 query.append("SELECT COUNT(*) ");
2458 query.append(
2459 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2460
2461 query.append("rowId = ?");
2462
2463 query.append(" ");
2464
2465 Query q = session.createQuery(query.toString());
2466
2467 int queryPos = 0;
2468
2469 q.setLong(queryPos++, rowId);
2470
2471 Long count = null;
2472
2473 Iterator<Long> itr = q.list().iterator();
2474
2475 if (itr.hasNext()) {
2476 count = itr.next();
2477 }
2478
2479 if (count == null) {
2480 count = new Long(0);
2481 }
2482
2483 FinderCache.putResult(finderClassNameCacheEnabled,
2484 finderClassName, finderMethodName, finderParams,
2485 finderArgs, count);
2486
2487 return count.intValue();
2488 }
2489 catch (Exception e) {
2490 throw HibernateUtil.processException(e);
2491 }
2492 finally {
2493 closeSession(session);
2494 }
2495 }
2496 else {
2497 return ((Long)result).intValue();
2498 }
2499 }
2500
2501 public int countByT_R(long tableId, long rowId) throws SystemException {
2502 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2503 String finderClassName = ExpandoValue.class.getName();
2504 String finderMethodName = "countByT_R";
2505 String[] finderParams = new String[] {
2506 Long.class.getName(), Long.class.getName()
2507 };
2508 Object[] finderArgs = new Object[] { new Long(tableId), new Long(rowId) };
2509
2510 Object result = null;
2511
2512 if (finderClassNameCacheEnabled) {
2513 result = FinderCache.getResult(finderClassName, finderMethodName,
2514 finderParams, finderArgs, getSessionFactory());
2515 }
2516
2517 if (result == null) {
2518 Session session = null;
2519
2520 try {
2521 session = openSession();
2522
2523 StringMaker query = new StringMaker();
2524
2525 query.append("SELECT COUNT(*) ");
2526 query.append(
2527 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2528
2529 query.append("tableId = ?");
2530
2531 query.append(" AND ");
2532
2533 query.append("rowId = ?");
2534
2535 query.append(" ");
2536
2537 Query q = session.createQuery(query.toString());
2538
2539 int queryPos = 0;
2540
2541 q.setLong(queryPos++, tableId);
2542
2543 q.setLong(queryPos++, rowId);
2544
2545 Long count = null;
2546
2547 Iterator<Long> itr = q.list().iterator();
2548
2549 if (itr.hasNext()) {
2550 count = itr.next();
2551 }
2552
2553 if (count == null) {
2554 count = new Long(0);
2555 }
2556
2557 FinderCache.putResult(finderClassNameCacheEnabled,
2558 finderClassName, finderMethodName, finderParams,
2559 finderArgs, count);
2560
2561 return count.intValue();
2562 }
2563 catch (Exception e) {
2564 throw HibernateUtil.processException(e);
2565 }
2566 finally {
2567 closeSession(session);
2568 }
2569 }
2570 else {
2571 return ((Long)result).intValue();
2572 }
2573 }
2574
2575 public int countByC_R(long columnId, long rowId) throws SystemException {
2576 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2577 String finderClassName = ExpandoValue.class.getName();
2578 String finderMethodName = "countByC_R";
2579 String[] finderParams = new String[] {
2580 Long.class.getName(), Long.class.getName()
2581 };
2582 Object[] finderArgs = new Object[] { new Long(columnId), new Long(rowId) };
2583
2584 Object result = null;
2585
2586 if (finderClassNameCacheEnabled) {
2587 result = FinderCache.getResult(finderClassName, finderMethodName,
2588 finderParams, finderArgs, getSessionFactory());
2589 }
2590
2591 if (result == null) {
2592 Session session = null;
2593
2594 try {
2595 session = openSession();
2596
2597 StringMaker query = new StringMaker();
2598
2599 query.append("SELECT COUNT(*) ");
2600 query.append(
2601 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2602
2603 query.append("columnId = ?");
2604
2605 query.append(" AND ");
2606
2607 query.append("rowId = ?");
2608
2609 query.append(" ");
2610
2611 Query q = session.createQuery(query.toString());
2612
2613 int queryPos = 0;
2614
2615 q.setLong(queryPos++, columnId);
2616
2617 q.setLong(queryPos++, rowId);
2618
2619 Long count = null;
2620
2621 Iterator<Long> itr = q.list().iterator();
2622
2623 if (itr.hasNext()) {
2624 count = itr.next();
2625 }
2626
2627 if (count == null) {
2628 count = new Long(0);
2629 }
2630
2631 FinderCache.putResult(finderClassNameCacheEnabled,
2632 finderClassName, finderMethodName, finderParams,
2633 finderArgs, count);
2634
2635 return count.intValue();
2636 }
2637 catch (Exception e) {
2638 throw HibernateUtil.processException(e);
2639 }
2640 finally {
2641 closeSession(session);
2642 }
2643 }
2644 else {
2645 return ((Long)result).intValue();
2646 }
2647 }
2648
2649 public int countByC_C(long classNameId, long classPK)
2650 throws SystemException {
2651 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2652 String finderClassName = ExpandoValue.class.getName();
2653 String finderMethodName = "countByC_C";
2654 String[] finderParams = new String[] {
2655 Long.class.getName(), Long.class.getName()
2656 };
2657 Object[] finderArgs = new Object[] {
2658 new Long(classNameId), new Long(classPK)
2659 };
2660
2661 Object result = null;
2662
2663 if (finderClassNameCacheEnabled) {
2664 result = FinderCache.getResult(finderClassName, finderMethodName,
2665 finderParams, finderArgs, getSessionFactory());
2666 }
2667
2668 if (result == null) {
2669 Session session = null;
2670
2671 try {
2672 session = openSession();
2673
2674 StringMaker query = new StringMaker();
2675
2676 query.append("SELECT COUNT(*) ");
2677 query.append(
2678 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2679
2680 query.append("classNameId = ?");
2681
2682 query.append(" AND ");
2683
2684 query.append("classPK = ?");
2685
2686 query.append(" ");
2687
2688 Query q = session.createQuery(query.toString());
2689
2690 int queryPos = 0;
2691
2692 q.setLong(queryPos++, classNameId);
2693
2694 q.setLong(queryPos++, classPK);
2695
2696 Long count = null;
2697
2698 Iterator<Long> itr = q.list().iterator();
2699
2700 if (itr.hasNext()) {
2701 count = itr.next();
2702 }
2703
2704 if (count == null) {
2705 count = new Long(0);
2706 }
2707
2708 FinderCache.putResult(finderClassNameCacheEnabled,
2709 finderClassName, finderMethodName, finderParams,
2710 finderArgs, count);
2711
2712 return count.intValue();
2713 }
2714 catch (Exception e) {
2715 throw HibernateUtil.processException(e);
2716 }
2717 finally {
2718 closeSession(session);
2719 }
2720 }
2721 else {
2722 return ((Long)result).intValue();
2723 }
2724 }
2725
2726 public int countByT_C_R(long tableId, long columnId, long rowId)
2727 throws SystemException {
2728 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2729 String finderClassName = ExpandoValue.class.getName();
2730 String finderMethodName = "countByT_C_R";
2731 String[] finderParams = new String[] {
2732 Long.class.getName(), Long.class.getName(), Long.class.getName()
2733 };
2734 Object[] finderArgs = new Object[] {
2735 new Long(tableId), new Long(columnId), new Long(rowId)
2736 };
2737
2738 Object result = null;
2739
2740 if (finderClassNameCacheEnabled) {
2741 result = FinderCache.getResult(finderClassName, finderMethodName,
2742 finderParams, finderArgs, getSessionFactory());
2743 }
2744
2745 if (result == null) {
2746 Session session = null;
2747
2748 try {
2749 session = openSession();
2750
2751 StringMaker query = new StringMaker();
2752
2753 query.append("SELECT COUNT(*) ");
2754 query.append(
2755 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2756
2757 query.append("tableId = ?");
2758
2759 query.append(" AND ");
2760
2761 query.append("columnId = ?");
2762
2763 query.append(" AND ");
2764
2765 query.append("rowId = ?");
2766
2767 query.append(" ");
2768
2769 Query q = session.createQuery(query.toString());
2770
2771 int queryPos = 0;
2772
2773 q.setLong(queryPos++, tableId);
2774
2775 q.setLong(queryPos++, columnId);
2776
2777 q.setLong(queryPos++, rowId);
2778
2779 Long count = null;
2780
2781 Iterator<Long> itr = q.list().iterator();
2782
2783 if (itr.hasNext()) {
2784 count = itr.next();
2785 }
2786
2787 if (count == null) {
2788 count = new Long(0);
2789 }
2790
2791 FinderCache.putResult(finderClassNameCacheEnabled,
2792 finderClassName, finderMethodName, finderParams,
2793 finderArgs, count);
2794
2795 return count.intValue();
2796 }
2797 catch (Exception e) {
2798 throw HibernateUtil.processException(e);
2799 }
2800 finally {
2801 closeSession(session);
2802 }
2803 }
2804 else {
2805 return ((Long)result).intValue();
2806 }
2807 }
2808
2809 public int countByT_C_C_C(long tableId, long columnId, long classNameId,
2810 long classPK) throws SystemException {
2811 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2812 String finderClassName = ExpandoValue.class.getName();
2813 String finderMethodName = "countByT_C_C_C";
2814 String[] finderParams = new String[] {
2815 Long.class.getName(), Long.class.getName(), Long.class.getName(),
2816 Long.class.getName()
2817 };
2818 Object[] finderArgs = new Object[] {
2819 new Long(tableId), new Long(columnId), new Long(classNameId),
2820 new Long(classPK)
2821 };
2822
2823 Object result = null;
2824
2825 if (finderClassNameCacheEnabled) {
2826 result = FinderCache.getResult(finderClassName, finderMethodName,
2827 finderParams, finderArgs, getSessionFactory());
2828 }
2829
2830 if (result == null) {
2831 Session session = null;
2832
2833 try {
2834 session = openSession();
2835
2836 StringMaker query = new StringMaker();
2837
2838 query.append("SELECT COUNT(*) ");
2839 query.append(
2840 "FROM com.liferay.portlet.expando.model.ExpandoValue WHERE ");
2841
2842 query.append("tableId = ?");
2843
2844 query.append(" AND ");
2845
2846 query.append("columnId = ?");
2847
2848 query.append(" AND ");
2849
2850 query.append("classNameId = ?");
2851
2852 query.append(" AND ");
2853
2854 query.append("classPK = ?");
2855
2856 query.append(" ");
2857
2858 Query q = session.createQuery(query.toString());
2859
2860 int queryPos = 0;
2861
2862 q.setLong(queryPos++, tableId);
2863
2864 q.setLong(queryPos++, columnId);
2865
2866 q.setLong(queryPos++, classNameId);
2867
2868 q.setLong(queryPos++, classPK);
2869
2870 Long count = null;
2871
2872 Iterator<Long> itr = q.list().iterator();
2873
2874 if (itr.hasNext()) {
2875 count = itr.next();
2876 }
2877
2878 if (count == null) {
2879 count = new Long(0);
2880 }
2881
2882 FinderCache.putResult(finderClassNameCacheEnabled,
2883 finderClassName, finderMethodName, finderParams,
2884 finderArgs, count);
2885
2886 return count.intValue();
2887 }
2888 catch (Exception e) {
2889 throw HibernateUtil.processException(e);
2890 }
2891 finally {
2892 closeSession(session);
2893 }
2894 }
2895 else {
2896 return ((Long)result).intValue();
2897 }
2898 }
2899
2900 public int countAll() throws SystemException {
2901 boolean finderClassNameCacheEnabled = ExpandoValueModelImpl.CACHE_ENABLED;
2902 String finderClassName = ExpandoValue.class.getName();
2903 String finderMethodName = "countAll";
2904 String[] finderParams = new String[] { };
2905 Object[] finderArgs = new Object[] { };
2906
2907 Object result = null;
2908
2909 if (finderClassNameCacheEnabled) {
2910 result = FinderCache.getResult(finderClassName, finderMethodName,
2911 finderParams, finderArgs, getSessionFactory());
2912 }
2913
2914 if (result == null) {
2915 Session session = null;
2916
2917 try {
2918 session = openSession();
2919
2920 Query q = session.createQuery(
2921 "SELECT COUNT(*) FROM com.liferay.portlet.expando.model.ExpandoValue");
2922
2923 Long count = null;
2924
2925 Iterator<Long> itr = q.list().iterator();
2926
2927 if (itr.hasNext()) {
2928 count = itr.next();
2929 }
2930
2931 if (count == null) {
2932 count = new Long(0);
2933 }
2934
2935 FinderCache.putResult(finderClassNameCacheEnabled,
2936 finderClassName, finderMethodName, finderParams,
2937 finderArgs, count);
2938
2939 return count.intValue();
2940 }
2941 catch (Exception e) {
2942 throw HibernateUtil.processException(e);
2943 }
2944 finally {
2945 closeSession(session);
2946 }
2947 }
2948 else {
2949 return ((Long)result).intValue();
2950 }
2951 }
2952
2953 protected void initDao() {
2954 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2955 PropsUtil.get(
2956 "value.object.listener.com.liferay.portlet.expando.model.ExpandoValue")));
2957
2958 if (listenerClassNames.length > 0) {
2959 try {
2960 List<ModelListener> listeners = new ArrayList<ModelListener>();
2961
2962 for (String listenerClassName : listenerClassNames) {
2963 listeners.add((ModelListener)Class.forName(
2964 listenerClassName).newInstance());
2965 }
2966
2967 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2968 }
2969 catch (Exception e) {
2970 _log.error(e);
2971 }
2972 }
2973 }
2974
2975 private static Log _log = LogFactory.getLog(ExpandoValuePersistenceImpl.class);
2976 private ModelListener[] _listeners;
2977}