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