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