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