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