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