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