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