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