1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.tags.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.StringPool;
41  import com.liferay.portal.kernel.util.StringUtil;
42  import com.liferay.portal.kernel.util.Validator;
43  import com.liferay.portal.model.ModelListener;
44  import com.liferay.portal.service.persistence.BatchSessionUtil;
45  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46  
47  import com.liferay.portlet.tags.NoSuchPropertyException;
48  import com.liferay.portlet.tags.model.TagsProperty;
49  import com.liferay.portlet.tags.model.impl.TagsPropertyImpl;
50  import com.liferay.portlet.tags.model.impl.TagsPropertyModelImpl;
51  
52  import java.util.ArrayList;
53  import java.util.Collections;
54  import java.util.List;
55  
56  /**
57   * <a href="TagsPropertyPersistenceImpl.java.html"><b><i>View Source</i></b></a>
58   *
59   * <p>
60   * ServiceBuilder generated this class. Modifications in this class will be
61   * overwritten the next time is generated.
62   * </p>
63   *
64   * @author    Brian Wing Shun Chan
65   * @see       TagsPropertyPersistence
66   * @see       TagsPropertyUtil
67   * @generated
68   */
69  public class TagsPropertyPersistenceImpl extends BasePersistenceImpl
70      implements TagsPropertyPersistence {
71      public static final String FINDER_CLASS_NAME_ENTITY = TagsPropertyImpl.class.getName();
72      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
73          ".List";
74      public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
75              TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
76              "findByCompanyId", new String[] { Long.class.getName() });
77      public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
78              TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
79              "findByCompanyId",
80              new String[] {
81                  Long.class.getName(),
82                  
83              "java.lang.Integer", "java.lang.Integer",
84                  "com.liferay.portal.kernel.util.OrderByComparator"
85              });
86      public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
87              TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88              "countByCompanyId", new String[] { Long.class.getName() });
89      public static final FinderPath FINDER_PATH_FIND_BY_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
90              TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91              "findByEntryId", new String[] { Long.class.getName() });
92      public static final FinderPath FINDER_PATH_FIND_BY_OBC_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
93              TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94              "findByEntryId",
95              new String[] {
96                  Long.class.getName(),
97                  
98              "java.lang.Integer", "java.lang.Integer",
99                  "com.liferay.portal.kernel.util.OrderByComparator"
100             });
101     public static final FinderPath FINDER_PATH_COUNT_BY_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
102             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103             "countByEntryId", new String[] { Long.class.getName() });
104     public static final FinderPath FINDER_PATH_FIND_BY_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
105             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106             "findByC_K",
107             new String[] { Long.class.getName(), String.class.getName() });
108     public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
109             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110             "findByC_K",
111             new String[] {
112                 Long.class.getName(), String.class.getName(),
113                 
114             "java.lang.Integer", "java.lang.Integer",
115                 "com.liferay.portal.kernel.util.OrderByComparator"
116             });
117     public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
118             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119             "countByC_K",
120             new String[] { Long.class.getName(), String.class.getName() });
121     public static final FinderPath FINDER_PATH_FETCH_BY_E_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
122             TagsPropertyModelImpl.FINDER_CACHE_ENABLED,
123             FINDER_CLASS_NAME_ENTITY, "fetchByE_K",
124             new String[] { Long.class.getName(), String.class.getName() });
125     public static final FinderPath FINDER_PATH_COUNT_BY_E_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
126             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127             "countByE_K",
128             new String[] { Long.class.getName(), String.class.getName() });
129     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
130             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131             "findAll", new String[0]);
132     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
133             TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134             "countAll", new String[0]);
135 
136     public void cacheResult(TagsProperty tagsProperty) {
137         EntityCacheUtil.putResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
138             TagsPropertyImpl.class, tagsProperty.getPrimaryKey(), tagsProperty);
139 
140         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
141             new Object[] {
142                 new Long(tagsProperty.getEntryId()),
143                 
144             tagsProperty.getKey()
145             }, tagsProperty);
146     }
147 
148     public void cacheResult(List<TagsProperty> tagsProperties) {
149         for (TagsProperty tagsProperty : tagsProperties) {
150             if (EntityCacheUtil.getResult(
151                         TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
152                         TagsPropertyImpl.class, tagsProperty.getPrimaryKey(),
153                         this) == null) {
154                 cacheResult(tagsProperty);
155             }
156         }
157     }
158 
159     public void clearCache() {
160         CacheRegistry.clear(TagsPropertyImpl.class.getName());
161         EntityCacheUtil.clearCache(TagsPropertyImpl.class.getName());
162         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
163         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
164     }
165 
166     public TagsProperty create(long propertyId) {
167         TagsProperty tagsProperty = new TagsPropertyImpl();
168 
169         tagsProperty.setNew(true);
170         tagsProperty.setPrimaryKey(propertyId);
171 
172         return tagsProperty;
173     }
174 
175     public TagsProperty remove(long propertyId)
176         throws NoSuchPropertyException, SystemException {
177         Session session = null;
178 
179         try {
180             session = openSession();
181 
182             TagsProperty tagsProperty = (TagsProperty)session.get(TagsPropertyImpl.class,
183                     new Long(propertyId));
184 
185             if (tagsProperty == null) {
186                 if (_log.isWarnEnabled()) {
187                     _log.warn("No TagsProperty exists with the primary key " +
188                         propertyId);
189                 }
190 
191                 throw new NoSuchPropertyException(
192                     "No TagsProperty exists with the primary key " +
193                     propertyId);
194             }
195 
196             return remove(tagsProperty);
197         }
198         catch (NoSuchPropertyException nsee) {
199             throw nsee;
200         }
201         catch (Exception e) {
202             throw processException(e);
203         }
204         finally {
205             closeSession(session);
206         }
207     }
208 
209     public TagsProperty remove(TagsProperty tagsProperty)
210         throws SystemException {
211         for (ModelListener<TagsProperty> listener : listeners) {
212             listener.onBeforeRemove(tagsProperty);
213         }
214 
215         tagsProperty = removeImpl(tagsProperty);
216 
217         for (ModelListener<TagsProperty> listener : listeners) {
218             listener.onAfterRemove(tagsProperty);
219         }
220 
221         return tagsProperty;
222     }
223 
224     protected TagsProperty removeImpl(TagsProperty tagsProperty)
225         throws SystemException {
226         tagsProperty = toUnwrappedModel(tagsProperty);
227 
228         Session session = null;
229 
230         try {
231             session = openSession();
232 
233             if (tagsProperty.isCachedModel() || BatchSessionUtil.isEnabled()) {
234                 Object staleObject = session.get(TagsPropertyImpl.class,
235                         tagsProperty.getPrimaryKeyObj());
236 
237                 if (staleObject != null) {
238                     session.evict(staleObject);
239                 }
240             }
241 
242             session.delete(tagsProperty);
243 
244             session.flush();
245         }
246         catch (Exception e) {
247             throw processException(e);
248         }
249         finally {
250             closeSession(session);
251         }
252 
253         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
254 
255         TagsPropertyModelImpl tagsPropertyModelImpl = (TagsPropertyModelImpl)tagsProperty;
256 
257         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_K,
258             new Object[] {
259                 new Long(tagsPropertyModelImpl.getOriginalEntryId()),
260                 
261             tagsPropertyModelImpl.getOriginalKey()
262             });
263 
264         EntityCacheUtil.removeResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
265             TagsPropertyImpl.class, tagsProperty.getPrimaryKey());
266 
267         return tagsProperty;
268     }
269 
270     /**
271      * @deprecated Use {@link #update(TagsProperty, boolean merge)}.
272      */
273     public TagsProperty update(TagsProperty tagsProperty)
274         throws SystemException {
275         if (_log.isWarnEnabled()) {
276             _log.warn(
277                 "Using the deprecated update(TagsProperty tagsProperty) method. Use update(TagsProperty tagsProperty, boolean merge) instead.");
278         }
279 
280         return update(tagsProperty, false);
281     }
282 
283     /**
284      * Add, update, or merge, the entity. This method also calls the model
285      * listeners to trigger the proper events associated with adding, deleting,
286      * or updating an entity.
287      *
288      * @param  tagsProperty the entity to add, update, or merge
289      * @param  merge boolean value for whether to merge the entity. The default
290      *         value is false. Setting merge to true is more expensive and
291      *         should only be true when tagsProperty is transient. See
292      *         LEP-5473 for a detailed discussion of this method.
293      * @return the entity that was added, updated, or merged
294      */
295     public TagsProperty update(TagsProperty tagsProperty, boolean merge)
296         throws SystemException {
297         boolean isNew = tagsProperty.isNew();
298 
299         for (ModelListener<TagsProperty> listener : listeners) {
300             if (isNew) {
301                 listener.onBeforeCreate(tagsProperty);
302             }
303             else {
304                 listener.onBeforeUpdate(tagsProperty);
305             }
306         }
307 
308         tagsProperty = updateImpl(tagsProperty, merge);
309 
310         for (ModelListener<TagsProperty> listener : listeners) {
311             if (isNew) {
312                 listener.onAfterCreate(tagsProperty);
313             }
314             else {
315                 listener.onAfterUpdate(tagsProperty);
316             }
317         }
318 
319         return tagsProperty;
320     }
321 
322     public TagsProperty updateImpl(
323         com.liferay.portlet.tags.model.TagsProperty tagsProperty, boolean merge)
324         throws SystemException {
325         tagsProperty = toUnwrappedModel(tagsProperty);
326 
327         boolean isNew = tagsProperty.isNew();
328 
329         TagsPropertyModelImpl tagsPropertyModelImpl = (TagsPropertyModelImpl)tagsProperty;
330 
331         Session session = null;
332 
333         try {
334             session = openSession();
335 
336             BatchSessionUtil.update(session, tagsProperty, merge);
337 
338             tagsProperty.setNew(false);
339         }
340         catch (Exception e) {
341             throw processException(e);
342         }
343         finally {
344             closeSession(session);
345         }
346 
347         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
348 
349         EntityCacheUtil.putResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
350             TagsPropertyImpl.class, tagsProperty.getPrimaryKey(), tagsProperty);
351 
352         if (!isNew &&
353                 ((tagsProperty.getEntryId() != tagsPropertyModelImpl.getOriginalEntryId()) ||
354                 !Validator.equals(tagsProperty.getKey(),
355                     tagsPropertyModelImpl.getOriginalKey()))) {
356             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_K,
357                 new Object[] {
358                     new Long(tagsPropertyModelImpl.getOriginalEntryId()),
359                     
360                 tagsPropertyModelImpl.getOriginalKey()
361                 });
362         }
363 
364         if (isNew ||
365                 ((tagsProperty.getEntryId() != tagsPropertyModelImpl.getOriginalEntryId()) ||
366                 !Validator.equals(tagsProperty.getKey(),
367                     tagsPropertyModelImpl.getOriginalKey()))) {
368             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
369                 new Object[] {
370                     new Long(tagsProperty.getEntryId()),
371                     
372                 tagsProperty.getKey()
373                 }, tagsProperty);
374         }
375 
376         return tagsProperty;
377     }
378 
379     protected TagsProperty toUnwrappedModel(TagsProperty tagsProperty) {
380         if (tagsProperty instanceof TagsPropertyImpl) {
381             return tagsProperty;
382         }
383 
384         TagsPropertyImpl tagsPropertyImpl = new TagsPropertyImpl();
385 
386         tagsPropertyImpl.setNew(tagsProperty.isNew());
387         tagsPropertyImpl.setPrimaryKey(tagsProperty.getPrimaryKey());
388 
389         tagsPropertyImpl.setPropertyId(tagsProperty.getPropertyId());
390         tagsPropertyImpl.setCompanyId(tagsProperty.getCompanyId());
391         tagsPropertyImpl.setUserId(tagsProperty.getUserId());
392         tagsPropertyImpl.setUserName(tagsProperty.getUserName());
393         tagsPropertyImpl.setCreateDate(tagsProperty.getCreateDate());
394         tagsPropertyImpl.setModifiedDate(tagsProperty.getModifiedDate());
395         tagsPropertyImpl.setEntryId(tagsProperty.getEntryId());
396         tagsPropertyImpl.setKey(tagsProperty.getKey());
397         tagsPropertyImpl.setValue(tagsProperty.getValue());
398 
399         return tagsPropertyImpl;
400     }
401 
402     public TagsProperty findByPrimaryKey(long propertyId)
403         throws NoSuchPropertyException, SystemException {
404         TagsProperty tagsProperty = fetchByPrimaryKey(propertyId);
405 
406         if (tagsProperty == null) {
407             if (_log.isWarnEnabled()) {
408                 _log.warn("No TagsProperty exists with the primary key " +
409                     propertyId);
410             }
411 
412             throw new NoSuchPropertyException(
413                 "No TagsProperty exists with the primary key " + propertyId);
414         }
415 
416         return tagsProperty;
417     }
418 
419     public TagsProperty fetchByPrimaryKey(long propertyId)
420         throws SystemException {
421         TagsProperty tagsProperty = (TagsProperty)EntityCacheUtil.getResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
422                 TagsPropertyImpl.class, propertyId, this);
423 
424         if (tagsProperty == null) {
425             Session session = null;
426 
427             try {
428                 session = openSession();
429 
430                 tagsProperty = (TagsProperty)session.get(TagsPropertyImpl.class,
431                         new Long(propertyId));
432             }
433             catch (Exception e) {
434                 throw processException(e);
435             }
436             finally {
437                 if (tagsProperty != null) {
438                     cacheResult(tagsProperty);
439                 }
440 
441                 closeSession(session);
442             }
443         }
444 
445         return tagsProperty;
446     }
447 
448     public List<TagsProperty> findByCompanyId(long companyId)
449         throws SystemException {
450         Object[] finderArgs = new Object[] { new Long(companyId) };
451 
452         List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
453                 finderArgs, this);
454 
455         if (list == null) {
456             Session session = null;
457 
458             try {
459                 session = openSession();
460 
461                 StringBuilder query = new StringBuilder();
462 
463                 query.append(
464                     "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
465 
466                 query.append("tagsProperty.companyId = ?");
467 
468                 query.append(" ");
469 
470                 query.append("ORDER BY ");
471 
472                 query.append("tagsProperty.key ASC");
473 
474                 Query q = session.createQuery(query.toString());
475 
476                 QueryPos qPos = QueryPos.getInstance(q);
477 
478                 qPos.add(companyId);
479 
480                 list = q.list();
481             }
482             catch (Exception e) {
483                 throw processException(e);
484             }
485             finally {
486                 if (list == null) {
487                     list = new ArrayList<TagsProperty>();
488                 }
489 
490                 cacheResult(list);
491 
492                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
493                     finderArgs, list);
494 
495                 closeSession(session);
496             }
497         }
498 
499         return list;
500     }
501 
502     public List<TagsProperty> findByCompanyId(long companyId, int start, int end)
503         throws SystemException {
504         return findByCompanyId(companyId, start, end, null);
505     }
506 
507     public List<TagsProperty> findByCompanyId(long companyId, int start,
508         int end, OrderByComparator obc) throws SystemException {
509         Object[] finderArgs = new Object[] {
510                 new Long(companyId),
511                 
512                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
513             };
514 
515         List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
516                 finderArgs, this);
517 
518         if (list == null) {
519             Session session = null;
520 
521             try {
522                 session = openSession();
523 
524                 StringBuilder query = new StringBuilder();
525 
526                 query.append(
527                     "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
528 
529                 query.append("tagsProperty.companyId = ?");
530 
531                 query.append(" ");
532 
533                 if (obc != null) {
534                     query.append("ORDER BY ");
535 
536                     String[] orderByFields = obc.getOrderByFields();
537 
538                     for (int i = 0; i < orderByFields.length; i++) {
539                         query.append("tagsProperty.");
540                         query.append(orderByFields[i]);
541 
542                         if (obc.isAscending()) {
543                             query.append(" ASC");
544                         }
545                         else {
546                             query.append(" DESC");
547                         }
548 
549                         if ((i + 1) < orderByFields.length) {
550                             query.append(", ");
551                         }
552                     }
553                 }
554 
555                 else {
556                     query.append("ORDER BY ");
557 
558                     query.append("tagsProperty.key ASC");
559                 }
560 
561                 Query q = session.createQuery(query.toString());
562 
563                 QueryPos qPos = QueryPos.getInstance(q);
564 
565                 qPos.add(companyId);
566 
567                 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
568                         start, end);
569             }
570             catch (Exception e) {
571                 throw processException(e);
572             }
573             finally {
574                 if (list == null) {
575                     list = new ArrayList<TagsProperty>();
576                 }
577 
578                 cacheResult(list);
579 
580                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
581                     finderArgs, list);
582 
583                 closeSession(session);
584             }
585         }
586 
587         return list;
588     }
589 
590     public TagsProperty findByCompanyId_First(long companyId,
591         OrderByComparator obc) throws NoSuchPropertyException, SystemException {
592         List<TagsProperty> list = findByCompanyId(companyId, 0, 1, obc);
593 
594         if (list.isEmpty()) {
595             StringBuilder msg = new StringBuilder();
596 
597             msg.append("No TagsProperty exists with the key {");
598 
599             msg.append("companyId=" + companyId);
600 
601             msg.append(StringPool.CLOSE_CURLY_BRACE);
602 
603             throw new NoSuchPropertyException(msg.toString());
604         }
605         else {
606             return list.get(0);
607         }
608     }
609 
610     public TagsProperty findByCompanyId_Last(long companyId,
611         OrderByComparator obc) throws NoSuchPropertyException, SystemException {
612         int count = countByCompanyId(companyId);
613 
614         List<TagsProperty> list = findByCompanyId(companyId, count - 1, count,
615                 obc);
616 
617         if (list.isEmpty()) {
618             StringBuilder msg = new StringBuilder();
619 
620             msg.append("No TagsProperty exists with the key {");
621 
622             msg.append("companyId=" + companyId);
623 
624             msg.append(StringPool.CLOSE_CURLY_BRACE);
625 
626             throw new NoSuchPropertyException(msg.toString());
627         }
628         else {
629             return list.get(0);
630         }
631     }
632 
633     public TagsProperty[] findByCompanyId_PrevAndNext(long propertyId,
634         long companyId, OrderByComparator obc)
635         throws NoSuchPropertyException, SystemException {
636         TagsProperty tagsProperty = findByPrimaryKey(propertyId);
637 
638         int count = countByCompanyId(companyId);
639 
640         Session session = null;
641 
642         try {
643             session = openSession();
644 
645             StringBuilder query = new StringBuilder();
646 
647             query.append(
648                 "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
649 
650             query.append("tagsProperty.companyId = ?");
651 
652             query.append(" ");
653 
654             if (obc != null) {
655                 query.append("ORDER BY ");
656 
657                 String[] orderByFields = obc.getOrderByFields();
658 
659                 for (int i = 0; i < orderByFields.length; i++) {
660                     query.append("tagsProperty.");
661                     query.append(orderByFields[i]);
662 
663                     if (obc.isAscending()) {
664                         query.append(" ASC");
665                     }
666                     else {
667                         query.append(" DESC");
668                     }
669 
670                     if ((i + 1) < orderByFields.length) {
671                         query.append(", ");
672                     }
673                 }
674             }
675 
676             else {
677                 query.append("ORDER BY ");
678 
679                 query.append("tagsProperty.key ASC");
680             }
681 
682             Query q = session.createQuery(query.toString());
683 
684             QueryPos qPos = QueryPos.getInstance(q);
685 
686             qPos.add(companyId);
687 
688             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
689                     tagsProperty);
690 
691             TagsProperty[] array = new TagsPropertyImpl[3];
692 
693             array[0] = (TagsProperty)objArray[0];
694             array[1] = (TagsProperty)objArray[1];
695             array[2] = (TagsProperty)objArray[2];
696 
697             return array;
698         }
699         catch (Exception e) {
700             throw processException(e);
701         }
702         finally {
703             closeSession(session);
704         }
705     }
706 
707     public List<TagsProperty> findByEntryId(long entryId)
708         throws SystemException {
709         Object[] finderArgs = new Object[] { new Long(entryId) };
710 
711         List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ENTRYID,
712                 finderArgs, this);
713 
714         if (list == null) {
715             Session session = null;
716 
717             try {
718                 session = openSession();
719 
720                 StringBuilder query = new StringBuilder();
721 
722                 query.append(
723                     "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
724 
725                 query.append("tagsProperty.entryId = ?");
726 
727                 query.append(" ");
728 
729                 query.append("ORDER BY ");
730 
731                 query.append("tagsProperty.key ASC");
732 
733                 Query q = session.createQuery(query.toString());
734 
735                 QueryPos qPos = QueryPos.getInstance(q);
736 
737                 qPos.add(entryId);
738 
739                 list = q.list();
740             }
741             catch (Exception e) {
742                 throw processException(e);
743             }
744             finally {
745                 if (list == null) {
746                     list = new ArrayList<TagsProperty>();
747                 }
748 
749                 cacheResult(list);
750 
751                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ENTRYID,
752                     finderArgs, list);
753 
754                 closeSession(session);
755             }
756         }
757 
758         return list;
759     }
760 
761     public List<TagsProperty> findByEntryId(long entryId, int start, int end)
762         throws SystemException {
763         return findByEntryId(entryId, start, end, null);
764     }
765 
766     public List<TagsProperty> findByEntryId(long entryId, int start, int end,
767         OrderByComparator obc) throws SystemException {
768         Object[] finderArgs = new Object[] {
769                 new Long(entryId),
770                 
771                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
772             };
773 
774         List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ENTRYID,
775                 finderArgs, this);
776 
777         if (list == null) {
778             Session session = null;
779 
780             try {
781                 session = openSession();
782 
783                 StringBuilder query = new StringBuilder();
784 
785                 query.append(
786                     "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
787 
788                 query.append("tagsProperty.entryId = ?");
789 
790                 query.append(" ");
791 
792                 if (obc != null) {
793                     query.append("ORDER BY ");
794 
795                     String[] orderByFields = obc.getOrderByFields();
796 
797                     for (int i = 0; i < orderByFields.length; i++) {
798                         query.append("tagsProperty.");
799                         query.append(orderByFields[i]);
800 
801                         if (obc.isAscending()) {
802                             query.append(" ASC");
803                         }
804                         else {
805                             query.append(" DESC");
806                         }
807 
808                         if ((i + 1) < orderByFields.length) {
809                             query.append(", ");
810                         }
811                     }
812                 }
813 
814                 else {
815                     query.append("ORDER BY ");
816 
817                     query.append("tagsProperty.key ASC");
818                 }
819 
820                 Query q = session.createQuery(query.toString());
821 
822                 QueryPos qPos = QueryPos.getInstance(q);
823 
824                 qPos.add(entryId);
825 
826                 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
827                         start, end);
828             }
829             catch (Exception e) {
830                 throw processException(e);
831             }
832             finally {
833                 if (list == null) {
834                     list = new ArrayList<TagsProperty>();
835                 }
836 
837                 cacheResult(list);
838 
839                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ENTRYID,
840                     finderArgs, list);
841 
842                 closeSession(session);
843             }
844         }
845 
846         return list;
847     }
848 
849     public TagsProperty findByEntryId_First(long entryId, OrderByComparator obc)
850         throws NoSuchPropertyException, SystemException {
851         List<TagsProperty> list = findByEntryId(entryId, 0, 1, obc);
852 
853         if (list.isEmpty()) {
854             StringBuilder msg = new StringBuilder();
855 
856             msg.append("No TagsProperty exists with the key {");
857 
858             msg.append("entryId=" + entryId);
859 
860             msg.append(StringPool.CLOSE_CURLY_BRACE);
861 
862             throw new NoSuchPropertyException(msg.toString());
863         }
864         else {
865             return list.get(0);
866         }
867     }
868 
869     public TagsProperty findByEntryId_Last(long entryId, OrderByComparator obc)
870         throws NoSuchPropertyException, SystemException {
871         int count = countByEntryId(entryId);
872 
873         List<TagsProperty> list = findByEntryId(entryId, count - 1, count, obc);
874 
875         if (list.isEmpty()) {
876             StringBuilder msg = new StringBuilder();
877 
878             msg.append("No TagsProperty exists with the key {");
879 
880             msg.append("entryId=" + entryId);
881 
882             msg.append(StringPool.CLOSE_CURLY_BRACE);
883 
884             throw new NoSuchPropertyException(msg.toString());
885         }
886         else {
887             return list.get(0);
888         }
889     }
890 
891     public TagsProperty[] findByEntryId_PrevAndNext(long propertyId,
892         long entryId, OrderByComparator obc)
893         throws NoSuchPropertyException, SystemException {
894         TagsProperty tagsProperty = findByPrimaryKey(propertyId);
895 
896         int count = countByEntryId(entryId);
897 
898         Session session = null;
899 
900         try {
901             session = openSession();
902 
903             StringBuilder query = new StringBuilder();
904 
905             query.append(
906                 "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
907 
908             query.append("tagsProperty.entryId = ?");
909 
910             query.append(" ");
911 
912             if (obc != null) {
913                 query.append("ORDER BY ");
914 
915                 String[] orderByFields = obc.getOrderByFields();
916 
917                 for (int i = 0; i < orderByFields.length; i++) {
918                     query.append("tagsProperty.");
919                     query.append(orderByFields[i]);
920 
921                     if (obc.isAscending()) {
922                         query.append(" ASC");
923                     }
924                     else {
925                         query.append(" DESC");
926                     }
927 
928                     if ((i + 1) < orderByFields.length) {
929                         query.append(", ");
930                     }
931                 }
932             }
933 
934             else {
935                 query.append("ORDER BY ");
936 
937                 query.append("tagsProperty.key ASC");
938             }
939 
940             Query q = session.createQuery(query.toString());
941 
942             QueryPos qPos = QueryPos.getInstance(q);
943 
944             qPos.add(entryId);
945 
946             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
947                     tagsProperty);
948 
949             TagsProperty[] array = new TagsPropertyImpl[3];
950 
951             array[0] = (TagsProperty)objArray[0];
952             array[1] = (TagsProperty)objArray[1];
953             array[2] = (TagsProperty)objArray[2];
954 
955             return array;
956         }
957         catch (Exception e) {
958             throw processException(e);
959         }
960         finally {
961             closeSession(session);
962         }
963     }
964 
965     public List<TagsProperty> findByC_K(long companyId, String key)
966         throws SystemException {
967         Object[] finderArgs = new Object[] { new Long(companyId), key };
968 
969         List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
970                 finderArgs, this);
971 
972         if (list == null) {
973             Session session = null;
974 
975             try {
976                 session = openSession();
977 
978                 StringBuilder query = new StringBuilder();
979 
980                 query.append(
981                     "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
982 
983                 query.append("tagsProperty.companyId = ?");
984 
985                 query.append(" AND ");
986 
987                 if (key == null) {
988                     query.append("tagsProperty.key IS NULL");
989                 }
990                 else {
991                     query.append("tagsProperty.key = ?");
992                 }
993 
994                 query.append(" ");
995 
996                 query.append("ORDER BY ");
997 
998                 query.append("tagsProperty.key ASC");
999 
1000                Query q = session.createQuery(query.toString());
1001
1002                QueryPos qPos = QueryPos.getInstance(q);
1003
1004                qPos.add(companyId);
1005
1006                if (key != null) {
1007                    qPos.add(key);
1008                }
1009
1010                list = q.list();
1011            }
1012            catch (Exception e) {
1013                throw processException(e);
1014            }
1015            finally {
1016                if (list == null) {
1017                    list = new ArrayList<TagsProperty>();
1018                }
1019
1020                cacheResult(list);
1021
1022                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K, finderArgs,
1023                    list);
1024
1025                closeSession(session);
1026            }
1027        }
1028
1029        return list;
1030    }
1031
1032    public List<TagsProperty> findByC_K(long companyId, String key, int start,
1033        int end) throws SystemException {
1034        return findByC_K(companyId, key, start, end, null);
1035    }
1036
1037    public List<TagsProperty> findByC_K(long companyId, String key, int start,
1038        int end, OrderByComparator obc) throws SystemException {
1039        Object[] finderArgs = new Object[] {
1040                new Long(companyId),
1041                
1042                key,
1043                
1044                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1045            };
1046
1047        List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_K,
1048                finderArgs, this);
1049
1050        if (list == null) {
1051            Session session = null;
1052
1053            try {
1054                session = openSession();
1055
1056                StringBuilder query = new StringBuilder();
1057
1058                query.append(
1059                    "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
1060
1061                query.append("tagsProperty.companyId = ?");
1062
1063                query.append(" AND ");
1064
1065                if (key == null) {
1066                    query.append("tagsProperty.key IS NULL");
1067                }
1068                else {
1069                    query.append("tagsProperty.key = ?");
1070                }
1071
1072                query.append(" ");
1073
1074                if (obc != null) {
1075                    query.append("ORDER BY ");
1076
1077                    String[] orderByFields = obc.getOrderByFields();
1078
1079                    for (int i = 0; i < orderByFields.length; i++) {
1080                        query.append("tagsProperty.");
1081                        query.append(orderByFields[i]);
1082
1083                        if (obc.isAscending()) {
1084                            query.append(" ASC");
1085                        }
1086                        else {
1087                            query.append(" DESC");
1088                        }
1089
1090                        if ((i + 1) < orderByFields.length) {
1091                            query.append(", ");
1092                        }
1093                    }
1094                }
1095
1096                else {
1097                    query.append("ORDER BY ");
1098
1099                    query.append("tagsProperty.key ASC");
1100                }
1101
1102                Query q = session.createQuery(query.toString());
1103
1104                QueryPos qPos = QueryPos.getInstance(q);
1105
1106                qPos.add(companyId);
1107
1108                if (key != null) {
1109                    qPos.add(key);
1110                }
1111
1112                list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1113                        start, end);
1114            }
1115            catch (Exception e) {
1116                throw processException(e);
1117            }
1118            finally {
1119                if (list == null) {
1120                    list = new ArrayList<TagsProperty>();
1121                }
1122
1123                cacheResult(list);
1124
1125                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_K,
1126                    finderArgs, list);
1127
1128                closeSession(session);
1129            }
1130        }
1131
1132        return list;
1133    }
1134
1135    public TagsProperty findByC_K_First(long companyId, String key,
1136        OrderByComparator obc) throws NoSuchPropertyException, SystemException {
1137        List<TagsProperty> list = findByC_K(companyId, key, 0, 1, obc);
1138
1139        if (list.isEmpty()) {
1140            StringBuilder msg = new StringBuilder();
1141
1142            msg.append("No TagsProperty exists with the key {");
1143
1144            msg.append("companyId=" + companyId);
1145
1146            msg.append(", ");
1147            msg.append("key=" + key);
1148
1149            msg.append(StringPool.CLOSE_CURLY_BRACE);
1150
1151            throw new NoSuchPropertyException(msg.toString());
1152        }
1153        else {
1154            return list.get(0);
1155        }
1156    }
1157
1158    public TagsProperty findByC_K_Last(long companyId, String key,
1159        OrderByComparator obc) throws NoSuchPropertyException, SystemException {
1160        int count = countByC_K(companyId, key);
1161
1162        List<TagsProperty> list = findByC_K(companyId, key, count - 1, count,
1163                obc);
1164
1165        if (list.isEmpty()) {
1166            StringBuilder msg = new StringBuilder();
1167
1168            msg.append("No TagsProperty exists with the key {");
1169
1170            msg.append("companyId=" + companyId);
1171
1172            msg.append(", ");
1173            msg.append("key=" + key);
1174
1175            msg.append(StringPool.CLOSE_CURLY_BRACE);
1176
1177            throw new NoSuchPropertyException(msg.toString());
1178        }
1179        else {
1180            return list.get(0);
1181        }
1182    }
1183
1184    public TagsProperty[] findByC_K_PrevAndNext(long propertyId,
1185        long companyId, String key, OrderByComparator obc)
1186        throws NoSuchPropertyException, SystemException {
1187        TagsProperty tagsProperty = findByPrimaryKey(propertyId);
1188
1189        int count = countByC_K(companyId, key);
1190
1191        Session session = null;
1192
1193        try {
1194            session = openSession();
1195
1196            StringBuilder query = new StringBuilder();
1197
1198            query.append(
1199                "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
1200
1201            query.append("tagsProperty.companyId = ?");
1202
1203            query.append(" AND ");
1204
1205            if (key == null) {
1206                query.append("tagsProperty.key IS NULL");
1207            }
1208            else {
1209                query.append("tagsProperty.key = ?");
1210            }
1211
1212            query.append(" ");
1213
1214            if (obc != null) {
1215                query.append("ORDER BY ");
1216
1217                String[] orderByFields = obc.getOrderByFields();
1218
1219                for (int i = 0; i < orderByFields.length; i++) {
1220                    query.append("tagsProperty.");
1221                    query.append(orderByFields[i]);
1222
1223                    if (obc.isAscending()) {
1224                        query.append(" ASC");
1225                    }
1226                    else {
1227                        query.append(" DESC");
1228                    }
1229
1230                    if ((i + 1) < orderByFields.length) {
1231                        query.append(", ");
1232                    }
1233                }
1234            }
1235
1236            else {
1237                query.append("ORDER BY ");
1238
1239                query.append("tagsProperty.key ASC");
1240            }
1241
1242            Query q = session.createQuery(query.toString());
1243
1244            QueryPos qPos = QueryPos.getInstance(q);
1245
1246            qPos.add(companyId);
1247
1248            if (key != null) {
1249                qPos.add(key);
1250            }
1251
1252            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1253                    tagsProperty);
1254
1255            TagsProperty[] array = new TagsPropertyImpl[3];
1256
1257            array[0] = (TagsProperty)objArray[0];
1258            array[1] = (TagsProperty)objArray[1];
1259            array[2] = (TagsProperty)objArray[2];
1260
1261            return array;
1262        }
1263        catch (Exception e) {
1264            throw processException(e);
1265        }
1266        finally {
1267            closeSession(session);
1268        }
1269    }
1270
1271    public TagsProperty findByE_K(long entryId, String key)
1272        throws NoSuchPropertyException, SystemException {
1273        TagsProperty tagsProperty = fetchByE_K(entryId, key);
1274
1275        if (tagsProperty == null) {
1276            StringBuilder msg = new StringBuilder();
1277
1278            msg.append("No TagsProperty exists with the key {");
1279
1280            msg.append("entryId=" + entryId);
1281
1282            msg.append(", ");
1283            msg.append("key=" + key);
1284
1285            msg.append(StringPool.CLOSE_CURLY_BRACE);
1286
1287            if (_log.isWarnEnabled()) {
1288                _log.warn(msg.toString());
1289            }
1290
1291            throw new NoSuchPropertyException(msg.toString());
1292        }
1293
1294        return tagsProperty;
1295    }
1296
1297    public TagsProperty fetchByE_K(long entryId, String key)
1298        throws SystemException {
1299        return fetchByE_K(entryId, key, true);
1300    }
1301
1302    public TagsProperty fetchByE_K(long entryId, String key,
1303        boolean retrieveFromCache) throws SystemException {
1304        Object[] finderArgs = new Object[] { new Long(entryId), key };
1305
1306        Object result = null;
1307
1308        if (retrieveFromCache) {
1309            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_E_K,
1310                    finderArgs, this);
1311        }
1312
1313        if (result == null) {
1314            Session session = null;
1315
1316            try {
1317                session = openSession();
1318
1319                StringBuilder query = new StringBuilder();
1320
1321                query.append(
1322                    "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ");
1323
1324                query.append("tagsProperty.entryId = ?");
1325
1326                query.append(" AND ");
1327
1328                if (key == null) {
1329                    query.append("tagsProperty.key IS NULL");
1330                }
1331                else {
1332                    query.append("tagsProperty.key = ?");
1333                }
1334
1335                query.append(" ");
1336
1337                query.append("ORDER BY ");
1338
1339                query.append("tagsProperty.key ASC");
1340
1341                Query q = session.createQuery(query.toString());
1342
1343                QueryPos qPos = QueryPos.getInstance(q);
1344
1345                qPos.add(entryId);
1346
1347                if (key != null) {
1348                    qPos.add(key);
1349                }
1350
1351                List<TagsProperty> list = q.list();
1352
1353                result = list;
1354
1355                TagsProperty tagsProperty = null;
1356
1357                if (list.isEmpty()) {
1358                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1359                        finderArgs, list);
1360                }
1361                else {
1362                    tagsProperty = list.get(0);
1363
1364                    cacheResult(tagsProperty);
1365
1366                    if ((tagsProperty.getEntryId() != entryId) ||
1367                            (tagsProperty.getKey() == null) ||
1368                            !tagsProperty.getKey().equals(key)) {
1369                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1370                            finderArgs, tagsProperty);
1371                    }
1372                }
1373
1374                return tagsProperty;
1375            }
1376            catch (Exception e) {
1377                throw processException(e);
1378            }
1379            finally {
1380                if (result == null) {
1381                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1382                        finderArgs, new ArrayList<TagsProperty>());
1383                }
1384
1385                closeSession(session);
1386            }
1387        }
1388        else {
1389            if (result instanceof List<?>) {
1390                return null;
1391            }
1392            else {
1393                return (TagsProperty)result;
1394            }
1395        }
1396    }
1397
1398    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1399        throws SystemException {
1400        Session session = null;
1401
1402        try {
1403            session = openSession();
1404
1405            dynamicQuery.compile(session);
1406
1407            return dynamicQuery.list();
1408        }
1409        catch (Exception e) {
1410            throw processException(e);
1411        }
1412        finally {
1413            closeSession(session);
1414        }
1415    }
1416
1417    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1418        int start, int end) throws SystemException {
1419        Session session = null;
1420
1421        try {
1422            session = openSession();
1423
1424            dynamicQuery.setLimit(start, end);
1425
1426            dynamicQuery.compile(session);
1427
1428            return dynamicQuery.list();
1429        }
1430        catch (Exception e) {
1431            throw processException(e);
1432        }
1433        finally {
1434            closeSession(session);
1435        }
1436    }
1437
1438    public List<TagsProperty> findAll() throws SystemException {
1439        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1440    }
1441
1442    public List<TagsProperty> findAll(int start, int end)
1443        throws SystemException {
1444        return findAll(start, end, null);
1445    }
1446
1447    public List<TagsProperty> findAll(int start, int end, OrderByComparator obc)
1448        throws SystemException {
1449        Object[] finderArgs = new Object[] {
1450                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1451            };
1452
1453        List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1454                finderArgs, this);
1455
1456        if (list == null) {
1457            Session session = null;
1458
1459            try {
1460                session = openSession();
1461
1462                StringBuilder query = new StringBuilder();
1463
1464                query.append(
1465                    "SELECT tagsProperty FROM TagsProperty tagsProperty ");
1466
1467                if (obc != null) {
1468                    query.append("ORDER BY ");
1469
1470                    String[] orderByFields = obc.getOrderByFields();
1471
1472                    for (int i = 0; i < orderByFields.length; i++) {
1473                        query.append("tagsProperty.");
1474                        query.append(orderByFields[i]);
1475
1476                        if (obc.isAscending()) {
1477                            query.append(" ASC");
1478                        }
1479                        else {
1480                            query.append(" DESC");
1481                        }
1482
1483                        if ((i + 1) < orderByFields.length) {
1484                            query.append(", ");
1485                        }
1486                    }
1487                }
1488
1489                else {
1490                    query.append("ORDER BY ");
1491
1492                    query.append("tagsProperty.key ASC");
1493                }
1494
1495                Query q = session.createQuery(query.toString());
1496
1497                if (obc == null) {
1498                    list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1499                            start, end, false);
1500
1501                    Collections.sort(list);
1502                }
1503                else {
1504                    list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1505                            start, end);
1506                }
1507            }
1508            catch (Exception e) {
1509                throw processException(e);
1510            }
1511            finally {
1512                if (list == null) {
1513                    list = new ArrayList<TagsProperty>();
1514                }
1515
1516                cacheResult(list);
1517
1518                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1519
1520                closeSession(session);
1521            }
1522        }
1523
1524        return list;
1525    }
1526
1527    public void removeByCompanyId(long companyId) throws SystemException {
1528        for (TagsProperty tagsProperty : findByCompanyId(companyId)) {
1529            remove(tagsProperty);
1530        }
1531    }
1532
1533    public void removeByEntryId(long entryId) throws SystemException {
1534        for (TagsProperty tagsProperty : findByEntryId(entryId)) {
1535            remove(tagsProperty);
1536        }
1537    }
1538
1539    public void removeByC_K(long companyId, String key)
1540        throws SystemException {
1541        for (TagsProperty tagsProperty : findByC_K(companyId, key)) {
1542            remove(tagsProperty);
1543        }
1544    }
1545
1546    public void removeByE_K(long entryId, String key)
1547        throws NoSuchPropertyException, SystemException {
1548        TagsProperty tagsProperty = findByE_K(entryId, key);
1549
1550        remove(tagsProperty);
1551    }
1552
1553    public void removeAll() throws SystemException {
1554        for (TagsProperty tagsProperty : findAll()) {
1555            remove(tagsProperty);
1556        }
1557    }
1558
1559    public int countByCompanyId(long companyId) throws SystemException {
1560        Object[] finderArgs = new Object[] { new Long(companyId) };
1561
1562        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1563                finderArgs, this);
1564
1565        if (count == null) {
1566            Session session = null;
1567
1568            try {
1569                session = openSession();
1570
1571                StringBuilder query = new StringBuilder();
1572
1573                query.append("SELECT COUNT(tagsProperty) ");
1574                query.append("FROM TagsProperty tagsProperty WHERE ");
1575
1576                query.append("tagsProperty.companyId = ?");
1577
1578                query.append(" ");
1579
1580                Query q = session.createQuery(query.toString());
1581
1582                QueryPos qPos = QueryPos.getInstance(q);
1583
1584                qPos.add(companyId);
1585
1586                count = (Long)q.uniqueResult();
1587            }
1588            catch (Exception e) {
1589                throw processException(e);
1590            }
1591            finally {
1592                if (count == null) {
1593                    count = Long.valueOf(0);
1594                }
1595
1596                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1597                    finderArgs, count);
1598
1599                closeSession(session);
1600            }
1601        }
1602
1603        return count.intValue();
1604    }
1605
1606    public int countByEntryId(long entryId) throws SystemException {
1607        Object[] finderArgs = new Object[] { new Long(entryId) };
1608
1609        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ENTRYID,
1610                finderArgs, this);
1611
1612        if (count == null) {
1613            Session session = null;
1614
1615            try {
1616                session = openSession();
1617
1618                StringBuilder query = new StringBuilder();
1619
1620                query.append("SELECT COUNT(tagsProperty) ");
1621                query.append("FROM TagsProperty tagsProperty WHERE ");
1622
1623                query.append("tagsProperty.entryId = ?");
1624
1625                query.append(" ");
1626
1627                Query q = session.createQuery(query.toString());
1628
1629                QueryPos qPos = QueryPos.getInstance(q);
1630
1631                qPos.add(entryId);
1632
1633                count = (Long)q.uniqueResult();
1634            }
1635            catch (Exception e) {
1636                throw processException(e);
1637            }
1638            finally {
1639                if (count == null) {
1640                    count = Long.valueOf(0);
1641                }
1642
1643                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ENTRYID,
1644                    finderArgs, count);
1645
1646                closeSession(session);
1647            }
1648        }
1649
1650        return count.intValue();
1651    }
1652
1653    public int countByC_K(long companyId, String key) throws SystemException {
1654        Object[] finderArgs = new Object[] { new Long(companyId), key };
1655
1656        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1657                finderArgs, this);
1658
1659        if (count == null) {
1660            Session session = null;
1661
1662            try {
1663                session = openSession();
1664
1665                StringBuilder query = new StringBuilder();
1666
1667                query.append("SELECT COUNT(tagsProperty) ");
1668                query.append("FROM TagsProperty tagsProperty WHERE ");
1669
1670                query.append("tagsProperty.companyId = ?");
1671
1672                query.append(" AND ");
1673
1674                if (key == null) {
1675                    query.append("tagsProperty.key IS NULL");
1676                }
1677                else {
1678                    query.append("tagsProperty.key = ?");
1679                }
1680
1681                query.append(" ");
1682
1683                Query q = session.createQuery(query.toString());
1684
1685                QueryPos qPos = QueryPos.getInstance(q);
1686
1687                qPos.add(companyId);
1688
1689                if (key != null) {
1690                    qPos.add(key);
1691                }
1692
1693                count = (Long)q.uniqueResult();
1694            }
1695            catch (Exception e) {
1696                throw processException(e);
1697            }
1698            finally {
1699                if (count == null) {
1700                    count = Long.valueOf(0);
1701                }
1702
1703                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
1704                    count);
1705
1706                closeSession(session);
1707            }
1708        }
1709
1710        return count.intValue();
1711    }
1712
1713    public int countByE_K(long entryId, String key) throws SystemException {
1714        Object[] finderArgs = new Object[] { new Long(entryId), key };
1715
1716        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E_K,
1717                finderArgs, this);
1718
1719        if (count == null) {
1720            Session session = null;
1721
1722            try {
1723                session = openSession();
1724
1725                StringBuilder query = new StringBuilder();
1726
1727                query.append("SELECT COUNT(tagsProperty) ");
1728                query.append("FROM TagsProperty tagsProperty WHERE ");
1729
1730                query.append("tagsProperty.entryId = ?");
1731
1732                query.append(" AND ");
1733
1734                if (key == null) {
1735                    query.append("tagsProperty.key IS NULL");
1736                }
1737                else {
1738                    query.append("tagsProperty.key = ?");
1739                }
1740
1741                query.append(" ");
1742
1743                Query q = session.createQuery(query.toString());
1744
1745                QueryPos qPos = QueryPos.getInstance(q);
1746
1747                qPos.add(entryId);
1748
1749                if (key != null) {
1750                    qPos.add(key);
1751                }
1752
1753                count = (Long)q.uniqueResult();
1754            }
1755            catch (Exception e) {
1756                throw processException(e);
1757            }
1758            finally {
1759                if (count == null) {
1760                    count = Long.valueOf(0);
1761                }
1762
1763                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_K, finderArgs,
1764                    count);
1765
1766                closeSession(session);
1767            }
1768        }
1769
1770        return count.intValue();
1771    }
1772
1773    public int countAll() throws SystemException {
1774        Object[] finderArgs = new Object[0];
1775
1776        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1777                finderArgs, this);
1778
1779        if (count == null) {
1780            Session session = null;
1781
1782            try {
1783                session = openSession();
1784
1785                Query q = session.createQuery(
1786                        "SELECT COUNT(tagsProperty) FROM TagsProperty tagsProperty");
1787
1788                count = (Long)q.uniqueResult();
1789            }
1790            catch (Exception e) {
1791                throw processException(e);
1792            }
1793            finally {
1794                if (count == null) {
1795                    count = Long.valueOf(0);
1796                }
1797
1798                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1799                    count);
1800
1801                closeSession(session);
1802            }
1803        }
1804
1805        return count.intValue();
1806    }
1807
1808    public void afterPropertiesSet() {
1809        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1810                    com.liferay.portal.util.PropsUtil.get(
1811                        "value.object.listener.com.liferay.portlet.tags.model.TagsProperty")));
1812
1813        if (listenerClassNames.length > 0) {
1814            try {
1815                List<ModelListener<TagsProperty>> listenersList = new ArrayList<ModelListener<TagsProperty>>();
1816
1817                for (String listenerClassName : listenerClassNames) {
1818                    listenersList.add((ModelListener<TagsProperty>)Class.forName(
1819                            listenerClassName).newInstance());
1820                }
1821
1822                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1823            }
1824            catch (Exception e) {
1825                _log.error(e);
1826            }
1827        }
1828    }
1829
1830    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
1831    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
1832    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
1833    protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
1834    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence.impl")
1835    protected com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence tagsPropertyPersistence;
1836    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsSourcePersistence.impl")
1837    protected com.liferay.portlet.tags.service.persistence.TagsSourcePersistence tagsSourcePersistence;
1838    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence.impl")
1839    protected com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence tagsVocabularyPersistence;
1840    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1841    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1842    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1843    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1844    private static Log _log = LogFactoryUtil.getLog(TagsPropertyPersistenceImpl.class);
1845}