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