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