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