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