1
22
23 package com.liferay.portlet.expando.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.model.ModelListener;
43 import com.liferay.portal.service.persistence.BatchSessionUtil;
44 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45
46 import com.liferay.portlet.expando.NoSuchValueException;
47 import com.liferay.portlet.expando.model.ExpandoValue;
48 import com.liferay.portlet.expando.model.impl.ExpandoValueImpl;
49 import com.liferay.portlet.expando.model.impl.ExpandoValueModelImpl;
50
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.List;
54
55
61 public class ExpandoValuePersistenceImpl extends BasePersistenceImpl
62 implements ExpandoValuePersistence {
63 public static final String FINDER_CLASS_NAME_ENTITY = ExpandoValueImpl.class.getName();
64 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
65 ".List";
66 public static final FinderPath FINDER_PATH_FIND_BY_TABLEID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
67 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
68 "findByTableId", new String[] { Long.class.getName() });
69 public static final FinderPath FINDER_PATH_FIND_BY_OBC_TABLEID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
70 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
71 "findByTableId",
72 new String[] {
73 Long.class.getName(),
74
75 "java.lang.Integer", "java.lang.Integer",
76 "com.liferay.portal.kernel.util.OrderByComparator"
77 });
78 public static final FinderPath FINDER_PATH_COUNT_BY_TABLEID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
79 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80 "countByTableId", new String[] { Long.class.getName() });
81 public static final FinderPath FINDER_PATH_FIND_BY_COLUMNID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
82 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
83 "findByColumnId", new String[] { Long.class.getName() });
84 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COLUMNID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
85 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
86 "findByColumnId",
87 new String[] {
88 Long.class.getName(),
89
90 "java.lang.Integer", "java.lang.Integer",
91 "com.liferay.portal.kernel.util.OrderByComparator"
92 });
93 public static final FinderPath FINDER_PATH_COUNT_BY_COLUMNID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
94 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
95 "countByColumnId", new String[] { Long.class.getName() });
96 public static final FinderPath FINDER_PATH_FIND_BY_ROWID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
97 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
98 "findByRowId", new String[] { Long.class.getName() });
99 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ROWID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
100 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findByRowId",
102 new String[] {
103 Long.class.getName(),
104
105 "java.lang.Integer", "java.lang.Integer",
106 "com.liferay.portal.kernel.util.OrderByComparator"
107 });
108 public static final FinderPath FINDER_PATH_COUNT_BY_ROWID = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
109 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110 "countByRowId", new String[] { Long.class.getName() });
111 public static final FinderPath FINDER_PATH_FIND_BY_T_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
112 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "findByT_C",
114 new String[] { Long.class.getName(), Long.class.getName() });
115 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
116 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "findByT_C",
118 new String[] {
119 Long.class.getName(), Long.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_COUNT_BY_T_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
125 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126 "countByT_C",
127 new String[] { Long.class.getName(), Long.class.getName() });
128 public static final FinderPath FINDER_PATH_FIND_BY_T_CPK = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
129 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130 "findByT_CPK",
131 new String[] { Long.class.getName(), Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_CPK = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
133 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "findByT_CPK",
135 new String[] {
136 Long.class.getName(), Long.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_T_CPK = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
142 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
143 "countByT_CPK",
144 new String[] { Long.class.getName(), Long.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_BY_T_R = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
146 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147 "findByT_R",
148 new String[] { Long.class.getName(), Long.class.getName() });
149 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_R = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
150 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
151 "findByT_R",
152 new String[] {
153 Long.class.getName(), Long.class.getName(),
154
155 "java.lang.Integer", "java.lang.Integer",
156 "com.liferay.portal.kernel.util.OrderByComparator"
157 });
158 public static final FinderPath FINDER_PATH_COUNT_BY_T_R = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
159 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160 "countByT_R",
161 new String[] { Long.class.getName(), Long.class.getName() });
162 public static final FinderPath FINDER_PATH_FETCH_BY_C_R = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
163 ExpandoValueModelImpl.FINDER_CACHE_ENABLED,
164 FINDER_CLASS_NAME_ENTITY, "fetchByC_R",
165 new String[] { Long.class.getName(), Long.class.getName() });
166 public static final FinderPath FINDER_PATH_COUNT_BY_C_R = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
167 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
168 "countByC_R",
169 new String[] { Long.class.getName(), Long.class.getName() });
170 public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
171 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
172 "findByC_C",
173 new String[] { Long.class.getName(), Long.class.getName() });
174 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
175 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
176 "findByC_C",
177 new String[] {
178 Long.class.getName(), Long.class.getName(),
179
180 "java.lang.Integer", "java.lang.Integer",
181 "com.liferay.portal.kernel.util.OrderByComparator"
182 });
183 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
184 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
185 "countByC_C",
186 new String[] { Long.class.getName(), Long.class.getName() });
187 public static final FinderPath FINDER_PATH_FETCH_BY_T_C_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
188 ExpandoValueModelImpl.FINDER_CACHE_ENABLED,
189 FINDER_CLASS_NAME_ENTITY, "fetchByT_C_C",
190 new String[] {
191 Long.class.getName(), Long.class.getName(), Long.class.getName()
192 });
193 public static final FinderPath FINDER_PATH_COUNT_BY_T_C_C = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
194 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
195 "countByT_C_C",
196 new String[] {
197 Long.class.getName(), Long.class.getName(), Long.class.getName()
198 });
199 public static final FinderPath FINDER_PATH_FIND_BY_T_C_D = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
200 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
201 "findByT_C_D",
202 new String[] {
203 Long.class.getName(), Long.class.getName(),
204 String.class.getName()
205 });
206 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_C_D = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
207 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208 "findByT_C_D",
209 new String[] {
210 Long.class.getName(), Long.class.getName(),
211 String.class.getName(),
212
213 "java.lang.Integer", "java.lang.Integer",
214 "com.liferay.portal.kernel.util.OrderByComparator"
215 });
216 public static final FinderPath FINDER_PATH_COUNT_BY_T_C_D = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
217 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
218 "countByT_C_D",
219 new String[] {
220 Long.class.getName(), Long.class.getName(),
221 String.class.getName()
222 });
223 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
224 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
225 "findAll", new String[0]);
226 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
227 ExpandoValueModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
228 "countAll", new String[0]);
229
230 public void cacheResult(ExpandoValue expandoValue) {
231 EntityCacheUtil.putResult(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
232 ExpandoValueImpl.class, expandoValue.getPrimaryKey(), expandoValue);
233
234 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R,
235 new Object[] {
236 new Long(expandoValue.getColumnId()),
237 new Long(expandoValue.getRowId())
238 }, expandoValue);
239
240 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C_C,
241 new Object[] {
242 new Long(expandoValue.getTableId()),
243 new Long(expandoValue.getColumnId()),
244 new Long(expandoValue.getClassPK())
245 }, expandoValue);
246 }
247
248 public void cacheResult(List<ExpandoValue> expandoValues) {
249 for (ExpandoValue expandoValue : expandoValues) {
250 if (EntityCacheUtil.getResult(
251 ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
252 ExpandoValueImpl.class, expandoValue.getPrimaryKey(),
253 this) == null) {
254 cacheResult(expandoValue);
255 }
256 }
257 }
258
259 public void clearCache() {
260 CacheRegistry.clear(ExpandoValueImpl.class.getName());
261 EntityCacheUtil.clearCache(ExpandoValueImpl.class.getName());
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264 }
265
266 public ExpandoValue create(long valueId) {
267 ExpandoValue expandoValue = new ExpandoValueImpl();
268
269 expandoValue.setNew(true);
270 expandoValue.setPrimaryKey(valueId);
271
272 return expandoValue;
273 }
274
275 public ExpandoValue remove(long valueId)
276 throws NoSuchValueException, SystemException {
277 Session session = null;
278
279 try {
280 session = openSession();
281
282 ExpandoValue expandoValue = (ExpandoValue)session.get(ExpandoValueImpl.class,
283 new Long(valueId));
284
285 if (expandoValue == null) {
286 if (_log.isWarnEnabled()) {
287 _log.warn("No ExpandoValue exists with the primary key " +
288 valueId);
289 }
290
291 throw new NoSuchValueException(
292 "No ExpandoValue exists with the primary key " + valueId);
293 }
294
295 return remove(expandoValue);
296 }
297 catch (NoSuchValueException nsee) {
298 throw nsee;
299 }
300 catch (Exception e) {
301 throw processException(e);
302 }
303 finally {
304 closeSession(session);
305 }
306 }
307
308 public ExpandoValue remove(ExpandoValue expandoValue)
309 throws SystemException {
310 for (ModelListener<ExpandoValue> listener : listeners) {
311 listener.onBeforeRemove(expandoValue);
312 }
313
314 expandoValue = removeImpl(expandoValue);
315
316 for (ModelListener<ExpandoValue> listener : listeners) {
317 listener.onAfterRemove(expandoValue);
318 }
319
320 return expandoValue;
321 }
322
323 protected ExpandoValue removeImpl(ExpandoValue expandoValue)
324 throws SystemException {
325 Session session = null;
326
327 try {
328 session = openSession();
329
330 if (expandoValue.isCachedModel() || BatchSessionUtil.isEnabled()) {
331 Object staleObject = session.get(ExpandoValueImpl.class,
332 expandoValue.getPrimaryKeyObj());
333
334 if (staleObject != null) {
335 session.evict(staleObject);
336 }
337 }
338
339 session.delete(expandoValue);
340
341 session.flush();
342 }
343 catch (Exception e) {
344 throw processException(e);
345 }
346 finally {
347 closeSession(session);
348 }
349
350 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
351
352 ExpandoValueModelImpl expandoValueModelImpl = (ExpandoValueModelImpl)expandoValue;
353
354 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_R,
355 new Object[] {
356 new Long(expandoValueModelImpl.getOriginalColumnId()),
357 new Long(expandoValueModelImpl.getOriginalRowId())
358 });
359
360 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_C_C,
361 new Object[] {
362 new Long(expandoValueModelImpl.getOriginalTableId()),
363 new Long(expandoValueModelImpl.getOriginalColumnId()),
364 new Long(expandoValueModelImpl.getOriginalClassPK())
365 });
366
367 EntityCacheUtil.removeResult(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
368 ExpandoValueImpl.class, expandoValue.getPrimaryKey());
369
370 return expandoValue;
371 }
372
373
376 public ExpandoValue update(ExpandoValue expandoValue)
377 throws SystemException {
378 if (_log.isWarnEnabled()) {
379 _log.warn(
380 "Using the deprecated update(ExpandoValue expandoValue) method. Use update(ExpandoValue expandoValue, boolean merge) instead.");
381 }
382
383 return update(expandoValue, false);
384 }
385
386
399 public ExpandoValue update(ExpandoValue expandoValue, boolean merge)
400 throws SystemException {
401 boolean isNew = expandoValue.isNew();
402
403 for (ModelListener<ExpandoValue> listener : listeners) {
404 if (isNew) {
405 listener.onBeforeCreate(expandoValue);
406 }
407 else {
408 listener.onBeforeUpdate(expandoValue);
409 }
410 }
411
412 expandoValue = updateImpl(expandoValue, merge);
413
414 for (ModelListener<ExpandoValue> listener : listeners) {
415 if (isNew) {
416 listener.onAfterCreate(expandoValue);
417 }
418 else {
419 listener.onAfterUpdate(expandoValue);
420 }
421 }
422
423 return expandoValue;
424 }
425
426 public ExpandoValue updateImpl(
427 com.liferay.portlet.expando.model.ExpandoValue expandoValue,
428 boolean merge) throws SystemException {
429 boolean isNew = expandoValue.isNew();
430
431 ExpandoValueModelImpl expandoValueModelImpl = (ExpandoValueModelImpl)expandoValue;
432
433 Session session = null;
434
435 try {
436 session = openSession();
437
438 BatchSessionUtil.update(session, expandoValue, merge);
439
440 expandoValue.setNew(false);
441 }
442 catch (Exception e) {
443 throw processException(e);
444 }
445 finally {
446 closeSession(session);
447 }
448
449 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
450
451 EntityCacheUtil.putResult(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
452 ExpandoValueImpl.class, expandoValue.getPrimaryKey(), expandoValue);
453
454 if (!isNew &&
455 ((expandoValue.getColumnId() != expandoValueModelImpl.getOriginalColumnId()) ||
456 (expandoValue.getRowId() != expandoValueModelImpl.getOriginalRowId()))) {
457 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_R,
458 new Object[] {
459 new Long(expandoValueModelImpl.getOriginalColumnId()),
460 new Long(expandoValueModelImpl.getOriginalRowId())
461 });
462 }
463
464 if (isNew ||
465 ((expandoValue.getColumnId() != expandoValueModelImpl.getOriginalColumnId()) ||
466 (expandoValue.getRowId() != expandoValueModelImpl.getOriginalRowId()))) {
467 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R,
468 new Object[] {
469 new Long(expandoValue.getColumnId()),
470 new Long(expandoValue.getRowId())
471 }, expandoValue);
472 }
473
474 if (!isNew &&
475 ((expandoValue.getTableId() != expandoValueModelImpl.getOriginalTableId()) ||
476 (expandoValue.getColumnId() != expandoValueModelImpl.getOriginalColumnId()) ||
477 (expandoValue.getClassPK() != expandoValueModelImpl.getOriginalClassPK()))) {
478 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_C_C,
479 new Object[] {
480 new Long(expandoValueModelImpl.getOriginalTableId()),
481 new Long(expandoValueModelImpl.getOriginalColumnId()),
482 new Long(expandoValueModelImpl.getOriginalClassPK())
483 });
484 }
485
486 if (isNew ||
487 ((expandoValue.getTableId() != expandoValueModelImpl.getOriginalTableId()) ||
488 (expandoValue.getColumnId() != expandoValueModelImpl.getOriginalColumnId()) ||
489 (expandoValue.getClassPK() != expandoValueModelImpl.getOriginalClassPK()))) {
490 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C_C,
491 new Object[] {
492 new Long(expandoValue.getTableId()),
493 new Long(expandoValue.getColumnId()),
494 new Long(expandoValue.getClassPK())
495 }, expandoValue);
496 }
497
498 return expandoValue;
499 }
500
501 public ExpandoValue findByPrimaryKey(long valueId)
502 throws NoSuchValueException, SystemException {
503 ExpandoValue expandoValue = fetchByPrimaryKey(valueId);
504
505 if (expandoValue == null) {
506 if (_log.isWarnEnabled()) {
507 _log.warn("No ExpandoValue exists with the primary key " +
508 valueId);
509 }
510
511 throw new NoSuchValueException(
512 "No ExpandoValue exists with the primary key " + valueId);
513 }
514
515 return expandoValue;
516 }
517
518 public ExpandoValue fetchByPrimaryKey(long valueId)
519 throws SystemException {
520 ExpandoValue expandoValue = (ExpandoValue)EntityCacheUtil.getResult(ExpandoValueModelImpl.ENTITY_CACHE_ENABLED,
521 ExpandoValueImpl.class, valueId, this);
522
523 if (expandoValue == null) {
524 Session session = null;
525
526 try {
527 session = openSession();
528
529 expandoValue = (ExpandoValue)session.get(ExpandoValueImpl.class,
530 new Long(valueId));
531 }
532 catch (Exception e) {
533 throw processException(e);
534 }
535 finally {
536 if (expandoValue != null) {
537 cacheResult(expandoValue);
538 }
539
540 closeSession(session);
541 }
542 }
543
544 return expandoValue;
545 }
546
547 public List<ExpandoValue> findByTableId(long tableId)
548 throws SystemException {
549 Object[] finderArgs = new Object[] { new Long(tableId) };
550
551 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TABLEID,
552 finderArgs, this);
553
554 if (list == null) {
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 StringBuilder query = new StringBuilder();
561
562 query.append(
563 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
564
565 query.append("expandoValue.tableId = ?");
566
567 query.append(" ");
568
569 query.append("ORDER BY ");
570
571 query.append("expandoValue.tableId ASC, ");
572 query.append("expandoValue.rowId ASC, ");
573 query.append("expandoValue.columnId ASC");
574
575 Query q = session.createQuery(query.toString());
576
577 QueryPos qPos = QueryPos.getInstance(q);
578
579 qPos.add(tableId);
580
581 list = q.list();
582 }
583 catch (Exception e) {
584 throw processException(e);
585 }
586 finally {
587 if (list == null) {
588 list = new ArrayList<ExpandoValue>();
589 }
590
591 cacheResult(list);
592
593 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TABLEID,
594 finderArgs, list);
595
596 closeSession(session);
597 }
598 }
599
600 return list;
601 }
602
603 public List<ExpandoValue> findByTableId(long tableId, int start, int end)
604 throws SystemException {
605 return findByTableId(tableId, start, end, null);
606 }
607
608 public List<ExpandoValue> findByTableId(long tableId, int start, int end,
609 OrderByComparator obc) throws SystemException {
610 Object[] finderArgs = new Object[] {
611 new Long(tableId),
612
613 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
614 };
615
616 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_TABLEID,
617 finderArgs, this);
618
619 if (list == null) {
620 Session session = null;
621
622 try {
623 session = openSession();
624
625 StringBuilder query = new StringBuilder();
626
627 query.append(
628 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
629
630 query.append("expandoValue.tableId = ?");
631
632 query.append(" ");
633
634 if (obc != null) {
635 query.append("ORDER BY ");
636
637 String[] orderByFields = obc.getOrderByFields();
638
639 for (int i = 0; i < orderByFields.length; i++) {
640 query.append("expandoValue.");
641 query.append(orderByFields[i]);
642
643 if (obc.isAscending()) {
644 query.append(" ASC");
645 }
646 else {
647 query.append(" DESC");
648 }
649
650 if ((i + 1) < orderByFields.length) {
651 query.append(", ");
652 }
653 }
654 }
655
656 else {
657 query.append("ORDER BY ");
658
659 query.append("expandoValue.tableId ASC, ");
660 query.append("expandoValue.rowId ASC, ");
661 query.append("expandoValue.columnId ASC");
662 }
663
664 Query q = session.createQuery(query.toString());
665
666 QueryPos qPos = QueryPos.getInstance(q);
667
668 qPos.add(tableId);
669
670 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
671 start, end);
672 }
673 catch (Exception e) {
674 throw processException(e);
675 }
676 finally {
677 if (list == null) {
678 list = new ArrayList<ExpandoValue>();
679 }
680
681 cacheResult(list);
682
683 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_TABLEID,
684 finderArgs, list);
685
686 closeSession(session);
687 }
688 }
689
690 return list;
691 }
692
693 public ExpandoValue findByTableId_First(long tableId, OrderByComparator obc)
694 throws NoSuchValueException, SystemException {
695 List<ExpandoValue> list = findByTableId(tableId, 0, 1, obc);
696
697 if (list.isEmpty()) {
698 StringBuilder msg = new StringBuilder();
699
700 msg.append("No ExpandoValue exists with the key {");
701
702 msg.append("tableId=" + tableId);
703
704 msg.append(StringPool.CLOSE_CURLY_BRACE);
705
706 throw new NoSuchValueException(msg.toString());
707 }
708 else {
709 return list.get(0);
710 }
711 }
712
713 public ExpandoValue findByTableId_Last(long tableId, OrderByComparator obc)
714 throws NoSuchValueException, SystemException {
715 int count = countByTableId(tableId);
716
717 List<ExpandoValue> list = findByTableId(tableId, count - 1, count, obc);
718
719 if (list.isEmpty()) {
720 StringBuilder msg = new StringBuilder();
721
722 msg.append("No ExpandoValue exists with the key {");
723
724 msg.append("tableId=" + tableId);
725
726 msg.append(StringPool.CLOSE_CURLY_BRACE);
727
728 throw new NoSuchValueException(msg.toString());
729 }
730 else {
731 return list.get(0);
732 }
733 }
734
735 public ExpandoValue[] findByTableId_PrevAndNext(long valueId, long tableId,
736 OrderByComparator obc) throws NoSuchValueException, SystemException {
737 ExpandoValue expandoValue = findByPrimaryKey(valueId);
738
739 int count = countByTableId(tableId);
740
741 Session session = null;
742
743 try {
744 session = openSession();
745
746 StringBuilder query = new StringBuilder();
747
748 query.append(
749 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
750
751 query.append("expandoValue.tableId = ?");
752
753 query.append(" ");
754
755 if (obc != null) {
756 query.append("ORDER BY ");
757
758 String[] orderByFields = obc.getOrderByFields();
759
760 for (int i = 0; i < orderByFields.length; i++) {
761 query.append("expandoValue.");
762 query.append(orderByFields[i]);
763
764 if (obc.isAscending()) {
765 query.append(" ASC");
766 }
767 else {
768 query.append(" DESC");
769 }
770
771 if ((i + 1) < orderByFields.length) {
772 query.append(", ");
773 }
774 }
775 }
776
777 else {
778 query.append("ORDER BY ");
779
780 query.append("expandoValue.tableId ASC, ");
781 query.append("expandoValue.rowId ASC, ");
782 query.append("expandoValue.columnId ASC");
783 }
784
785 Query q = session.createQuery(query.toString());
786
787 QueryPos qPos = QueryPos.getInstance(q);
788
789 qPos.add(tableId);
790
791 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
792 expandoValue);
793
794 ExpandoValue[] array = new ExpandoValueImpl[3];
795
796 array[0] = (ExpandoValue)objArray[0];
797 array[1] = (ExpandoValue)objArray[1];
798 array[2] = (ExpandoValue)objArray[2];
799
800 return array;
801 }
802 catch (Exception e) {
803 throw processException(e);
804 }
805 finally {
806 closeSession(session);
807 }
808 }
809
810 public List<ExpandoValue> findByColumnId(long columnId)
811 throws SystemException {
812 Object[] finderArgs = new Object[] { new Long(columnId) };
813
814 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COLUMNID,
815 finderArgs, this);
816
817 if (list == null) {
818 Session session = null;
819
820 try {
821 session = openSession();
822
823 StringBuilder query = new StringBuilder();
824
825 query.append(
826 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
827
828 query.append("expandoValue.columnId = ?");
829
830 query.append(" ");
831
832 query.append("ORDER BY ");
833
834 query.append("expandoValue.tableId ASC, ");
835 query.append("expandoValue.rowId ASC, ");
836 query.append("expandoValue.columnId ASC");
837
838 Query q = session.createQuery(query.toString());
839
840 QueryPos qPos = QueryPos.getInstance(q);
841
842 qPos.add(columnId);
843
844 list = q.list();
845 }
846 catch (Exception e) {
847 throw processException(e);
848 }
849 finally {
850 if (list == null) {
851 list = new ArrayList<ExpandoValue>();
852 }
853
854 cacheResult(list);
855
856 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COLUMNID,
857 finderArgs, list);
858
859 closeSession(session);
860 }
861 }
862
863 return list;
864 }
865
866 public List<ExpandoValue> findByColumnId(long columnId, int start, int end)
867 throws SystemException {
868 return findByColumnId(columnId, start, end, null);
869 }
870
871 public List<ExpandoValue> findByColumnId(long columnId, int start, int end,
872 OrderByComparator obc) throws SystemException {
873 Object[] finderArgs = new Object[] {
874 new Long(columnId),
875
876 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
877 };
878
879 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COLUMNID,
880 finderArgs, this);
881
882 if (list == null) {
883 Session session = null;
884
885 try {
886 session = openSession();
887
888 StringBuilder query = new StringBuilder();
889
890 query.append(
891 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
892
893 query.append("expandoValue.columnId = ?");
894
895 query.append(" ");
896
897 if (obc != null) {
898 query.append("ORDER BY ");
899
900 String[] orderByFields = obc.getOrderByFields();
901
902 for (int i = 0; i < orderByFields.length; i++) {
903 query.append("expandoValue.");
904 query.append(orderByFields[i]);
905
906 if (obc.isAscending()) {
907 query.append(" ASC");
908 }
909 else {
910 query.append(" DESC");
911 }
912
913 if ((i + 1) < orderByFields.length) {
914 query.append(", ");
915 }
916 }
917 }
918
919 else {
920 query.append("ORDER BY ");
921
922 query.append("expandoValue.tableId ASC, ");
923 query.append("expandoValue.rowId ASC, ");
924 query.append("expandoValue.columnId ASC");
925 }
926
927 Query q = session.createQuery(query.toString());
928
929 QueryPos qPos = QueryPos.getInstance(q);
930
931 qPos.add(columnId);
932
933 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
934 start, end);
935 }
936 catch (Exception e) {
937 throw processException(e);
938 }
939 finally {
940 if (list == null) {
941 list = new ArrayList<ExpandoValue>();
942 }
943
944 cacheResult(list);
945
946 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COLUMNID,
947 finderArgs, list);
948
949 closeSession(session);
950 }
951 }
952
953 return list;
954 }
955
956 public ExpandoValue findByColumnId_First(long columnId,
957 OrderByComparator obc) throws NoSuchValueException, SystemException {
958 List<ExpandoValue> list = findByColumnId(columnId, 0, 1, obc);
959
960 if (list.isEmpty()) {
961 StringBuilder msg = new StringBuilder();
962
963 msg.append("No ExpandoValue exists with the key {");
964
965 msg.append("columnId=" + columnId);
966
967 msg.append(StringPool.CLOSE_CURLY_BRACE);
968
969 throw new NoSuchValueException(msg.toString());
970 }
971 else {
972 return list.get(0);
973 }
974 }
975
976 public ExpandoValue findByColumnId_Last(long columnId, OrderByComparator obc)
977 throws NoSuchValueException, SystemException {
978 int count = countByColumnId(columnId);
979
980 List<ExpandoValue> list = findByColumnId(columnId, count - 1, count, obc);
981
982 if (list.isEmpty()) {
983 StringBuilder msg = new StringBuilder();
984
985 msg.append("No ExpandoValue exists with the key {");
986
987 msg.append("columnId=" + columnId);
988
989 msg.append(StringPool.CLOSE_CURLY_BRACE);
990
991 throw new NoSuchValueException(msg.toString());
992 }
993 else {
994 return list.get(0);
995 }
996 }
997
998 public ExpandoValue[] findByColumnId_PrevAndNext(long valueId,
999 long columnId, OrderByComparator obc)
1000 throws NoSuchValueException, SystemException {
1001 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1002
1003 int count = countByColumnId(columnId);
1004
1005 Session session = null;
1006
1007 try {
1008 session = openSession();
1009
1010 StringBuilder query = new StringBuilder();
1011
1012 query.append(
1013 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1014
1015 query.append("expandoValue.columnId = ?");
1016
1017 query.append(" ");
1018
1019 if (obc != null) {
1020 query.append("ORDER BY ");
1021
1022 String[] orderByFields = obc.getOrderByFields();
1023
1024 for (int i = 0; i < orderByFields.length; i++) {
1025 query.append("expandoValue.");
1026 query.append(orderByFields[i]);
1027
1028 if (obc.isAscending()) {
1029 query.append(" ASC");
1030 }
1031 else {
1032 query.append(" DESC");
1033 }
1034
1035 if ((i + 1) < orderByFields.length) {
1036 query.append(", ");
1037 }
1038 }
1039 }
1040
1041 else {
1042 query.append("ORDER BY ");
1043
1044 query.append("expandoValue.tableId ASC, ");
1045 query.append("expandoValue.rowId ASC, ");
1046 query.append("expandoValue.columnId ASC");
1047 }
1048
1049 Query q = session.createQuery(query.toString());
1050
1051 QueryPos qPos = QueryPos.getInstance(q);
1052
1053 qPos.add(columnId);
1054
1055 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1056 expandoValue);
1057
1058 ExpandoValue[] array = new ExpandoValueImpl[3];
1059
1060 array[0] = (ExpandoValue)objArray[0];
1061 array[1] = (ExpandoValue)objArray[1];
1062 array[2] = (ExpandoValue)objArray[2];
1063
1064 return array;
1065 }
1066 catch (Exception e) {
1067 throw processException(e);
1068 }
1069 finally {
1070 closeSession(session);
1071 }
1072 }
1073
1074 public List<ExpandoValue> findByRowId(long rowId) throws SystemException {
1075 Object[] finderArgs = new Object[] { new Long(rowId) };
1076
1077 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ROWID,
1078 finderArgs, this);
1079
1080 if (list == null) {
1081 Session session = null;
1082
1083 try {
1084 session = openSession();
1085
1086 StringBuilder query = new StringBuilder();
1087
1088 query.append(
1089 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1090
1091 query.append("expandoValue.rowId = ?");
1092
1093 query.append(" ");
1094
1095 query.append("ORDER BY ");
1096
1097 query.append("expandoValue.tableId ASC, ");
1098 query.append("expandoValue.rowId ASC, ");
1099 query.append("expandoValue.columnId ASC");
1100
1101 Query q = session.createQuery(query.toString());
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 qPos.add(rowId);
1106
1107 list = q.list();
1108 }
1109 catch (Exception e) {
1110 throw processException(e);
1111 }
1112 finally {
1113 if (list == null) {
1114 list = new ArrayList<ExpandoValue>();
1115 }
1116
1117 cacheResult(list);
1118
1119 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ROWID,
1120 finderArgs, list);
1121
1122 closeSession(session);
1123 }
1124 }
1125
1126 return list;
1127 }
1128
1129 public List<ExpandoValue> findByRowId(long rowId, int start, int end)
1130 throws SystemException {
1131 return findByRowId(rowId, start, end, null);
1132 }
1133
1134 public List<ExpandoValue> findByRowId(long rowId, int start, int end,
1135 OrderByComparator obc) throws SystemException {
1136 Object[] finderArgs = new Object[] {
1137 new Long(rowId),
1138
1139 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1140 };
1141
1142 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ROWID,
1143 finderArgs, this);
1144
1145 if (list == null) {
1146 Session session = null;
1147
1148 try {
1149 session = openSession();
1150
1151 StringBuilder query = new StringBuilder();
1152
1153 query.append(
1154 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1155
1156 query.append("expandoValue.rowId = ?");
1157
1158 query.append(" ");
1159
1160 if (obc != null) {
1161 query.append("ORDER BY ");
1162
1163 String[] orderByFields = obc.getOrderByFields();
1164
1165 for (int i = 0; i < orderByFields.length; i++) {
1166 query.append("expandoValue.");
1167 query.append(orderByFields[i]);
1168
1169 if (obc.isAscending()) {
1170 query.append(" ASC");
1171 }
1172 else {
1173 query.append(" DESC");
1174 }
1175
1176 if ((i + 1) < orderByFields.length) {
1177 query.append(", ");
1178 }
1179 }
1180 }
1181
1182 else {
1183 query.append("ORDER BY ");
1184
1185 query.append("expandoValue.tableId ASC, ");
1186 query.append("expandoValue.rowId ASC, ");
1187 query.append("expandoValue.columnId ASC");
1188 }
1189
1190 Query q = session.createQuery(query.toString());
1191
1192 QueryPos qPos = QueryPos.getInstance(q);
1193
1194 qPos.add(rowId);
1195
1196 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
1197 start, end);
1198 }
1199 catch (Exception e) {
1200 throw processException(e);
1201 }
1202 finally {
1203 if (list == null) {
1204 list = new ArrayList<ExpandoValue>();
1205 }
1206
1207 cacheResult(list);
1208
1209 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ROWID,
1210 finderArgs, list);
1211
1212 closeSession(session);
1213 }
1214 }
1215
1216 return list;
1217 }
1218
1219 public ExpandoValue findByRowId_First(long rowId, OrderByComparator obc)
1220 throws NoSuchValueException, SystemException {
1221 List<ExpandoValue> list = findByRowId(rowId, 0, 1, obc);
1222
1223 if (list.isEmpty()) {
1224 StringBuilder msg = new StringBuilder();
1225
1226 msg.append("No ExpandoValue exists with the key {");
1227
1228 msg.append("rowId=" + rowId);
1229
1230 msg.append(StringPool.CLOSE_CURLY_BRACE);
1231
1232 throw new NoSuchValueException(msg.toString());
1233 }
1234 else {
1235 return list.get(0);
1236 }
1237 }
1238
1239 public ExpandoValue findByRowId_Last(long rowId, OrderByComparator obc)
1240 throws NoSuchValueException, SystemException {
1241 int count = countByRowId(rowId);
1242
1243 List<ExpandoValue> list = findByRowId(rowId, count - 1, count, obc);
1244
1245 if (list.isEmpty()) {
1246 StringBuilder msg = new StringBuilder();
1247
1248 msg.append("No ExpandoValue exists with the key {");
1249
1250 msg.append("rowId=" + rowId);
1251
1252 msg.append(StringPool.CLOSE_CURLY_BRACE);
1253
1254 throw new NoSuchValueException(msg.toString());
1255 }
1256 else {
1257 return list.get(0);
1258 }
1259 }
1260
1261 public ExpandoValue[] findByRowId_PrevAndNext(long valueId, long rowId,
1262 OrderByComparator obc) throws NoSuchValueException, SystemException {
1263 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1264
1265 int count = countByRowId(rowId);
1266
1267 Session session = null;
1268
1269 try {
1270 session = openSession();
1271
1272 StringBuilder query = new StringBuilder();
1273
1274 query.append(
1275 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1276
1277 query.append("expandoValue.rowId = ?");
1278
1279 query.append(" ");
1280
1281 if (obc != null) {
1282 query.append("ORDER BY ");
1283
1284 String[] orderByFields = obc.getOrderByFields();
1285
1286 for (int i = 0; i < orderByFields.length; i++) {
1287 query.append("expandoValue.");
1288 query.append(orderByFields[i]);
1289
1290 if (obc.isAscending()) {
1291 query.append(" ASC");
1292 }
1293 else {
1294 query.append(" DESC");
1295 }
1296
1297 if ((i + 1) < orderByFields.length) {
1298 query.append(", ");
1299 }
1300 }
1301 }
1302
1303 else {
1304 query.append("ORDER BY ");
1305
1306 query.append("expandoValue.tableId ASC, ");
1307 query.append("expandoValue.rowId ASC, ");
1308 query.append("expandoValue.columnId ASC");
1309 }
1310
1311 Query q = session.createQuery(query.toString());
1312
1313 QueryPos qPos = QueryPos.getInstance(q);
1314
1315 qPos.add(rowId);
1316
1317 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1318 expandoValue);
1319
1320 ExpandoValue[] array = new ExpandoValueImpl[3];
1321
1322 array[0] = (ExpandoValue)objArray[0];
1323 array[1] = (ExpandoValue)objArray[1];
1324 array[2] = (ExpandoValue)objArray[2];
1325
1326 return array;
1327 }
1328 catch (Exception e) {
1329 throw processException(e);
1330 }
1331 finally {
1332 closeSession(session);
1333 }
1334 }
1335
1336 public List<ExpandoValue> findByT_C(long tableId, long columnId)
1337 throws SystemException {
1338 Object[] finderArgs = new Object[] { new Long(tableId), new Long(columnId) };
1339
1340 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_C,
1341 finderArgs, this);
1342
1343 if (list == null) {
1344 Session session = null;
1345
1346 try {
1347 session = openSession();
1348
1349 StringBuilder query = new StringBuilder();
1350
1351 query.append(
1352 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1353
1354 query.append("expandoValue.tableId = ?");
1355
1356 query.append(" AND ");
1357
1358 query.append("expandoValue.columnId = ?");
1359
1360 query.append(" ");
1361
1362 query.append("ORDER BY ");
1363
1364 query.append("expandoValue.tableId ASC, ");
1365 query.append("expandoValue.rowId ASC, ");
1366 query.append("expandoValue.columnId ASC");
1367
1368 Query q = session.createQuery(query.toString());
1369
1370 QueryPos qPos = QueryPos.getInstance(q);
1371
1372 qPos.add(tableId);
1373
1374 qPos.add(columnId);
1375
1376 list = q.list();
1377 }
1378 catch (Exception e) {
1379 throw processException(e);
1380 }
1381 finally {
1382 if (list == null) {
1383 list = new ArrayList<ExpandoValue>();
1384 }
1385
1386 cacheResult(list);
1387
1388 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_C, finderArgs,
1389 list);
1390
1391 closeSession(session);
1392 }
1393 }
1394
1395 return list;
1396 }
1397
1398 public List<ExpandoValue> findByT_C(long tableId, long columnId, int start,
1399 int end) throws SystemException {
1400 return findByT_C(tableId, columnId, start, end, null);
1401 }
1402
1403 public List<ExpandoValue> findByT_C(long tableId, long columnId, int start,
1404 int end, OrderByComparator obc) throws SystemException {
1405 Object[] finderArgs = new Object[] {
1406 new Long(tableId), new Long(columnId),
1407
1408 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1409 };
1410
1411 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_C,
1412 finderArgs, this);
1413
1414 if (list == null) {
1415 Session session = null;
1416
1417 try {
1418 session = openSession();
1419
1420 StringBuilder query = new StringBuilder();
1421
1422 query.append(
1423 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1424
1425 query.append("expandoValue.tableId = ?");
1426
1427 query.append(" AND ");
1428
1429 query.append("expandoValue.columnId = ?");
1430
1431 query.append(" ");
1432
1433 if (obc != null) {
1434 query.append("ORDER BY ");
1435
1436 String[] orderByFields = obc.getOrderByFields();
1437
1438 for (int i = 0; i < orderByFields.length; i++) {
1439 query.append("expandoValue.");
1440 query.append(orderByFields[i]);
1441
1442 if (obc.isAscending()) {
1443 query.append(" ASC");
1444 }
1445 else {
1446 query.append(" DESC");
1447 }
1448
1449 if ((i + 1) < orderByFields.length) {
1450 query.append(", ");
1451 }
1452 }
1453 }
1454
1455 else {
1456 query.append("ORDER BY ");
1457
1458 query.append("expandoValue.tableId ASC, ");
1459 query.append("expandoValue.rowId ASC, ");
1460 query.append("expandoValue.columnId ASC");
1461 }
1462
1463 Query q = session.createQuery(query.toString());
1464
1465 QueryPos qPos = QueryPos.getInstance(q);
1466
1467 qPos.add(tableId);
1468
1469 qPos.add(columnId);
1470
1471 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
1472 start, end);
1473 }
1474 catch (Exception e) {
1475 throw processException(e);
1476 }
1477 finally {
1478 if (list == null) {
1479 list = new ArrayList<ExpandoValue>();
1480 }
1481
1482 cacheResult(list);
1483
1484 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_C,
1485 finderArgs, list);
1486
1487 closeSession(session);
1488 }
1489 }
1490
1491 return list;
1492 }
1493
1494 public ExpandoValue findByT_C_First(long tableId, long columnId,
1495 OrderByComparator obc) throws NoSuchValueException, SystemException {
1496 List<ExpandoValue> list = findByT_C(tableId, columnId, 0, 1, obc);
1497
1498 if (list.isEmpty()) {
1499 StringBuilder msg = new StringBuilder();
1500
1501 msg.append("No ExpandoValue exists with the key {");
1502
1503 msg.append("tableId=" + tableId);
1504
1505 msg.append(", ");
1506 msg.append("columnId=" + columnId);
1507
1508 msg.append(StringPool.CLOSE_CURLY_BRACE);
1509
1510 throw new NoSuchValueException(msg.toString());
1511 }
1512 else {
1513 return list.get(0);
1514 }
1515 }
1516
1517 public ExpandoValue findByT_C_Last(long tableId, long columnId,
1518 OrderByComparator obc) throws NoSuchValueException, SystemException {
1519 int count = countByT_C(tableId, columnId);
1520
1521 List<ExpandoValue> list = findByT_C(tableId, columnId, count - 1,
1522 count, obc);
1523
1524 if (list.isEmpty()) {
1525 StringBuilder msg = new StringBuilder();
1526
1527 msg.append("No ExpandoValue exists with the key {");
1528
1529 msg.append("tableId=" + tableId);
1530
1531 msg.append(", ");
1532 msg.append("columnId=" + columnId);
1533
1534 msg.append(StringPool.CLOSE_CURLY_BRACE);
1535
1536 throw new NoSuchValueException(msg.toString());
1537 }
1538 else {
1539 return list.get(0);
1540 }
1541 }
1542
1543 public ExpandoValue[] findByT_C_PrevAndNext(long valueId, long tableId,
1544 long columnId, OrderByComparator obc)
1545 throws NoSuchValueException, SystemException {
1546 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1547
1548 int count = countByT_C(tableId, columnId);
1549
1550 Session session = null;
1551
1552 try {
1553 session = openSession();
1554
1555 StringBuilder query = new StringBuilder();
1556
1557 query.append(
1558 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1559
1560 query.append("expandoValue.tableId = ?");
1561
1562 query.append(" AND ");
1563
1564 query.append("expandoValue.columnId = ?");
1565
1566 query.append(" ");
1567
1568 if (obc != null) {
1569 query.append("ORDER BY ");
1570
1571 String[] orderByFields = obc.getOrderByFields();
1572
1573 for (int i = 0; i < orderByFields.length; i++) {
1574 query.append("expandoValue.");
1575 query.append(orderByFields[i]);
1576
1577 if (obc.isAscending()) {
1578 query.append(" ASC");
1579 }
1580 else {
1581 query.append(" DESC");
1582 }
1583
1584 if ((i + 1) < orderByFields.length) {
1585 query.append(", ");
1586 }
1587 }
1588 }
1589
1590 else {
1591 query.append("ORDER BY ");
1592
1593 query.append("expandoValue.tableId ASC, ");
1594 query.append("expandoValue.rowId ASC, ");
1595 query.append("expandoValue.columnId ASC");
1596 }
1597
1598 Query q = session.createQuery(query.toString());
1599
1600 QueryPos qPos = QueryPos.getInstance(q);
1601
1602 qPos.add(tableId);
1603
1604 qPos.add(columnId);
1605
1606 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1607 expandoValue);
1608
1609 ExpandoValue[] array = new ExpandoValueImpl[3];
1610
1611 array[0] = (ExpandoValue)objArray[0];
1612 array[1] = (ExpandoValue)objArray[1];
1613 array[2] = (ExpandoValue)objArray[2];
1614
1615 return array;
1616 }
1617 catch (Exception e) {
1618 throw processException(e);
1619 }
1620 finally {
1621 closeSession(session);
1622 }
1623 }
1624
1625 public List<ExpandoValue> findByT_CPK(long tableId, long classPK)
1626 throws SystemException {
1627 Object[] finderArgs = new Object[] { new Long(tableId), new Long(classPK) };
1628
1629 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_CPK,
1630 finderArgs, this);
1631
1632 if (list == null) {
1633 Session session = null;
1634
1635 try {
1636 session = openSession();
1637
1638 StringBuilder query = new StringBuilder();
1639
1640 query.append(
1641 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1642
1643 query.append("expandoValue.tableId = ?");
1644
1645 query.append(" AND ");
1646
1647 query.append("expandoValue.classPK = ?");
1648
1649 query.append(" ");
1650
1651 query.append("ORDER BY ");
1652
1653 query.append("expandoValue.tableId ASC, ");
1654 query.append("expandoValue.rowId ASC, ");
1655 query.append("expandoValue.columnId ASC");
1656
1657 Query q = session.createQuery(query.toString());
1658
1659 QueryPos qPos = QueryPos.getInstance(q);
1660
1661 qPos.add(tableId);
1662
1663 qPos.add(classPK);
1664
1665 list = q.list();
1666 }
1667 catch (Exception e) {
1668 throw processException(e);
1669 }
1670 finally {
1671 if (list == null) {
1672 list = new ArrayList<ExpandoValue>();
1673 }
1674
1675 cacheResult(list);
1676
1677 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_CPK,
1678 finderArgs, list);
1679
1680 closeSession(session);
1681 }
1682 }
1683
1684 return list;
1685 }
1686
1687 public List<ExpandoValue> findByT_CPK(long tableId, long classPK,
1688 int start, int end) throws SystemException {
1689 return findByT_CPK(tableId, classPK, start, end, null);
1690 }
1691
1692 public List<ExpandoValue> findByT_CPK(long tableId, long classPK,
1693 int start, int end, OrderByComparator obc) throws SystemException {
1694 Object[] finderArgs = new Object[] {
1695 new Long(tableId), new Long(classPK),
1696
1697 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1698 };
1699
1700 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_CPK,
1701 finderArgs, this);
1702
1703 if (list == null) {
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 StringBuilder query = new StringBuilder();
1710
1711 query.append(
1712 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1713
1714 query.append("expandoValue.tableId = ?");
1715
1716 query.append(" AND ");
1717
1718 query.append("expandoValue.classPK = ?");
1719
1720 query.append(" ");
1721
1722 if (obc != null) {
1723 query.append("ORDER BY ");
1724
1725 String[] orderByFields = obc.getOrderByFields();
1726
1727 for (int i = 0; i < orderByFields.length; i++) {
1728 query.append("expandoValue.");
1729 query.append(orderByFields[i]);
1730
1731 if (obc.isAscending()) {
1732 query.append(" ASC");
1733 }
1734 else {
1735 query.append(" DESC");
1736 }
1737
1738 if ((i + 1) < orderByFields.length) {
1739 query.append(", ");
1740 }
1741 }
1742 }
1743
1744 else {
1745 query.append("ORDER BY ");
1746
1747 query.append("expandoValue.tableId ASC, ");
1748 query.append("expandoValue.rowId ASC, ");
1749 query.append("expandoValue.columnId ASC");
1750 }
1751
1752 Query q = session.createQuery(query.toString());
1753
1754 QueryPos qPos = QueryPos.getInstance(q);
1755
1756 qPos.add(tableId);
1757
1758 qPos.add(classPK);
1759
1760 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
1761 start, end);
1762 }
1763 catch (Exception e) {
1764 throw processException(e);
1765 }
1766 finally {
1767 if (list == null) {
1768 list = new ArrayList<ExpandoValue>();
1769 }
1770
1771 cacheResult(list);
1772
1773 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_CPK,
1774 finderArgs, list);
1775
1776 closeSession(session);
1777 }
1778 }
1779
1780 return list;
1781 }
1782
1783 public ExpandoValue findByT_CPK_First(long tableId, long classPK,
1784 OrderByComparator obc) throws NoSuchValueException, SystemException {
1785 List<ExpandoValue> list = findByT_CPK(tableId, classPK, 0, 1, obc);
1786
1787 if (list.isEmpty()) {
1788 StringBuilder msg = new StringBuilder();
1789
1790 msg.append("No ExpandoValue exists with the key {");
1791
1792 msg.append("tableId=" + tableId);
1793
1794 msg.append(", ");
1795 msg.append("classPK=" + classPK);
1796
1797 msg.append(StringPool.CLOSE_CURLY_BRACE);
1798
1799 throw new NoSuchValueException(msg.toString());
1800 }
1801 else {
1802 return list.get(0);
1803 }
1804 }
1805
1806 public ExpandoValue findByT_CPK_Last(long tableId, long classPK,
1807 OrderByComparator obc) throws NoSuchValueException, SystemException {
1808 int count = countByT_CPK(tableId, classPK);
1809
1810 List<ExpandoValue> list = findByT_CPK(tableId, classPK, count - 1,
1811 count, obc);
1812
1813 if (list.isEmpty()) {
1814 StringBuilder msg = new StringBuilder();
1815
1816 msg.append("No ExpandoValue exists with the key {");
1817
1818 msg.append("tableId=" + tableId);
1819
1820 msg.append(", ");
1821 msg.append("classPK=" + classPK);
1822
1823 msg.append(StringPool.CLOSE_CURLY_BRACE);
1824
1825 throw new NoSuchValueException(msg.toString());
1826 }
1827 else {
1828 return list.get(0);
1829 }
1830 }
1831
1832 public ExpandoValue[] findByT_CPK_PrevAndNext(long valueId, long tableId,
1833 long classPK, OrderByComparator obc)
1834 throws NoSuchValueException, SystemException {
1835 ExpandoValue expandoValue = findByPrimaryKey(valueId);
1836
1837 int count = countByT_CPK(tableId, classPK);
1838
1839 Session session = null;
1840
1841 try {
1842 session = openSession();
1843
1844 StringBuilder query = new StringBuilder();
1845
1846 query.append(
1847 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1848
1849 query.append("expandoValue.tableId = ?");
1850
1851 query.append(" AND ");
1852
1853 query.append("expandoValue.classPK = ?");
1854
1855 query.append(" ");
1856
1857 if (obc != null) {
1858 query.append("ORDER BY ");
1859
1860 String[] orderByFields = obc.getOrderByFields();
1861
1862 for (int i = 0; i < orderByFields.length; i++) {
1863 query.append("expandoValue.");
1864 query.append(orderByFields[i]);
1865
1866 if (obc.isAscending()) {
1867 query.append(" ASC");
1868 }
1869 else {
1870 query.append(" DESC");
1871 }
1872
1873 if ((i + 1) < orderByFields.length) {
1874 query.append(", ");
1875 }
1876 }
1877 }
1878
1879 else {
1880 query.append("ORDER BY ");
1881
1882 query.append("expandoValue.tableId ASC, ");
1883 query.append("expandoValue.rowId ASC, ");
1884 query.append("expandoValue.columnId ASC");
1885 }
1886
1887 Query q = session.createQuery(query.toString());
1888
1889 QueryPos qPos = QueryPos.getInstance(q);
1890
1891 qPos.add(tableId);
1892
1893 qPos.add(classPK);
1894
1895 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1896 expandoValue);
1897
1898 ExpandoValue[] array = new ExpandoValueImpl[3];
1899
1900 array[0] = (ExpandoValue)objArray[0];
1901 array[1] = (ExpandoValue)objArray[1];
1902 array[2] = (ExpandoValue)objArray[2];
1903
1904 return array;
1905 }
1906 catch (Exception e) {
1907 throw processException(e);
1908 }
1909 finally {
1910 closeSession(session);
1911 }
1912 }
1913
1914 public List<ExpandoValue> findByT_R(long tableId, long rowId)
1915 throws SystemException {
1916 Object[] finderArgs = new Object[] { new Long(tableId), new Long(rowId) };
1917
1918 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_R,
1919 finderArgs, this);
1920
1921 if (list == null) {
1922 Session session = null;
1923
1924 try {
1925 session = openSession();
1926
1927 StringBuilder query = new StringBuilder();
1928
1929 query.append(
1930 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
1931
1932 query.append("expandoValue.tableId = ?");
1933
1934 query.append(" AND ");
1935
1936 query.append("expandoValue.rowId = ?");
1937
1938 query.append(" ");
1939
1940 query.append("ORDER BY ");
1941
1942 query.append("expandoValue.tableId ASC, ");
1943 query.append("expandoValue.rowId ASC, ");
1944 query.append("expandoValue.columnId ASC");
1945
1946 Query q = session.createQuery(query.toString());
1947
1948 QueryPos qPos = QueryPos.getInstance(q);
1949
1950 qPos.add(tableId);
1951
1952 qPos.add(rowId);
1953
1954 list = q.list();
1955 }
1956 catch (Exception e) {
1957 throw processException(e);
1958 }
1959 finally {
1960 if (list == null) {
1961 list = new ArrayList<ExpandoValue>();
1962 }
1963
1964 cacheResult(list);
1965
1966 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_R, finderArgs,
1967 list);
1968
1969 closeSession(session);
1970 }
1971 }
1972
1973 return list;
1974 }
1975
1976 public List<ExpandoValue> findByT_R(long tableId, long rowId, int start,
1977 int end) throws SystemException {
1978 return findByT_R(tableId, rowId, start, end, null);
1979 }
1980
1981 public List<ExpandoValue> findByT_R(long tableId, long rowId, int start,
1982 int end, OrderByComparator obc) throws SystemException {
1983 Object[] finderArgs = new Object[] {
1984 new Long(tableId), new Long(rowId),
1985
1986 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1987 };
1988
1989 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_R,
1990 finderArgs, this);
1991
1992 if (list == null) {
1993 Session session = null;
1994
1995 try {
1996 session = openSession();
1997
1998 StringBuilder query = new StringBuilder();
1999
2000 query.append(
2001 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2002
2003 query.append("expandoValue.tableId = ?");
2004
2005 query.append(" AND ");
2006
2007 query.append("expandoValue.rowId = ?");
2008
2009 query.append(" ");
2010
2011 if (obc != null) {
2012 query.append("ORDER BY ");
2013
2014 String[] orderByFields = obc.getOrderByFields();
2015
2016 for (int i = 0; i < orderByFields.length; i++) {
2017 query.append("expandoValue.");
2018 query.append(orderByFields[i]);
2019
2020 if (obc.isAscending()) {
2021 query.append(" ASC");
2022 }
2023 else {
2024 query.append(" DESC");
2025 }
2026
2027 if ((i + 1) < orderByFields.length) {
2028 query.append(", ");
2029 }
2030 }
2031 }
2032
2033 else {
2034 query.append("ORDER BY ");
2035
2036 query.append("expandoValue.tableId ASC, ");
2037 query.append("expandoValue.rowId ASC, ");
2038 query.append("expandoValue.columnId ASC");
2039 }
2040
2041 Query q = session.createQuery(query.toString());
2042
2043 QueryPos qPos = QueryPos.getInstance(q);
2044
2045 qPos.add(tableId);
2046
2047 qPos.add(rowId);
2048
2049 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
2050 start, end);
2051 }
2052 catch (Exception e) {
2053 throw processException(e);
2054 }
2055 finally {
2056 if (list == null) {
2057 list = new ArrayList<ExpandoValue>();
2058 }
2059
2060 cacheResult(list);
2061
2062 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_R,
2063 finderArgs, list);
2064
2065 closeSession(session);
2066 }
2067 }
2068
2069 return list;
2070 }
2071
2072 public ExpandoValue findByT_R_First(long tableId, long rowId,
2073 OrderByComparator obc) throws NoSuchValueException, SystemException {
2074 List<ExpandoValue> list = findByT_R(tableId, rowId, 0, 1, obc);
2075
2076 if (list.isEmpty()) {
2077 StringBuilder msg = new StringBuilder();
2078
2079 msg.append("No ExpandoValue exists with the key {");
2080
2081 msg.append("tableId=" + tableId);
2082
2083 msg.append(", ");
2084 msg.append("rowId=" + rowId);
2085
2086 msg.append(StringPool.CLOSE_CURLY_BRACE);
2087
2088 throw new NoSuchValueException(msg.toString());
2089 }
2090 else {
2091 return list.get(0);
2092 }
2093 }
2094
2095 public ExpandoValue findByT_R_Last(long tableId, long rowId,
2096 OrderByComparator obc) throws NoSuchValueException, SystemException {
2097 int count = countByT_R(tableId, rowId);
2098
2099 List<ExpandoValue> list = findByT_R(tableId, rowId, count - 1, count,
2100 obc);
2101
2102 if (list.isEmpty()) {
2103 StringBuilder msg = new StringBuilder();
2104
2105 msg.append("No ExpandoValue exists with the key {");
2106
2107 msg.append("tableId=" + tableId);
2108
2109 msg.append(", ");
2110 msg.append("rowId=" + rowId);
2111
2112 msg.append(StringPool.CLOSE_CURLY_BRACE);
2113
2114 throw new NoSuchValueException(msg.toString());
2115 }
2116 else {
2117 return list.get(0);
2118 }
2119 }
2120
2121 public ExpandoValue[] findByT_R_PrevAndNext(long valueId, long tableId,
2122 long rowId, OrderByComparator obc)
2123 throws NoSuchValueException, SystemException {
2124 ExpandoValue expandoValue = findByPrimaryKey(valueId);
2125
2126 int count = countByT_R(tableId, rowId);
2127
2128 Session session = null;
2129
2130 try {
2131 session = openSession();
2132
2133 StringBuilder query = new StringBuilder();
2134
2135 query.append(
2136 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2137
2138 query.append("expandoValue.tableId = ?");
2139
2140 query.append(" AND ");
2141
2142 query.append("expandoValue.rowId = ?");
2143
2144 query.append(" ");
2145
2146 if (obc != null) {
2147 query.append("ORDER BY ");
2148
2149 String[] orderByFields = obc.getOrderByFields();
2150
2151 for (int i = 0; i < orderByFields.length; i++) {
2152 query.append("expandoValue.");
2153 query.append(orderByFields[i]);
2154
2155 if (obc.isAscending()) {
2156 query.append(" ASC");
2157 }
2158 else {
2159 query.append(" DESC");
2160 }
2161
2162 if ((i + 1) < orderByFields.length) {
2163 query.append(", ");
2164 }
2165 }
2166 }
2167
2168 else {
2169 query.append("ORDER BY ");
2170
2171 query.append("expandoValue.tableId ASC, ");
2172 query.append("expandoValue.rowId ASC, ");
2173 query.append("expandoValue.columnId ASC");
2174 }
2175
2176 Query q = session.createQuery(query.toString());
2177
2178 QueryPos qPos = QueryPos.getInstance(q);
2179
2180 qPos.add(tableId);
2181
2182 qPos.add(rowId);
2183
2184 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2185 expandoValue);
2186
2187 ExpandoValue[] array = new ExpandoValueImpl[3];
2188
2189 array[0] = (ExpandoValue)objArray[0];
2190 array[1] = (ExpandoValue)objArray[1];
2191 array[2] = (ExpandoValue)objArray[2];
2192
2193 return array;
2194 }
2195 catch (Exception e) {
2196 throw processException(e);
2197 }
2198 finally {
2199 closeSession(session);
2200 }
2201 }
2202
2203 public ExpandoValue findByC_R(long columnId, long rowId)
2204 throws NoSuchValueException, SystemException {
2205 ExpandoValue expandoValue = fetchByC_R(columnId, rowId);
2206
2207 if (expandoValue == null) {
2208 StringBuilder msg = new StringBuilder();
2209
2210 msg.append("No ExpandoValue exists with the key {");
2211
2212 msg.append("columnId=" + columnId);
2213
2214 msg.append(", ");
2215 msg.append("rowId=" + rowId);
2216
2217 msg.append(StringPool.CLOSE_CURLY_BRACE);
2218
2219 if (_log.isWarnEnabled()) {
2220 _log.warn(msg.toString());
2221 }
2222
2223 throw new NoSuchValueException(msg.toString());
2224 }
2225
2226 return expandoValue;
2227 }
2228
2229 public ExpandoValue fetchByC_R(long columnId, long rowId)
2230 throws SystemException {
2231 return fetchByC_R(columnId, rowId, true);
2232 }
2233
2234 public ExpandoValue fetchByC_R(long columnId, long rowId,
2235 boolean retrieveFromCache) throws SystemException {
2236 Object[] finderArgs = new Object[] { new Long(columnId), new Long(rowId) };
2237
2238 Object result = null;
2239
2240 if (retrieveFromCache) {
2241 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_R,
2242 finderArgs, this);
2243 }
2244
2245 if (result == null) {
2246 Session session = null;
2247
2248 try {
2249 session = openSession();
2250
2251 StringBuilder query = new StringBuilder();
2252
2253 query.append(
2254 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2255
2256 query.append("expandoValue.columnId = ?");
2257
2258 query.append(" AND ");
2259
2260 query.append("expandoValue.rowId = ?");
2261
2262 query.append(" ");
2263
2264 query.append("ORDER BY ");
2265
2266 query.append("expandoValue.tableId ASC, ");
2267 query.append("expandoValue.rowId ASC, ");
2268 query.append("expandoValue.columnId ASC");
2269
2270 Query q = session.createQuery(query.toString());
2271
2272 QueryPos qPos = QueryPos.getInstance(q);
2273
2274 qPos.add(columnId);
2275
2276 qPos.add(rowId);
2277
2278 List<ExpandoValue> list = q.list();
2279
2280 result = list;
2281
2282 ExpandoValue expandoValue = null;
2283
2284 if (list.isEmpty()) {
2285 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R,
2286 finderArgs, list);
2287 }
2288 else {
2289 expandoValue = list.get(0);
2290
2291 cacheResult(expandoValue);
2292
2293 if ((expandoValue.getColumnId() != columnId) ||
2294 (expandoValue.getRowId() != rowId)) {
2295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R,
2296 finderArgs, expandoValue);
2297 }
2298 }
2299
2300 return expandoValue;
2301 }
2302 catch (Exception e) {
2303 throw processException(e);
2304 }
2305 finally {
2306 if (result == null) {
2307 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R,
2308 finderArgs, new ArrayList<ExpandoValue>());
2309 }
2310
2311 closeSession(session);
2312 }
2313 }
2314 else {
2315 if (result instanceof List) {
2316 return null;
2317 }
2318 else {
2319 return (ExpandoValue)result;
2320 }
2321 }
2322 }
2323
2324 public List<ExpandoValue> findByC_C(long classNameId, long classPK)
2325 throws SystemException {
2326 Object[] finderArgs = new Object[] {
2327 new Long(classNameId), new Long(classPK)
2328 };
2329
2330 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
2331 finderArgs, this);
2332
2333 if (list == null) {
2334 Session session = null;
2335
2336 try {
2337 session = openSession();
2338
2339 StringBuilder query = new StringBuilder();
2340
2341 query.append(
2342 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2343
2344 query.append("expandoValue.classNameId = ?");
2345
2346 query.append(" AND ");
2347
2348 query.append("expandoValue.classPK = ?");
2349
2350 query.append(" ");
2351
2352 query.append("ORDER BY ");
2353
2354 query.append("expandoValue.tableId ASC, ");
2355 query.append("expandoValue.rowId ASC, ");
2356 query.append("expandoValue.columnId ASC");
2357
2358 Query q = session.createQuery(query.toString());
2359
2360 QueryPos qPos = QueryPos.getInstance(q);
2361
2362 qPos.add(classNameId);
2363
2364 qPos.add(classPK);
2365
2366 list = q.list();
2367 }
2368 catch (Exception e) {
2369 throw processException(e);
2370 }
2371 finally {
2372 if (list == null) {
2373 list = new ArrayList<ExpandoValue>();
2374 }
2375
2376 cacheResult(list);
2377
2378 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
2379 list);
2380
2381 closeSession(session);
2382 }
2383 }
2384
2385 return list;
2386 }
2387
2388 public List<ExpandoValue> findByC_C(long classNameId, long classPK,
2389 int start, int end) throws SystemException {
2390 return findByC_C(classNameId, classPK, start, end, null);
2391 }
2392
2393 public List<ExpandoValue> findByC_C(long classNameId, long classPK,
2394 int start, int end, OrderByComparator obc) throws SystemException {
2395 Object[] finderArgs = new Object[] {
2396 new Long(classNameId), new Long(classPK),
2397
2398 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2399 };
2400
2401 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_C,
2402 finderArgs, this);
2403
2404 if (list == null) {
2405 Session session = null;
2406
2407 try {
2408 session = openSession();
2409
2410 StringBuilder query = new StringBuilder();
2411
2412 query.append(
2413 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2414
2415 query.append("expandoValue.classNameId = ?");
2416
2417 query.append(" AND ");
2418
2419 query.append("expandoValue.classPK = ?");
2420
2421 query.append(" ");
2422
2423 if (obc != null) {
2424 query.append("ORDER BY ");
2425
2426 String[] orderByFields = obc.getOrderByFields();
2427
2428 for (int i = 0; i < orderByFields.length; i++) {
2429 query.append("expandoValue.");
2430 query.append(orderByFields[i]);
2431
2432 if (obc.isAscending()) {
2433 query.append(" ASC");
2434 }
2435 else {
2436 query.append(" DESC");
2437 }
2438
2439 if ((i + 1) < orderByFields.length) {
2440 query.append(", ");
2441 }
2442 }
2443 }
2444
2445 else {
2446 query.append("ORDER BY ");
2447
2448 query.append("expandoValue.tableId ASC, ");
2449 query.append("expandoValue.rowId ASC, ");
2450 query.append("expandoValue.columnId ASC");
2451 }
2452
2453 Query q = session.createQuery(query.toString());
2454
2455 QueryPos qPos = QueryPos.getInstance(q);
2456
2457 qPos.add(classNameId);
2458
2459 qPos.add(classPK);
2460
2461 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
2462 start, end);
2463 }
2464 catch (Exception e) {
2465 throw processException(e);
2466 }
2467 finally {
2468 if (list == null) {
2469 list = new ArrayList<ExpandoValue>();
2470 }
2471
2472 cacheResult(list);
2473
2474 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_C,
2475 finderArgs, list);
2476
2477 closeSession(session);
2478 }
2479 }
2480
2481 return list;
2482 }
2483
2484 public ExpandoValue findByC_C_First(long classNameId, long classPK,
2485 OrderByComparator obc) throws NoSuchValueException, SystemException {
2486 List<ExpandoValue> list = findByC_C(classNameId, classPK, 0, 1, obc);
2487
2488 if (list.isEmpty()) {
2489 StringBuilder msg = new StringBuilder();
2490
2491 msg.append("No ExpandoValue exists with the key {");
2492
2493 msg.append("classNameId=" + classNameId);
2494
2495 msg.append(", ");
2496 msg.append("classPK=" + classPK);
2497
2498 msg.append(StringPool.CLOSE_CURLY_BRACE);
2499
2500 throw new NoSuchValueException(msg.toString());
2501 }
2502 else {
2503 return list.get(0);
2504 }
2505 }
2506
2507 public ExpandoValue findByC_C_Last(long classNameId, long classPK,
2508 OrderByComparator obc) throws NoSuchValueException, SystemException {
2509 int count = countByC_C(classNameId, classPK);
2510
2511 List<ExpandoValue> list = findByC_C(classNameId, classPK, count - 1,
2512 count, obc);
2513
2514 if (list.isEmpty()) {
2515 StringBuilder msg = new StringBuilder();
2516
2517 msg.append("No ExpandoValue exists with the key {");
2518
2519 msg.append("classNameId=" + classNameId);
2520
2521 msg.append(", ");
2522 msg.append("classPK=" + classPK);
2523
2524 msg.append(StringPool.CLOSE_CURLY_BRACE);
2525
2526 throw new NoSuchValueException(msg.toString());
2527 }
2528 else {
2529 return list.get(0);
2530 }
2531 }
2532
2533 public ExpandoValue[] findByC_C_PrevAndNext(long valueId, long classNameId,
2534 long classPK, OrderByComparator obc)
2535 throws NoSuchValueException, SystemException {
2536 ExpandoValue expandoValue = findByPrimaryKey(valueId);
2537
2538 int count = countByC_C(classNameId, classPK);
2539
2540 Session session = null;
2541
2542 try {
2543 session = openSession();
2544
2545 StringBuilder query = new StringBuilder();
2546
2547 query.append(
2548 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2549
2550 query.append("expandoValue.classNameId = ?");
2551
2552 query.append(" AND ");
2553
2554 query.append("expandoValue.classPK = ?");
2555
2556 query.append(" ");
2557
2558 if (obc != null) {
2559 query.append("ORDER BY ");
2560
2561 String[] orderByFields = obc.getOrderByFields();
2562
2563 for (int i = 0; i < orderByFields.length; i++) {
2564 query.append("expandoValue.");
2565 query.append(orderByFields[i]);
2566
2567 if (obc.isAscending()) {
2568 query.append(" ASC");
2569 }
2570 else {
2571 query.append(" DESC");
2572 }
2573
2574 if ((i + 1) < orderByFields.length) {
2575 query.append(", ");
2576 }
2577 }
2578 }
2579
2580 else {
2581 query.append("ORDER BY ");
2582
2583 query.append("expandoValue.tableId ASC, ");
2584 query.append("expandoValue.rowId ASC, ");
2585 query.append("expandoValue.columnId ASC");
2586 }
2587
2588 Query q = session.createQuery(query.toString());
2589
2590 QueryPos qPos = QueryPos.getInstance(q);
2591
2592 qPos.add(classNameId);
2593
2594 qPos.add(classPK);
2595
2596 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2597 expandoValue);
2598
2599 ExpandoValue[] array = new ExpandoValueImpl[3];
2600
2601 array[0] = (ExpandoValue)objArray[0];
2602 array[1] = (ExpandoValue)objArray[1];
2603 array[2] = (ExpandoValue)objArray[2];
2604
2605 return array;
2606 }
2607 catch (Exception e) {
2608 throw processException(e);
2609 }
2610 finally {
2611 closeSession(session);
2612 }
2613 }
2614
2615 public ExpandoValue findByT_C_C(long tableId, long columnId, long classPK)
2616 throws NoSuchValueException, SystemException {
2617 ExpandoValue expandoValue = fetchByT_C_C(tableId, columnId, classPK);
2618
2619 if (expandoValue == null) {
2620 StringBuilder msg = new StringBuilder();
2621
2622 msg.append("No ExpandoValue exists with the key {");
2623
2624 msg.append("tableId=" + tableId);
2625
2626 msg.append(", ");
2627 msg.append("columnId=" + columnId);
2628
2629 msg.append(", ");
2630 msg.append("classPK=" + classPK);
2631
2632 msg.append(StringPool.CLOSE_CURLY_BRACE);
2633
2634 if (_log.isWarnEnabled()) {
2635 _log.warn(msg.toString());
2636 }
2637
2638 throw new NoSuchValueException(msg.toString());
2639 }
2640
2641 return expandoValue;
2642 }
2643
2644 public ExpandoValue fetchByT_C_C(long tableId, long columnId, long classPK)
2645 throws SystemException {
2646 return fetchByT_C_C(tableId, columnId, classPK, true);
2647 }
2648
2649 public ExpandoValue fetchByT_C_C(long tableId, long columnId, long classPK,
2650 boolean retrieveFromCache) throws SystemException {
2651 Object[] finderArgs = new Object[] {
2652 new Long(tableId), new Long(columnId), new Long(classPK)
2653 };
2654
2655 Object result = null;
2656
2657 if (retrieveFromCache) {
2658 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_T_C_C,
2659 finderArgs, this);
2660 }
2661
2662 if (result == null) {
2663 Session session = null;
2664
2665 try {
2666 session = openSession();
2667
2668 StringBuilder query = new StringBuilder();
2669
2670 query.append(
2671 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2672
2673 query.append("expandoValue.tableId = ?");
2674
2675 query.append(" AND ");
2676
2677 query.append("expandoValue.columnId = ?");
2678
2679 query.append(" AND ");
2680
2681 query.append("expandoValue.classPK = ?");
2682
2683 query.append(" ");
2684
2685 query.append("ORDER BY ");
2686
2687 query.append("expandoValue.tableId ASC, ");
2688 query.append("expandoValue.rowId ASC, ");
2689 query.append("expandoValue.columnId ASC");
2690
2691 Query q = session.createQuery(query.toString());
2692
2693 QueryPos qPos = QueryPos.getInstance(q);
2694
2695 qPos.add(tableId);
2696
2697 qPos.add(columnId);
2698
2699 qPos.add(classPK);
2700
2701 List<ExpandoValue> list = q.list();
2702
2703 result = list;
2704
2705 ExpandoValue expandoValue = null;
2706
2707 if (list.isEmpty()) {
2708 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C_C,
2709 finderArgs, list);
2710 }
2711 else {
2712 expandoValue = list.get(0);
2713
2714 cacheResult(expandoValue);
2715
2716 if ((expandoValue.getTableId() != tableId) ||
2717 (expandoValue.getColumnId() != columnId) ||
2718 (expandoValue.getClassPK() != classPK)) {
2719 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C_C,
2720 finderArgs, expandoValue);
2721 }
2722 }
2723
2724 return expandoValue;
2725 }
2726 catch (Exception e) {
2727 throw processException(e);
2728 }
2729 finally {
2730 if (result == null) {
2731 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C_C,
2732 finderArgs, new ArrayList<ExpandoValue>());
2733 }
2734
2735 closeSession(session);
2736 }
2737 }
2738 else {
2739 if (result instanceof List) {
2740 return null;
2741 }
2742 else {
2743 return (ExpandoValue)result;
2744 }
2745 }
2746 }
2747
2748 public List<ExpandoValue> findByT_C_D(long tableId, long columnId,
2749 String data) throws SystemException {
2750 Object[] finderArgs = new Object[] {
2751 new Long(tableId), new Long(columnId),
2752
2753 data
2754 };
2755
2756 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_C_D,
2757 finderArgs, this);
2758
2759 if (list == null) {
2760 Session session = null;
2761
2762 try {
2763 session = openSession();
2764
2765 StringBuilder query = new StringBuilder();
2766
2767 query.append(
2768 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2769
2770 query.append("expandoValue.tableId = ?");
2771
2772 query.append(" AND ");
2773
2774 query.append("expandoValue.columnId = ?");
2775
2776 query.append(" AND ");
2777
2778 if (data == null) {
2779 query.append("expandoValue.data IS NULL");
2780 }
2781 else {
2782 query.append("expandoValue.data = ?");
2783 }
2784
2785 query.append(" ");
2786
2787 query.append("ORDER BY ");
2788
2789 query.append("expandoValue.tableId ASC, ");
2790 query.append("expandoValue.rowId ASC, ");
2791 query.append("expandoValue.columnId ASC");
2792
2793 Query q = session.createQuery(query.toString());
2794
2795 QueryPos qPos = QueryPos.getInstance(q);
2796
2797 qPos.add(tableId);
2798
2799 qPos.add(columnId);
2800
2801 if (data != null) {
2802 qPos.add(data);
2803 }
2804
2805 list = q.list();
2806 }
2807 catch (Exception e) {
2808 throw processException(e);
2809 }
2810 finally {
2811 if (list == null) {
2812 list = new ArrayList<ExpandoValue>();
2813 }
2814
2815 cacheResult(list);
2816
2817 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_C_D,
2818 finderArgs, list);
2819
2820 closeSession(session);
2821 }
2822 }
2823
2824 return list;
2825 }
2826
2827 public List<ExpandoValue> findByT_C_D(long tableId, long columnId,
2828 String data, int start, int end) throws SystemException {
2829 return findByT_C_D(tableId, columnId, data, start, end, null);
2830 }
2831
2832 public List<ExpandoValue> findByT_C_D(long tableId, long columnId,
2833 String data, int start, int end, OrderByComparator obc)
2834 throws SystemException {
2835 Object[] finderArgs = new Object[] {
2836 new Long(tableId), new Long(columnId),
2837
2838 data,
2839
2840 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2841 };
2842
2843 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_C_D,
2844 finderArgs, this);
2845
2846 if (list == null) {
2847 Session session = null;
2848
2849 try {
2850 session = openSession();
2851
2852 StringBuilder query = new StringBuilder();
2853
2854 query.append(
2855 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
2856
2857 query.append("expandoValue.tableId = ?");
2858
2859 query.append(" AND ");
2860
2861 query.append("expandoValue.columnId = ?");
2862
2863 query.append(" AND ");
2864
2865 if (data == null) {
2866 query.append("expandoValue.data IS NULL");
2867 }
2868 else {
2869 query.append("expandoValue.data = ?");
2870 }
2871
2872 query.append(" ");
2873
2874 if (obc != null) {
2875 query.append("ORDER BY ");
2876
2877 String[] orderByFields = obc.getOrderByFields();
2878
2879 for (int i = 0; i < orderByFields.length; i++) {
2880 query.append("expandoValue.");
2881 query.append(orderByFields[i]);
2882
2883 if (obc.isAscending()) {
2884 query.append(" ASC");
2885 }
2886 else {
2887 query.append(" DESC");
2888 }
2889
2890 if ((i + 1) < orderByFields.length) {
2891 query.append(", ");
2892 }
2893 }
2894 }
2895
2896 else {
2897 query.append("ORDER BY ");
2898
2899 query.append("expandoValue.tableId ASC, ");
2900 query.append("expandoValue.rowId ASC, ");
2901 query.append("expandoValue.columnId ASC");
2902 }
2903
2904 Query q = session.createQuery(query.toString());
2905
2906 QueryPos qPos = QueryPos.getInstance(q);
2907
2908 qPos.add(tableId);
2909
2910 qPos.add(columnId);
2911
2912 if (data != null) {
2913 qPos.add(data);
2914 }
2915
2916 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
2917 start, end);
2918 }
2919 catch (Exception e) {
2920 throw processException(e);
2921 }
2922 finally {
2923 if (list == null) {
2924 list = new ArrayList<ExpandoValue>();
2925 }
2926
2927 cacheResult(list);
2928
2929 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_C_D,
2930 finderArgs, list);
2931
2932 closeSession(session);
2933 }
2934 }
2935
2936 return list;
2937 }
2938
2939 public ExpandoValue findByT_C_D_First(long tableId, long columnId,
2940 String data, OrderByComparator obc)
2941 throws NoSuchValueException, SystemException {
2942 List<ExpandoValue> list = findByT_C_D(tableId, columnId, data, 0, 1, obc);
2943
2944 if (list.isEmpty()) {
2945 StringBuilder msg = new StringBuilder();
2946
2947 msg.append("No ExpandoValue exists with the key {");
2948
2949 msg.append("tableId=" + tableId);
2950
2951 msg.append(", ");
2952 msg.append("columnId=" + columnId);
2953
2954 msg.append(", ");
2955 msg.append("data=" + data);
2956
2957 msg.append(StringPool.CLOSE_CURLY_BRACE);
2958
2959 throw new NoSuchValueException(msg.toString());
2960 }
2961 else {
2962 return list.get(0);
2963 }
2964 }
2965
2966 public ExpandoValue findByT_C_D_Last(long tableId, long columnId,
2967 String data, OrderByComparator obc)
2968 throws NoSuchValueException, SystemException {
2969 int count = countByT_C_D(tableId, columnId, data);
2970
2971 List<ExpandoValue> list = findByT_C_D(tableId, columnId, data,
2972 count - 1, count, obc);
2973
2974 if (list.isEmpty()) {
2975 StringBuilder msg = new StringBuilder();
2976
2977 msg.append("No ExpandoValue exists with the key {");
2978
2979 msg.append("tableId=" + tableId);
2980
2981 msg.append(", ");
2982 msg.append("columnId=" + columnId);
2983
2984 msg.append(", ");
2985 msg.append("data=" + data);
2986
2987 msg.append(StringPool.CLOSE_CURLY_BRACE);
2988
2989 throw new NoSuchValueException(msg.toString());
2990 }
2991 else {
2992 return list.get(0);
2993 }
2994 }
2995
2996 public ExpandoValue[] findByT_C_D_PrevAndNext(long valueId, long tableId,
2997 long columnId, String data, OrderByComparator obc)
2998 throws NoSuchValueException, SystemException {
2999 ExpandoValue expandoValue = findByPrimaryKey(valueId);
3000
3001 int count = countByT_C_D(tableId, columnId, data);
3002
3003 Session session = null;
3004
3005 try {
3006 session = openSession();
3007
3008 StringBuilder query = new StringBuilder();
3009
3010 query.append(
3011 "SELECT expandoValue FROM ExpandoValue expandoValue WHERE ");
3012
3013 query.append("expandoValue.tableId = ?");
3014
3015 query.append(" AND ");
3016
3017 query.append("expandoValue.columnId = ?");
3018
3019 query.append(" AND ");
3020
3021 if (data == null) {
3022 query.append("expandoValue.data IS NULL");
3023 }
3024 else {
3025 query.append("expandoValue.data = ?");
3026 }
3027
3028 query.append(" ");
3029
3030 if (obc != null) {
3031 query.append("ORDER BY ");
3032
3033 String[] orderByFields = obc.getOrderByFields();
3034
3035 for (int i = 0; i < orderByFields.length; i++) {
3036 query.append("expandoValue.");
3037 query.append(orderByFields[i]);
3038
3039 if (obc.isAscending()) {
3040 query.append(" ASC");
3041 }
3042 else {
3043 query.append(" DESC");
3044 }
3045
3046 if ((i + 1) < orderByFields.length) {
3047 query.append(", ");
3048 }
3049 }
3050 }
3051
3052 else {
3053 query.append("ORDER BY ");
3054
3055 query.append("expandoValue.tableId ASC, ");
3056 query.append("expandoValue.rowId ASC, ");
3057 query.append("expandoValue.columnId ASC");
3058 }
3059
3060 Query q = session.createQuery(query.toString());
3061
3062 QueryPos qPos = QueryPos.getInstance(q);
3063
3064 qPos.add(tableId);
3065
3066 qPos.add(columnId);
3067
3068 if (data != null) {
3069 qPos.add(data);
3070 }
3071
3072 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
3073 expandoValue);
3074
3075 ExpandoValue[] array = new ExpandoValueImpl[3];
3076
3077 array[0] = (ExpandoValue)objArray[0];
3078 array[1] = (ExpandoValue)objArray[1];
3079 array[2] = (ExpandoValue)objArray[2];
3080
3081 return array;
3082 }
3083 catch (Exception e) {
3084 throw processException(e);
3085 }
3086 finally {
3087 closeSession(session);
3088 }
3089 }
3090
3091 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
3092 throws SystemException {
3093 Session session = null;
3094
3095 try {
3096 session = openSession();
3097
3098 dynamicQuery.compile(session);
3099
3100 return dynamicQuery.list();
3101 }
3102 catch (Exception e) {
3103 throw processException(e);
3104 }
3105 finally {
3106 closeSession(session);
3107 }
3108 }
3109
3110 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
3111 int start, int end) throws SystemException {
3112 Session session = null;
3113
3114 try {
3115 session = openSession();
3116
3117 dynamicQuery.setLimit(start, end);
3118
3119 dynamicQuery.compile(session);
3120
3121 return dynamicQuery.list();
3122 }
3123 catch (Exception e) {
3124 throw processException(e);
3125 }
3126 finally {
3127 closeSession(session);
3128 }
3129 }
3130
3131 public List<ExpandoValue> findAll() throws SystemException {
3132 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3133 }
3134
3135 public List<ExpandoValue> findAll(int start, int end)
3136 throws SystemException {
3137 return findAll(start, end, null);
3138 }
3139
3140 public List<ExpandoValue> findAll(int start, int end, OrderByComparator obc)
3141 throws SystemException {
3142 Object[] finderArgs = new Object[] {
3143 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3144 };
3145
3146 List<ExpandoValue> list = (List<ExpandoValue>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3147 finderArgs, this);
3148
3149 if (list == null) {
3150 Session session = null;
3151
3152 try {
3153 session = openSession();
3154
3155 StringBuilder query = new StringBuilder();
3156
3157 query.append(
3158 "SELECT expandoValue FROM ExpandoValue expandoValue ");
3159
3160 if (obc != null) {
3161 query.append("ORDER BY ");
3162
3163 String[] orderByFields = obc.getOrderByFields();
3164
3165 for (int i = 0; i < orderByFields.length; i++) {
3166 query.append("expandoValue.");
3167 query.append(orderByFields[i]);
3168
3169 if (obc.isAscending()) {
3170 query.append(" ASC");
3171 }
3172 else {
3173 query.append(" DESC");
3174 }
3175
3176 if ((i + 1) < orderByFields.length) {
3177 query.append(", ");
3178 }
3179 }
3180 }
3181
3182 else {
3183 query.append("ORDER BY ");
3184
3185 query.append("expandoValue.tableId ASC, ");
3186 query.append("expandoValue.rowId ASC, ");
3187 query.append("expandoValue.columnId ASC");
3188 }
3189
3190 Query q = session.createQuery(query.toString());
3191
3192 if (obc == null) {
3193 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
3194 start, end, false);
3195
3196 Collections.sort(list);
3197 }
3198 else {
3199 list = (List<ExpandoValue>)QueryUtil.list(q, getDialect(),
3200 start, end);
3201 }
3202 }
3203 catch (Exception e) {
3204 throw processException(e);
3205 }
3206 finally {
3207 if (list == null) {
3208 list = new ArrayList<ExpandoValue>();
3209 }
3210
3211 cacheResult(list);
3212
3213 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3214
3215 closeSession(session);
3216 }
3217 }
3218
3219 return list;
3220 }
3221
3222 public void removeByTableId(long tableId) throws SystemException {
3223 for (ExpandoValue expandoValue : findByTableId(tableId)) {
3224 remove(expandoValue);
3225 }
3226 }
3227
3228 public void removeByColumnId(long columnId) throws SystemException {
3229 for (ExpandoValue expandoValue : findByColumnId(columnId)) {
3230 remove(expandoValue);
3231 }
3232 }
3233
3234 public void removeByRowId(long rowId) throws SystemException {
3235 for (ExpandoValue expandoValue : findByRowId(rowId)) {
3236 remove(expandoValue);
3237 }
3238 }
3239
3240 public void removeByT_C(long tableId, long columnId)
3241 throws SystemException {
3242 for (ExpandoValue expandoValue : findByT_C(tableId, columnId)) {
3243 remove(expandoValue);
3244 }
3245 }
3246
3247 public void removeByT_CPK(long tableId, long classPK)
3248 throws SystemException {
3249 for (ExpandoValue expandoValue : findByT_CPK(tableId, classPK)) {
3250 remove(expandoValue);
3251 }
3252 }
3253
3254 public void removeByT_R(long tableId, long rowId) throws SystemException {
3255 for (ExpandoValue expandoValue : findByT_R(tableId, rowId)) {
3256 remove(expandoValue);
3257 }
3258 }
3259
3260 public void removeByC_R(long columnId, long rowId)
3261 throws NoSuchValueException, SystemException {
3262 ExpandoValue expandoValue = findByC_R(columnId, rowId);
3263
3264 remove(expandoValue);
3265 }
3266
3267 public void removeByC_C(long classNameId, long classPK)
3268 throws SystemException {
3269 for (ExpandoValue expandoValue : findByC_C(classNameId, classPK)) {
3270 remove(expandoValue);
3271 }
3272 }
3273
3274 public void removeByT_C_C(long tableId, long columnId, long classPK)
3275 throws NoSuchValueException, SystemException {
3276 ExpandoValue expandoValue = findByT_C_C(tableId, columnId, classPK);
3277
3278 remove(expandoValue);
3279 }
3280
3281 public void removeByT_C_D(long tableId, long columnId, String data)
3282 throws SystemException {
3283 for (ExpandoValue expandoValue : findByT_C_D(tableId, columnId, data)) {
3284 remove(expandoValue);
3285 }
3286 }
3287
3288 public void removeAll() throws SystemException {
3289 for (ExpandoValue expandoValue : findAll()) {
3290 remove(expandoValue);
3291 }
3292 }
3293
3294 public int countByTableId(long tableId) throws SystemException {
3295 Object[] finderArgs = new Object[] { new Long(tableId) };
3296
3297 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TABLEID,
3298 finderArgs, this);
3299
3300 if (count == null) {
3301 Session session = null;
3302
3303 try {
3304 session = openSession();
3305
3306 StringBuilder query = new StringBuilder();
3307
3308 query.append("SELECT COUNT(expandoValue) ");
3309 query.append("FROM ExpandoValue expandoValue WHERE ");
3310
3311 query.append("expandoValue.tableId = ?");
3312
3313 query.append(" ");
3314
3315 Query q = session.createQuery(query.toString());
3316
3317 QueryPos qPos = QueryPos.getInstance(q);
3318
3319 qPos.add(tableId);
3320
3321 count = (Long)q.uniqueResult();
3322 }
3323 catch (Exception e) {
3324 throw processException(e);
3325 }
3326 finally {
3327 if (count == null) {
3328 count = Long.valueOf(0);
3329 }
3330
3331 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TABLEID,
3332 finderArgs, count);
3333
3334 closeSession(session);
3335 }
3336 }
3337
3338 return count.intValue();
3339 }
3340
3341 public int countByColumnId(long columnId) throws SystemException {
3342 Object[] finderArgs = new Object[] { new Long(columnId) };
3343
3344 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COLUMNID,
3345 finderArgs, this);
3346
3347 if (count == null) {
3348 Session session = null;
3349
3350 try {
3351 session = openSession();
3352
3353 StringBuilder query = new StringBuilder();
3354
3355 query.append("SELECT COUNT(expandoValue) ");
3356 query.append("FROM ExpandoValue expandoValue WHERE ");
3357
3358 query.append("expandoValue.columnId = ?");
3359
3360 query.append(" ");
3361
3362 Query q = session.createQuery(query.toString());
3363
3364 QueryPos qPos = QueryPos.getInstance(q);
3365
3366 qPos.add(columnId);
3367
3368 count = (Long)q.uniqueResult();
3369 }
3370 catch (Exception e) {
3371 throw processException(e);
3372 }
3373 finally {
3374 if (count == null) {
3375 count = Long.valueOf(0);
3376 }
3377
3378 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COLUMNID,
3379 finderArgs, count);
3380
3381 closeSession(session);
3382 }
3383 }
3384
3385 return count.intValue();
3386 }
3387
3388 public int countByRowId(long rowId) throws SystemException {
3389 Object[] finderArgs = new Object[] { new Long(rowId) };
3390
3391 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROWID,
3392 finderArgs, this);
3393
3394 if (count == null) {
3395 Session session = null;
3396
3397 try {
3398 session = openSession();
3399
3400 StringBuilder query = new StringBuilder();
3401
3402 query.append("SELECT COUNT(expandoValue) ");
3403 query.append("FROM ExpandoValue expandoValue WHERE ");
3404
3405 query.append("expandoValue.rowId = ?");
3406
3407 query.append(" ");
3408
3409 Query q = session.createQuery(query.toString());
3410
3411 QueryPos qPos = QueryPos.getInstance(q);
3412
3413 qPos.add(rowId);
3414
3415 count = (Long)q.uniqueResult();
3416 }
3417 catch (Exception e) {
3418 throw processException(e);
3419 }
3420 finally {
3421 if (count == null) {
3422 count = Long.valueOf(0);
3423 }
3424
3425 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROWID,
3426 finderArgs, count);
3427
3428 closeSession(session);
3429 }
3430 }
3431
3432 return count.intValue();
3433 }
3434
3435 public int countByT_C(long tableId, long columnId)
3436 throws SystemException {
3437 Object[] finderArgs = new Object[] { new Long(tableId), new Long(columnId) };
3438
3439 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_C,
3440 finderArgs, this);
3441
3442 if (count == null) {
3443 Session session = null;
3444
3445 try {
3446 session = openSession();
3447
3448 StringBuilder query = new StringBuilder();
3449
3450 query.append("SELECT COUNT(expandoValue) ");
3451 query.append("FROM ExpandoValue expandoValue WHERE ");
3452
3453 query.append("expandoValue.tableId = ?");
3454
3455 query.append(" AND ");
3456
3457 query.append("expandoValue.columnId = ?");
3458
3459 query.append(" ");
3460
3461 Query q = session.createQuery(query.toString());
3462
3463 QueryPos qPos = QueryPos.getInstance(q);
3464
3465 qPos.add(tableId);
3466
3467 qPos.add(columnId);
3468
3469 count = (Long)q.uniqueResult();
3470 }
3471 catch (Exception e) {
3472 throw processException(e);
3473 }
3474 finally {
3475 if (count == null) {
3476 count = Long.valueOf(0);
3477 }
3478
3479 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_C, finderArgs,
3480 count);
3481
3482 closeSession(session);
3483 }
3484 }
3485
3486 return count.intValue();
3487 }
3488
3489 public int countByT_CPK(long tableId, long classPK)
3490 throws SystemException {
3491 Object[] finderArgs = new Object[] { new Long(tableId), new Long(classPK) };
3492
3493 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_CPK,
3494 finderArgs, this);
3495
3496 if (count == null) {
3497 Session session = null;
3498
3499 try {
3500 session = openSession();
3501
3502 StringBuilder query = new StringBuilder();
3503
3504 query.append("SELECT COUNT(expandoValue) ");
3505 query.append("FROM ExpandoValue expandoValue WHERE ");
3506
3507 query.append("expandoValue.tableId = ?");
3508
3509 query.append(" AND ");
3510
3511 query.append("expandoValue.classPK = ?");
3512
3513 query.append(" ");
3514
3515 Query q = session.createQuery(query.toString());
3516
3517 QueryPos qPos = QueryPos.getInstance(q);
3518
3519 qPos.add(tableId);
3520
3521 qPos.add(classPK);
3522
3523 count = (Long)q.uniqueResult();
3524 }
3525 catch (Exception e) {
3526 throw processException(e);
3527 }
3528 finally {
3529 if (count == null) {
3530 count = Long.valueOf(0);
3531 }
3532
3533 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_CPK,
3534 finderArgs, count);
3535
3536 closeSession(session);
3537 }
3538 }
3539
3540 return count.intValue();
3541 }
3542
3543 public int countByT_R(long tableId, long rowId) throws SystemException {
3544 Object[] finderArgs = new Object[] { new Long(tableId), new Long(rowId) };
3545
3546 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_R,
3547 finderArgs, this);
3548
3549 if (count == null) {
3550 Session session = null;
3551
3552 try {
3553 session = openSession();
3554
3555 StringBuilder query = new StringBuilder();
3556
3557 query.append("SELECT COUNT(expandoValue) ");
3558 query.append("FROM ExpandoValue expandoValue WHERE ");
3559
3560 query.append("expandoValue.tableId = ?");
3561
3562 query.append(" AND ");
3563
3564 query.append("expandoValue.rowId = ?");
3565
3566 query.append(" ");
3567
3568 Query q = session.createQuery(query.toString());
3569
3570 QueryPos qPos = QueryPos.getInstance(q);
3571
3572 qPos.add(tableId);
3573
3574 qPos.add(rowId);
3575
3576 count = (Long)q.uniqueResult();
3577 }
3578 catch (Exception e) {
3579 throw processException(e);
3580 }
3581 finally {
3582 if (count == null) {
3583 count = Long.valueOf(0);
3584 }
3585
3586 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_R, finderArgs,
3587 count);
3588
3589 closeSession(session);
3590 }
3591 }
3592
3593 return count.intValue();
3594 }
3595
3596 public int countByC_R(long columnId, long rowId) throws SystemException {
3597 Object[] finderArgs = new Object[] { new Long(columnId), new Long(rowId) };
3598
3599 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_R,
3600 finderArgs, this);
3601
3602 if (count == null) {
3603 Session session = null;
3604
3605 try {
3606 session = openSession();
3607
3608 StringBuilder query = new StringBuilder();
3609
3610 query.append("SELECT COUNT(expandoValue) ");
3611 query.append("FROM ExpandoValue expandoValue WHERE ");
3612
3613 query.append("expandoValue.columnId = ?");
3614
3615 query.append(" AND ");
3616
3617 query.append("expandoValue.rowId = ?");
3618
3619 query.append(" ");
3620
3621 Query q = session.createQuery(query.toString());
3622
3623 QueryPos qPos = QueryPos.getInstance(q);
3624
3625 qPos.add(columnId);
3626
3627 qPos.add(rowId);
3628
3629 count = (Long)q.uniqueResult();
3630 }
3631 catch (Exception e) {
3632 throw processException(e);
3633 }
3634 finally {
3635 if (count == null) {
3636 count = Long.valueOf(0);
3637 }
3638
3639 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_R, finderArgs,
3640 count);
3641
3642 closeSession(session);
3643 }
3644 }
3645
3646 return count.intValue();
3647 }
3648
3649 public int countByC_C(long classNameId, long classPK)
3650 throws SystemException {
3651 Object[] finderArgs = new Object[] {
3652 new Long(classNameId), new Long(classPK)
3653 };
3654
3655 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3656 finderArgs, this);
3657
3658 if (count == null) {
3659 Session session = null;
3660
3661 try {
3662 session = openSession();
3663
3664 StringBuilder query = new StringBuilder();
3665
3666 query.append("SELECT COUNT(expandoValue) ");
3667 query.append("FROM ExpandoValue expandoValue WHERE ");
3668
3669 query.append("expandoValue.classNameId = ?");
3670
3671 query.append(" AND ");
3672
3673 query.append("expandoValue.classPK = ?");
3674
3675 query.append(" ");
3676
3677 Query q = session.createQuery(query.toString());
3678
3679 QueryPos qPos = QueryPos.getInstance(q);
3680
3681 qPos.add(classNameId);
3682
3683 qPos.add(classPK);
3684
3685 count = (Long)q.uniqueResult();
3686 }
3687 catch (Exception e) {
3688 throw processException(e);
3689 }
3690 finally {
3691 if (count == null) {
3692 count = Long.valueOf(0);
3693 }
3694
3695 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3696 count);
3697
3698 closeSession(session);
3699 }
3700 }
3701
3702 return count.intValue();
3703 }
3704
3705 public int countByT_C_C(long tableId, long columnId, long classPK)
3706 throws SystemException {
3707 Object[] finderArgs = new Object[] {
3708 new Long(tableId), new Long(columnId), new Long(classPK)
3709 };
3710
3711 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_C_C,
3712 finderArgs, this);
3713
3714 if (count == null) {
3715 Session session = null;
3716
3717 try {
3718 session = openSession();
3719
3720 StringBuilder query = new StringBuilder();
3721
3722 query.append("SELECT COUNT(expandoValue) ");
3723 query.append("FROM ExpandoValue expandoValue WHERE ");
3724
3725 query.append("expandoValue.tableId = ?");
3726
3727 query.append(" AND ");
3728
3729 query.append("expandoValue.columnId = ?");
3730
3731 query.append(" AND ");
3732
3733 query.append("expandoValue.classPK = ?");
3734
3735 query.append(" ");
3736
3737 Query q = session.createQuery(query.toString());
3738
3739 QueryPos qPos = QueryPos.getInstance(q);
3740
3741 qPos.add(tableId);
3742
3743 qPos.add(columnId);
3744
3745 qPos.add(classPK);
3746
3747 count = (Long)q.uniqueResult();
3748 }
3749 catch (Exception e) {
3750 throw processException(e);
3751 }
3752 finally {
3753 if (count == null) {
3754 count = Long.valueOf(0);
3755 }
3756
3757 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_C_C,
3758 finderArgs, count);
3759
3760 closeSession(session);
3761 }
3762 }
3763
3764 return count.intValue();
3765 }
3766
3767 public int countByT_C_D(long tableId, long columnId, String data)
3768 throws SystemException {
3769 Object[] finderArgs = new Object[] {
3770 new Long(tableId), new Long(columnId),
3771
3772 data
3773 };
3774
3775 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_C_D,
3776 finderArgs, this);
3777
3778 if (count == null) {
3779 Session session = null;
3780
3781 try {
3782 session = openSession();
3783
3784 StringBuilder query = new StringBuilder();
3785
3786 query.append("SELECT COUNT(expandoValue) ");
3787 query.append("FROM ExpandoValue expandoValue WHERE ");
3788
3789 query.append("expandoValue.tableId = ?");
3790
3791 query.append(" AND ");
3792
3793 query.append("expandoValue.columnId = ?");
3794
3795 query.append(" AND ");
3796
3797 if (data == null) {
3798 query.append("expandoValue.data IS NULL");
3799 }
3800 else {
3801 query.append("expandoValue.data = ?");
3802 }
3803
3804 query.append(" ");
3805
3806 Query q = session.createQuery(query.toString());
3807
3808 QueryPos qPos = QueryPos.getInstance(q);
3809
3810 qPos.add(tableId);
3811
3812 qPos.add(columnId);
3813
3814 if (data != null) {
3815 qPos.add(data);
3816 }
3817
3818 count = (Long)q.uniqueResult();
3819 }
3820 catch (Exception e) {
3821 throw processException(e);
3822 }
3823 finally {
3824 if (count == null) {
3825 count = Long.valueOf(0);
3826 }
3827
3828 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_C_D,
3829 finderArgs, count);
3830
3831 closeSession(session);
3832 }
3833 }
3834
3835 return count.intValue();
3836 }
3837
3838 public int countAll() throws SystemException {
3839 Object[] finderArgs = new Object[0];
3840
3841 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3842 finderArgs, this);
3843
3844 if (count == null) {
3845 Session session = null;
3846
3847 try {
3848 session = openSession();
3849
3850 Query q = session.createQuery(
3851 "SELECT COUNT(expandoValue) FROM ExpandoValue expandoValue");
3852
3853 count = (Long)q.uniqueResult();
3854 }
3855 catch (Exception e) {
3856 throw processException(e);
3857 }
3858 finally {
3859 if (count == null) {
3860 count = Long.valueOf(0);
3861 }
3862
3863 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3864 count);
3865
3866 closeSession(session);
3867 }
3868 }
3869
3870 return count.intValue();
3871 }
3872
3873 public void afterPropertiesSet() {
3874 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3875 com.liferay.portal.util.PropsUtil.get(
3876 "value.object.listener.com.liferay.portlet.expando.model.ExpandoValue")));
3877
3878 if (listenerClassNames.length > 0) {
3879 try {
3880 List<ModelListener<ExpandoValue>> listenersList = new ArrayList<ModelListener<ExpandoValue>>();
3881
3882 for (String listenerClassName : listenerClassNames) {
3883 listenersList.add((ModelListener<ExpandoValue>)Class.forName(
3884 listenerClassName).newInstance());
3885 }
3886
3887 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3888 }
3889 catch (Exception e) {
3890 _log.error(e);
3891 }
3892 }
3893 }
3894
3895 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence.impl")
3896 protected com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence expandoColumnPersistence;
3897 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoRowPersistence.impl")
3898 protected com.liferay.portlet.expando.service.persistence.ExpandoRowPersistence expandoRowPersistence;
3899 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoTablePersistence.impl")
3900 protected com.liferay.portlet.expando.service.persistence.ExpandoTablePersistence expandoTablePersistence;
3901 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
3902 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
3903 private static Log _log = LogFactoryUtil.getLog(ExpandoValuePersistenceImpl.class);
3904}