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.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.NoSuchVocabularyException;
48  import com.liferay.portlet.tags.model.TagsVocabulary;
49  import com.liferay.portlet.tags.model.impl.TagsVocabularyImpl;
50  import com.liferay.portlet.tags.model.impl.TagsVocabularyModelImpl;
51  
52  import java.util.ArrayList;
53  import java.util.Collections;
54  import java.util.List;
55  
56  /**
57   * <a href="TagsVocabularyPersistenceImpl.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       TagsVocabularyPersistence
66   * @see       TagsVocabularyUtil
67   * @generated
68   */
69  public class TagsVocabularyPersistenceImpl extends BasePersistenceImpl
70      implements TagsVocabularyPersistence {
71      public static final String FINDER_CLASS_NAME_ENTITY = TagsVocabularyImpl.class.getName();
72      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
73          ".List";
74      public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
75              TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
76              FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
77              new String[] { Long.class.getName(), String.class.getName() });
78      public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
79              TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
80              FINDER_CLASS_NAME_LIST, "countByG_N",
81              new String[] { Long.class.getName(), String.class.getName() });
82      public static final FinderPath FINDER_PATH_FIND_BY_G_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
83              TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
84              FINDER_CLASS_NAME_LIST, "findByG_F",
85              new String[] { Long.class.getName(), Boolean.class.getName() });
86      public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
87              TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
88              FINDER_CLASS_NAME_LIST, "findByG_F",
89              new String[] {
90                  Long.class.getName(), Boolean.class.getName(),
91                  
92              "java.lang.Integer", "java.lang.Integer",
93                  "com.liferay.portal.kernel.util.OrderByComparator"
94              });
95      public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
96              TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
97              FINDER_CLASS_NAME_LIST, "countByG_F",
98              new String[] { Long.class.getName(), Boolean.class.getName() });
99      public static final FinderPath FINDER_PATH_FIND_BY_C_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
100             TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
101             FINDER_CLASS_NAME_LIST, "findByC_F",
102             new String[] { Long.class.getName(), Boolean.class.getName() });
103     public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
104             TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
105             FINDER_CLASS_NAME_LIST, "findByC_F",
106             new String[] {
107                 Long.class.getName(), Boolean.class.getName(),
108                 
109             "java.lang.Integer", "java.lang.Integer",
110                 "com.liferay.portal.kernel.util.OrderByComparator"
111             });
112     public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
113             TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
114             FINDER_CLASS_NAME_LIST, "countByC_F",
115             new String[] { Long.class.getName(), Boolean.class.getName() });
116     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
117             TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
118             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
119     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
120             TagsVocabularyModelImpl.FINDER_CACHE_ENABLED,
121             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
122 
123     public void cacheResult(TagsVocabulary tagsVocabulary) {
124         EntityCacheUtil.putResult(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
125             TagsVocabularyImpl.class, tagsVocabulary.getPrimaryKey(),
126             tagsVocabulary);
127 
128         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
129             new Object[] {
130                 new Long(tagsVocabulary.getGroupId()),
131                 
132             tagsVocabulary.getName()
133             }, tagsVocabulary);
134     }
135 
136     public void cacheResult(List<TagsVocabulary> tagsVocabularies) {
137         for (TagsVocabulary tagsVocabulary : tagsVocabularies) {
138             if (EntityCacheUtil.getResult(
139                         TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
140                         TagsVocabularyImpl.class,
141                         tagsVocabulary.getPrimaryKey(), this) == null) {
142                 cacheResult(tagsVocabulary);
143             }
144         }
145     }
146 
147     public void clearCache() {
148         CacheRegistry.clear(TagsVocabularyImpl.class.getName());
149         EntityCacheUtil.clearCache(TagsVocabularyImpl.class.getName());
150         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
151         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
152     }
153 
154     public TagsVocabulary create(long vocabularyId) {
155         TagsVocabulary tagsVocabulary = new TagsVocabularyImpl();
156 
157         tagsVocabulary.setNew(true);
158         tagsVocabulary.setPrimaryKey(vocabularyId);
159 
160         return tagsVocabulary;
161     }
162 
163     public TagsVocabulary remove(long vocabularyId)
164         throws NoSuchVocabularyException, SystemException {
165         Session session = null;
166 
167         try {
168             session = openSession();
169 
170             TagsVocabulary tagsVocabulary = (TagsVocabulary)session.get(TagsVocabularyImpl.class,
171                     new Long(vocabularyId));
172 
173             if (tagsVocabulary == null) {
174                 if (_log.isWarnEnabled()) {
175                     _log.warn("No TagsVocabulary exists with the primary key " +
176                         vocabularyId);
177                 }
178 
179                 throw new NoSuchVocabularyException(
180                     "No TagsVocabulary exists with the primary key " +
181                     vocabularyId);
182             }
183 
184             return remove(tagsVocabulary);
185         }
186         catch (NoSuchVocabularyException nsee) {
187             throw nsee;
188         }
189         catch (Exception e) {
190             throw processException(e);
191         }
192         finally {
193             closeSession(session);
194         }
195     }
196 
197     public TagsVocabulary remove(TagsVocabulary tagsVocabulary)
198         throws SystemException {
199         for (ModelListener<TagsVocabulary> listener : listeners) {
200             listener.onBeforeRemove(tagsVocabulary);
201         }
202 
203         tagsVocabulary = removeImpl(tagsVocabulary);
204 
205         for (ModelListener<TagsVocabulary> listener : listeners) {
206             listener.onAfterRemove(tagsVocabulary);
207         }
208 
209         return tagsVocabulary;
210     }
211 
212     protected TagsVocabulary removeImpl(TagsVocabulary tagsVocabulary)
213         throws SystemException {
214         tagsVocabulary = toUnwrappedModel(tagsVocabulary);
215 
216         Session session = null;
217 
218         try {
219             session = openSession();
220 
221             if (tagsVocabulary.isCachedModel() || BatchSessionUtil.isEnabled()) {
222                 Object staleObject = session.get(TagsVocabularyImpl.class,
223                         tagsVocabulary.getPrimaryKeyObj());
224 
225                 if (staleObject != null) {
226                     session.evict(staleObject);
227                 }
228             }
229 
230             session.delete(tagsVocabulary);
231 
232             session.flush();
233         }
234         catch (Exception e) {
235             throw processException(e);
236         }
237         finally {
238             closeSession(session);
239         }
240 
241         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
242 
243         TagsVocabularyModelImpl tagsVocabularyModelImpl = (TagsVocabularyModelImpl)tagsVocabulary;
244 
245         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
246             new Object[] {
247                 new Long(tagsVocabularyModelImpl.getOriginalGroupId()),
248                 
249             tagsVocabularyModelImpl.getOriginalName()
250             });
251 
252         EntityCacheUtil.removeResult(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
253             TagsVocabularyImpl.class, tagsVocabulary.getPrimaryKey());
254 
255         return tagsVocabulary;
256     }
257 
258     /**
259      * @deprecated Use {@link #update(TagsVocabulary, boolean merge)}.
260      */
261     public TagsVocabulary update(TagsVocabulary tagsVocabulary)
262         throws SystemException {
263         if (_log.isWarnEnabled()) {
264             _log.warn(
265                 "Using the deprecated update(TagsVocabulary tagsVocabulary) method. Use update(TagsVocabulary tagsVocabulary, boolean merge) instead.");
266         }
267 
268         return update(tagsVocabulary, false);
269     }
270 
271     /**
272      * Add, update, or merge, the entity. This method also calls the model
273      * listeners to trigger the proper events associated with adding, deleting,
274      * or updating an entity.
275      *
276      * @param  tagsVocabulary the entity to add, update, or merge
277      * @param  merge boolean value for whether to merge the entity. The default
278      *         value is false. Setting merge to true is more expensive and
279      *         should only be true when tagsVocabulary is transient. See
280      *         LEP-5473 for a detailed discussion of this method.
281      * @return the entity that was added, updated, or merged
282      */
283     public TagsVocabulary update(TagsVocabulary tagsVocabulary, boolean merge)
284         throws SystemException {
285         boolean isNew = tagsVocabulary.isNew();
286 
287         for (ModelListener<TagsVocabulary> listener : listeners) {
288             if (isNew) {
289                 listener.onBeforeCreate(tagsVocabulary);
290             }
291             else {
292                 listener.onBeforeUpdate(tagsVocabulary);
293             }
294         }
295 
296         tagsVocabulary = updateImpl(tagsVocabulary, merge);
297 
298         for (ModelListener<TagsVocabulary> listener : listeners) {
299             if (isNew) {
300                 listener.onAfterCreate(tagsVocabulary);
301             }
302             else {
303                 listener.onAfterUpdate(tagsVocabulary);
304             }
305         }
306 
307         return tagsVocabulary;
308     }
309 
310     public TagsVocabulary updateImpl(
311         com.liferay.portlet.tags.model.TagsVocabulary tagsVocabulary,
312         boolean merge) throws SystemException {
313         tagsVocabulary = toUnwrappedModel(tagsVocabulary);
314 
315         boolean isNew = tagsVocabulary.isNew();
316 
317         TagsVocabularyModelImpl tagsVocabularyModelImpl = (TagsVocabularyModelImpl)tagsVocabulary;
318 
319         Session session = null;
320 
321         try {
322             session = openSession();
323 
324             BatchSessionUtil.update(session, tagsVocabulary, merge);
325 
326             tagsVocabulary.setNew(false);
327         }
328         catch (Exception e) {
329             throw processException(e);
330         }
331         finally {
332             closeSession(session);
333         }
334 
335         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336 
337         EntityCacheUtil.putResult(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
338             TagsVocabularyImpl.class, tagsVocabulary.getPrimaryKey(),
339             tagsVocabulary);
340 
341         if (!isNew &&
342                 ((tagsVocabulary.getGroupId() != tagsVocabularyModelImpl.getOriginalGroupId()) ||
343                 !Validator.equals(tagsVocabulary.getName(),
344                     tagsVocabularyModelImpl.getOriginalName()))) {
345             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
346                 new Object[] {
347                     new Long(tagsVocabularyModelImpl.getOriginalGroupId()),
348                     
349                 tagsVocabularyModelImpl.getOriginalName()
350                 });
351         }
352 
353         if (isNew ||
354                 ((tagsVocabulary.getGroupId() != tagsVocabularyModelImpl.getOriginalGroupId()) ||
355                 !Validator.equals(tagsVocabulary.getName(),
356                     tagsVocabularyModelImpl.getOriginalName()))) {
357             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
358                 new Object[] {
359                     new Long(tagsVocabulary.getGroupId()),
360                     
361                 tagsVocabulary.getName()
362                 }, tagsVocabulary);
363         }
364 
365         return tagsVocabulary;
366     }
367 
368     protected TagsVocabulary toUnwrappedModel(TagsVocabulary tagsVocabulary) {
369         if (tagsVocabulary instanceof TagsVocabularyImpl) {
370             return tagsVocabulary;
371         }
372 
373         TagsVocabularyImpl tagsVocabularyImpl = new TagsVocabularyImpl();
374 
375         tagsVocabularyImpl.setNew(tagsVocabulary.isNew());
376         tagsVocabularyImpl.setPrimaryKey(tagsVocabulary.getPrimaryKey());
377 
378         tagsVocabularyImpl.setVocabularyId(tagsVocabulary.getVocabularyId());
379         tagsVocabularyImpl.setGroupId(tagsVocabulary.getGroupId());
380         tagsVocabularyImpl.setCompanyId(tagsVocabulary.getCompanyId());
381         tagsVocabularyImpl.setUserId(tagsVocabulary.getUserId());
382         tagsVocabularyImpl.setUserName(tagsVocabulary.getUserName());
383         tagsVocabularyImpl.setCreateDate(tagsVocabulary.getCreateDate());
384         tagsVocabularyImpl.setModifiedDate(tagsVocabulary.getModifiedDate());
385         tagsVocabularyImpl.setName(tagsVocabulary.getName());
386         tagsVocabularyImpl.setDescription(tagsVocabulary.getDescription());
387         tagsVocabularyImpl.setFolksonomy(tagsVocabulary.isFolksonomy());
388 
389         return tagsVocabularyImpl;
390     }
391 
392     public TagsVocabulary findByPrimaryKey(long vocabularyId)
393         throws NoSuchVocabularyException, SystemException {
394         TagsVocabulary tagsVocabulary = fetchByPrimaryKey(vocabularyId);
395 
396         if (tagsVocabulary == null) {
397             if (_log.isWarnEnabled()) {
398                 _log.warn("No TagsVocabulary exists with the primary key " +
399                     vocabularyId);
400             }
401 
402             throw new NoSuchVocabularyException(
403                 "No TagsVocabulary exists with the primary key " +
404                 vocabularyId);
405         }
406 
407         return tagsVocabulary;
408     }
409 
410     public TagsVocabulary fetchByPrimaryKey(long vocabularyId)
411         throws SystemException {
412         TagsVocabulary tagsVocabulary = (TagsVocabulary)EntityCacheUtil.getResult(TagsVocabularyModelImpl.ENTITY_CACHE_ENABLED,
413                 TagsVocabularyImpl.class, vocabularyId, this);
414 
415         if (tagsVocabulary == null) {
416             Session session = null;
417 
418             try {
419                 session = openSession();
420 
421                 tagsVocabulary = (TagsVocabulary)session.get(TagsVocabularyImpl.class,
422                         new Long(vocabularyId));
423             }
424             catch (Exception e) {
425                 throw processException(e);
426             }
427             finally {
428                 if (tagsVocabulary != null) {
429                     cacheResult(tagsVocabulary);
430                 }
431 
432                 closeSession(session);
433             }
434         }
435 
436         return tagsVocabulary;
437     }
438 
439     public TagsVocabulary findByG_N(long groupId, String name)
440         throws NoSuchVocabularyException, SystemException {
441         TagsVocabulary tagsVocabulary = fetchByG_N(groupId, name);
442 
443         if (tagsVocabulary == null) {
444             StringBuilder msg = new StringBuilder();
445 
446             msg.append("No TagsVocabulary exists with the key {");
447 
448             msg.append("groupId=" + groupId);
449 
450             msg.append(", ");
451             msg.append("name=" + name);
452 
453             msg.append(StringPool.CLOSE_CURLY_BRACE);
454 
455             if (_log.isWarnEnabled()) {
456                 _log.warn(msg.toString());
457             }
458 
459             throw new NoSuchVocabularyException(msg.toString());
460         }
461 
462         return tagsVocabulary;
463     }
464 
465     public TagsVocabulary fetchByG_N(long groupId, String name)
466         throws SystemException {
467         return fetchByG_N(groupId, name, true);
468     }
469 
470     public TagsVocabulary fetchByG_N(long groupId, String name,
471         boolean retrieveFromCache) throws SystemException {
472         Object[] finderArgs = new Object[] { new Long(groupId), name };
473 
474         Object result = null;
475 
476         if (retrieveFromCache) {
477             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
478                     finderArgs, this);
479         }
480 
481         if (result == null) {
482             Session session = null;
483 
484             try {
485                 session = openSession();
486 
487                 StringBuilder query = new StringBuilder();
488 
489                 query.append(
490                     "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
491 
492                 query.append("tagsVocabulary.groupId = ?");
493 
494                 query.append(" AND ");
495 
496                 if (name == null) {
497                     query.append("tagsVocabulary.name IS NULL");
498                 }
499                 else {
500                     query.append("tagsVocabulary.name = ?");
501                 }
502 
503                 query.append(" ");
504 
505                 query.append("ORDER BY ");
506 
507                 query.append("tagsVocabulary.name ASC");
508 
509                 Query q = session.createQuery(query.toString());
510 
511                 QueryPos qPos = QueryPos.getInstance(q);
512 
513                 qPos.add(groupId);
514 
515                 if (name != null) {
516                     qPos.add(name);
517                 }
518 
519                 List<TagsVocabulary> list = q.list();
520 
521                 result = list;
522 
523                 TagsVocabulary tagsVocabulary = null;
524 
525                 if (list.isEmpty()) {
526                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
527                         finderArgs, list);
528                 }
529                 else {
530                     tagsVocabulary = list.get(0);
531 
532                     cacheResult(tagsVocabulary);
533 
534                     if ((tagsVocabulary.getGroupId() != groupId) ||
535                             (tagsVocabulary.getName() == null) ||
536                             !tagsVocabulary.getName().equals(name)) {
537                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
538                             finderArgs, tagsVocabulary);
539                     }
540                 }
541 
542                 return tagsVocabulary;
543             }
544             catch (Exception e) {
545                 throw processException(e);
546             }
547             finally {
548                 if (result == null) {
549                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
550                         finderArgs, new ArrayList<TagsVocabulary>());
551                 }
552 
553                 closeSession(session);
554             }
555         }
556         else {
557             if (result instanceof List<?>) {
558                 return null;
559             }
560             else {
561                 return (TagsVocabulary)result;
562             }
563         }
564     }
565 
566     public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy)
567         throws SystemException {
568         Object[] finderArgs = new Object[] {
569                 new Long(groupId), Boolean.valueOf(folksonomy)
570             };
571 
572         List<TagsVocabulary> list = (List<TagsVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F,
573                 finderArgs, this);
574 
575         if (list == null) {
576             Session session = null;
577 
578             try {
579                 session = openSession();
580 
581                 StringBuilder query = new StringBuilder();
582 
583                 query.append(
584                     "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
585 
586                 query.append("tagsVocabulary.groupId = ?");
587 
588                 query.append(" AND ");
589 
590                 query.append("tagsVocabulary.folksonomy = ?");
591 
592                 query.append(" ");
593 
594                 query.append("ORDER BY ");
595 
596                 query.append("tagsVocabulary.name ASC");
597 
598                 Query q = session.createQuery(query.toString());
599 
600                 QueryPos qPos = QueryPos.getInstance(q);
601 
602                 qPos.add(groupId);
603 
604                 qPos.add(folksonomy);
605 
606                 list = q.list();
607             }
608             catch (Exception e) {
609                 throw processException(e);
610             }
611             finally {
612                 if (list == null) {
613                     list = new ArrayList<TagsVocabulary>();
614                 }
615 
616                 cacheResult(list);
617 
618                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F, finderArgs,
619                     list);
620 
621                 closeSession(session);
622             }
623         }
624 
625         return list;
626     }
627 
628     public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy,
629         int start, int end) throws SystemException {
630         return findByG_F(groupId, folksonomy, start, end, null);
631     }
632 
633     public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy,
634         int start, int end, OrderByComparator obc) throws SystemException {
635         Object[] finderArgs = new Object[] {
636                 new Long(groupId), Boolean.valueOf(folksonomy),
637                 
638                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
639             };
640 
641         List<TagsVocabulary> list = (List<TagsVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_F,
642                 finderArgs, this);
643 
644         if (list == null) {
645             Session session = null;
646 
647             try {
648                 session = openSession();
649 
650                 StringBuilder query = new StringBuilder();
651 
652                 query.append(
653                     "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
654 
655                 query.append("tagsVocabulary.groupId = ?");
656 
657                 query.append(" AND ");
658 
659                 query.append("tagsVocabulary.folksonomy = ?");
660 
661                 query.append(" ");
662 
663                 if (obc != null) {
664                     query.append("ORDER BY ");
665 
666                     String[] orderByFields = obc.getOrderByFields();
667 
668                     for (int i = 0; i < orderByFields.length; i++) {
669                         query.append("tagsVocabulary.");
670                         query.append(orderByFields[i]);
671 
672                         if (obc.isAscending()) {
673                             query.append(" ASC");
674                         }
675                         else {
676                             query.append(" DESC");
677                         }
678 
679                         if ((i + 1) < orderByFields.length) {
680                             query.append(", ");
681                         }
682                     }
683                 }
684 
685                 else {
686                     query.append("ORDER BY ");
687 
688                     query.append("tagsVocabulary.name ASC");
689                 }
690 
691                 Query q = session.createQuery(query.toString());
692 
693                 QueryPos qPos = QueryPos.getInstance(q);
694 
695                 qPos.add(groupId);
696 
697                 qPos.add(folksonomy);
698 
699                 list = (List<TagsVocabulary>)QueryUtil.list(q, getDialect(),
700                         start, end);
701             }
702             catch (Exception e) {
703                 throw processException(e);
704             }
705             finally {
706                 if (list == null) {
707                     list = new ArrayList<TagsVocabulary>();
708                 }
709 
710                 cacheResult(list);
711 
712                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_F,
713                     finderArgs, list);
714 
715                 closeSession(session);
716             }
717         }
718 
719         return list;
720     }
721 
722     public TagsVocabulary findByG_F_First(long groupId, boolean folksonomy,
723         OrderByComparator obc)
724         throws NoSuchVocabularyException, SystemException {
725         List<TagsVocabulary> list = findByG_F(groupId, folksonomy, 0, 1, obc);
726 
727         if (list.isEmpty()) {
728             StringBuilder msg = new StringBuilder();
729 
730             msg.append("No TagsVocabulary exists with the key {");
731 
732             msg.append("groupId=" + groupId);
733 
734             msg.append(", ");
735             msg.append("folksonomy=" + folksonomy);
736 
737             msg.append(StringPool.CLOSE_CURLY_BRACE);
738 
739             throw new NoSuchVocabularyException(msg.toString());
740         }
741         else {
742             return list.get(0);
743         }
744     }
745 
746     public TagsVocabulary findByG_F_Last(long groupId, boolean folksonomy,
747         OrderByComparator obc)
748         throws NoSuchVocabularyException, SystemException {
749         int count = countByG_F(groupId, folksonomy);
750 
751         List<TagsVocabulary> list = findByG_F(groupId, folksonomy, count - 1,
752                 count, obc);
753 
754         if (list.isEmpty()) {
755             StringBuilder msg = new StringBuilder();
756 
757             msg.append("No TagsVocabulary exists with the key {");
758 
759             msg.append("groupId=" + groupId);
760 
761             msg.append(", ");
762             msg.append("folksonomy=" + folksonomy);
763 
764             msg.append(StringPool.CLOSE_CURLY_BRACE);
765 
766             throw new NoSuchVocabularyException(msg.toString());
767         }
768         else {
769             return list.get(0);
770         }
771     }
772 
773     public TagsVocabulary[] findByG_F_PrevAndNext(long vocabularyId,
774         long groupId, boolean folksonomy, OrderByComparator obc)
775         throws NoSuchVocabularyException, SystemException {
776         TagsVocabulary tagsVocabulary = findByPrimaryKey(vocabularyId);
777 
778         int count = countByG_F(groupId, folksonomy);
779 
780         Session session = null;
781 
782         try {
783             session = openSession();
784 
785             StringBuilder query = new StringBuilder();
786 
787             query.append(
788                 "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
789 
790             query.append("tagsVocabulary.groupId = ?");
791 
792             query.append(" AND ");
793 
794             query.append("tagsVocabulary.folksonomy = ?");
795 
796             query.append(" ");
797 
798             if (obc != null) {
799                 query.append("ORDER BY ");
800 
801                 String[] orderByFields = obc.getOrderByFields();
802 
803                 for (int i = 0; i < orderByFields.length; i++) {
804                     query.append("tagsVocabulary.");
805                     query.append(orderByFields[i]);
806 
807                     if (obc.isAscending()) {
808                         query.append(" ASC");
809                     }
810                     else {
811                         query.append(" DESC");
812                     }
813 
814                     if ((i + 1) < orderByFields.length) {
815                         query.append(", ");
816                     }
817                 }
818             }
819 
820             else {
821                 query.append("ORDER BY ");
822 
823                 query.append("tagsVocabulary.name ASC");
824             }
825 
826             Query q = session.createQuery(query.toString());
827 
828             QueryPos qPos = QueryPos.getInstance(q);
829 
830             qPos.add(groupId);
831 
832             qPos.add(folksonomy);
833 
834             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
835                     tagsVocabulary);
836 
837             TagsVocabulary[] array = new TagsVocabularyImpl[3];
838 
839             array[0] = (TagsVocabulary)objArray[0];
840             array[1] = (TagsVocabulary)objArray[1];
841             array[2] = (TagsVocabulary)objArray[2];
842 
843             return array;
844         }
845         catch (Exception e) {
846             throw processException(e);
847         }
848         finally {
849             closeSession(session);
850         }
851     }
852 
853     public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy)
854         throws SystemException {
855         Object[] finderArgs = new Object[] {
856                 new Long(companyId), Boolean.valueOf(folksonomy)
857             };
858 
859         List<TagsVocabulary> list = (List<TagsVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_F,
860                 finderArgs, this);
861 
862         if (list == null) {
863             Session session = null;
864 
865             try {
866                 session = openSession();
867 
868                 StringBuilder query = new StringBuilder();
869 
870                 query.append(
871                     "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
872 
873                 query.append("tagsVocabulary.companyId = ?");
874 
875                 query.append(" AND ");
876 
877                 query.append("tagsVocabulary.folksonomy = ?");
878 
879                 query.append(" ");
880 
881                 query.append("ORDER BY ");
882 
883                 query.append("tagsVocabulary.name ASC");
884 
885                 Query q = session.createQuery(query.toString());
886 
887                 QueryPos qPos = QueryPos.getInstance(q);
888 
889                 qPos.add(companyId);
890 
891                 qPos.add(folksonomy);
892 
893                 list = q.list();
894             }
895             catch (Exception e) {
896                 throw processException(e);
897             }
898             finally {
899                 if (list == null) {
900                     list = new ArrayList<TagsVocabulary>();
901                 }
902 
903                 cacheResult(list);
904 
905                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_F, finderArgs,
906                     list);
907 
908                 closeSession(session);
909             }
910         }
911 
912         return list;
913     }
914 
915     public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy,
916         int start, int end) throws SystemException {
917         return findByC_F(companyId, folksonomy, start, end, null);
918     }
919 
920     public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy,
921         int start, int end, OrderByComparator obc) throws SystemException {
922         Object[] finderArgs = new Object[] {
923                 new Long(companyId), Boolean.valueOf(folksonomy),
924                 
925                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
926             };
927 
928         List<TagsVocabulary> list = (List<TagsVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_F,
929                 finderArgs, this);
930 
931         if (list == null) {
932             Session session = null;
933 
934             try {
935                 session = openSession();
936 
937                 StringBuilder query = new StringBuilder();
938 
939                 query.append(
940                     "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
941 
942                 query.append("tagsVocabulary.companyId = ?");
943 
944                 query.append(" AND ");
945 
946                 query.append("tagsVocabulary.folksonomy = ?");
947 
948                 query.append(" ");
949 
950                 if (obc != null) {
951                     query.append("ORDER BY ");
952 
953                     String[] orderByFields = obc.getOrderByFields();
954 
955                     for (int i = 0; i < orderByFields.length; i++) {
956                         query.append("tagsVocabulary.");
957                         query.append(orderByFields[i]);
958 
959                         if (obc.isAscending()) {
960                             query.append(" ASC");
961                         }
962                         else {
963                             query.append(" DESC");
964                         }
965 
966                         if ((i + 1) < orderByFields.length) {
967                             query.append(", ");
968                         }
969                     }
970                 }
971 
972                 else {
973                     query.append("ORDER BY ");
974 
975                     query.append("tagsVocabulary.name ASC");
976                 }
977 
978                 Query q = session.createQuery(query.toString());
979 
980                 QueryPos qPos = QueryPos.getInstance(q);
981 
982                 qPos.add(companyId);
983 
984                 qPos.add(folksonomy);
985 
986                 list = (List<TagsVocabulary>)QueryUtil.list(q, getDialect(),
987                         start, end);
988             }
989             catch (Exception e) {
990                 throw processException(e);
991             }
992             finally {
993                 if (list == null) {
994                     list = new ArrayList<TagsVocabulary>();
995                 }
996 
997                 cacheResult(list);
998 
999                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_F,
1000                    finderArgs, list);
1001
1002                closeSession(session);
1003            }
1004        }
1005
1006        return list;
1007    }
1008
1009    public TagsVocabulary findByC_F_First(long companyId, boolean folksonomy,
1010        OrderByComparator obc)
1011        throws NoSuchVocabularyException, SystemException {
1012        List<TagsVocabulary> list = findByC_F(companyId, folksonomy, 0, 1, obc);
1013
1014        if (list.isEmpty()) {
1015            StringBuilder msg = new StringBuilder();
1016
1017            msg.append("No TagsVocabulary exists with the key {");
1018
1019            msg.append("companyId=" + companyId);
1020
1021            msg.append(", ");
1022            msg.append("folksonomy=" + folksonomy);
1023
1024            msg.append(StringPool.CLOSE_CURLY_BRACE);
1025
1026            throw new NoSuchVocabularyException(msg.toString());
1027        }
1028        else {
1029            return list.get(0);
1030        }
1031    }
1032
1033    public TagsVocabulary findByC_F_Last(long companyId, boolean folksonomy,
1034        OrderByComparator obc)
1035        throws NoSuchVocabularyException, SystemException {
1036        int count = countByC_F(companyId, folksonomy);
1037
1038        List<TagsVocabulary> list = findByC_F(companyId, folksonomy, count - 1,
1039                count, obc);
1040
1041        if (list.isEmpty()) {
1042            StringBuilder msg = new StringBuilder();
1043
1044            msg.append("No TagsVocabulary exists with the key {");
1045
1046            msg.append("companyId=" + companyId);
1047
1048            msg.append(", ");
1049            msg.append("folksonomy=" + folksonomy);
1050
1051            msg.append(StringPool.CLOSE_CURLY_BRACE);
1052
1053            throw new NoSuchVocabularyException(msg.toString());
1054        }
1055        else {
1056            return list.get(0);
1057        }
1058    }
1059
1060    public TagsVocabulary[] findByC_F_PrevAndNext(long vocabularyId,
1061        long companyId, boolean folksonomy, OrderByComparator obc)
1062        throws NoSuchVocabularyException, SystemException {
1063        TagsVocabulary tagsVocabulary = findByPrimaryKey(vocabularyId);
1064
1065        int count = countByC_F(companyId, folksonomy);
1066
1067        Session session = null;
1068
1069        try {
1070            session = openSession();
1071
1072            StringBuilder query = new StringBuilder();
1073
1074            query.append(
1075                "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary WHERE ");
1076
1077            query.append("tagsVocabulary.companyId = ?");
1078
1079            query.append(" AND ");
1080
1081            query.append("tagsVocabulary.folksonomy = ?");
1082
1083            query.append(" ");
1084
1085            if (obc != null) {
1086                query.append("ORDER BY ");
1087
1088                String[] orderByFields = obc.getOrderByFields();
1089
1090                for (int i = 0; i < orderByFields.length; i++) {
1091                    query.append("tagsVocabulary.");
1092                    query.append(orderByFields[i]);
1093
1094                    if (obc.isAscending()) {
1095                        query.append(" ASC");
1096                    }
1097                    else {
1098                        query.append(" DESC");
1099                    }
1100
1101                    if ((i + 1) < orderByFields.length) {
1102                        query.append(", ");
1103                    }
1104                }
1105            }
1106
1107            else {
1108                query.append("ORDER BY ");
1109
1110                query.append("tagsVocabulary.name ASC");
1111            }
1112
1113            Query q = session.createQuery(query.toString());
1114
1115            QueryPos qPos = QueryPos.getInstance(q);
1116
1117            qPos.add(companyId);
1118
1119            qPos.add(folksonomy);
1120
1121            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1122                    tagsVocabulary);
1123
1124            TagsVocabulary[] array = new TagsVocabularyImpl[3];
1125
1126            array[0] = (TagsVocabulary)objArray[0];
1127            array[1] = (TagsVocabulary)objArray[1];
1128            array[2] = (TagsVocabulary)objArray[2];
1129
1130            return array;
1131        }
1132        catch (Exception e) {
1133            throw processException(e);
1134        }
1135        finally {
1136            closeSession(session);
1137        }
1138    }
1139
1140    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1141        throws SystemException {
1142        Session session = null;
1143
1144        try {
1145            session = openSession();
1146
1147            dynamicQuery.compile(session);
1148
1149            return dynamicQuery.list();
1150        }
1151        catch (Exception e) {
1152            throw processException(e);
1153        }
1154        finally {
1155            closeSession(session);
1156        }
1157    }
1158
1159    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1160        int start, int end) throws SystemException {
1161        Session session = null;
1162
1163        try {
1164            session = openSession();
1165
1166            dynamicQuery.setLimit(start, end);
1167
1168            dynamicQuery.compile(session);
1169
1170            return dynamicQuery.list();
1171        }
1172        catch (Exception e) {
1173            throw processException(e);
1174        }
1175        finally {
1176            closeSession(session);
1177        }
1178    }
1179
1180    public List<TagsVocabulary> findAll() throws SystemException {
1181        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1182    }
1183
1184    public List<TagsVocabulary> findAll(int start, int end)
1185        throws SystemException {
1186        return findAll(start, end, null);
1187    }
1188
1189    public List<TagsVocabulary> findAll(int start, int end,
1190        OrderByComparator obc) throws SystemException {
1191        Object[] finderArgs = new Object[] {
1192                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1193            };
1194
1195        List<TagsVocabulary> list = (List<TagsVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1196                finderArgs, this);
1197
1198        if (list == null) {
1199            Session session = null;
1200
1201            try {
1202                session = openSession();
1203
1204                StringBuilder query = new StringBuilder();
1205
1206                query.append(
1207                    "SELECT tagsVocabulary FROM TagsVocabulary tagsVocabulary ");
1208
1209                if (obc != null) {
1210                    query.append("ORDER BY ");
1211
1212                    String[] orderByFields = obc.getOrderByFields();
1213
1214                    for (int i = 0; i < orderByFields.length; i++) {
1215                        query.append("tagsVocabulary.");
1216                        query.append(orderByFields[i]);
1217
1218                        if (obc.isAscending()) {
1219                            query.append(" ASC");
1220                        }
1221                        else {
1222                            query.append(" DESC");
1223                        }
1224
1225                        if ((i + 1) < orderByFields.length) {
1226                            query.append(", ");
1227                        }
1228                    }
1229                }
1230
1231                else {
1232                    query.append("ORDER BY ");
1233
1234                    query.append("tagsVocabulary.name ASC");
1235                }
1236
1237                Query q = session.createQuery(query.toString());
1238
1239                if (obc == null) {
1240                    list = (List<TagsVocabulary>)QueryUtil.list(q,
1241                            getDialect(), start, end, false);
1242
1243                    Collections.sort(list);
1244                }
1245                else {
1246                    list = (List<TagsVocabulary>)QueryUtil.list(q,
1247                            getDialect(), start, end);
1248                }
1249            }
1250            catch (Exception e) {
1251                throw processException(e);
1252            }
1253            finally {
1254                if (list == null) {
1255                    list = new ArrayList<TagsVocabulary>();
1256                }
1257
1258                cacheResult(list);
1259
1260                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1261
1262                closeSession(session);
1263            }
1264        }
1265
1266        return list;
1267    }
1268
1269    public void removeByG_N(long groupId, String name)
1270        throws NoSuchVocabularyException, SystemException {
1271        TagsVocabulary tagsVocabulary = findByG_N(groupId, name);
1272
1273        remove(tagsVocabulary);
1274    }
1275
1276    public void removeByG_F(long groupId, boolean folksonomy)
1277        throws SystemException {
1278        for (TagsVocabulary tagsVocabulary : findByG_F(groupId, folksonomy)) {
1279            remove(tagsVocabulary);
1280        }
1281    }
1282
1283    public void removeByC_F(long companyId, boolean folksonomy)
1284        throws SystemException {
1285        for (TagsVocabulary tagsVocabulary : findByC_F(companyId, folksonomy)) {
1286            remove(tagsVocabulary);
1287        }
1288    }
1289
1290    public void removeAll() throws SystemException {
1291        for (TagsVocabulary tagsVocabulary : findAll()) {
1292            remove(tagsVocabulary);
1293        }
1294    }
1295
1296    public int countByG_N(long groupId, String name) throws SystemException {
1297        Object[] finderArgs = new Object[] { new Long(groupId), name };
1298
1299        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1300                finderArgs, this);
1301
1302        if (count == null) {
1303            Session session = null;
1304
1305            try {
1306                session = openSession();
1307
1308                StringBuilder query = new StringBuilder();
1309
1310                query.append("SELECT COUNT(tagsVocabulary) ");
1311                query.append("FROM TagsVocabulary tagsVocabulary WHERE ");
1312
1313                query.append("tagsVocabulary.groupId = ?");
1314
1315                query.append(" AND ");
1316
1317                if (name == null) {
1318                    query.append("tagsVocabulary.name IS NULL");
1319                }
1320                else {
1321                    query.append("tagsVocabulary.name = ?");
1322                }
1323
1324                query.append(" ");
1325
1326                Query q = session.createQuery(query.toString());
1327
1328                QueryPos qPos = QueryPos.getInstance(q);
1329
1330                qPos.add(groupId);
1331
1332                if (name != null) {
1333                    qPos.add(name);
1334                }
1335
1336                count = (Long)q.uniqueResult();
1337            }
1338            catch (Exception e) {
1339                throw processException(e);
1340            }
1341            finally {
1342                if (count == null) {
1343                    count = Long.valueOf(0);
1344                }
1345
1346                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1347                    count);
1348
1349                closeSession(session);
1350            }
1351        }
1352
1353        return count.intValue();
1354    }
1355
1356    public int countByG_F(long groupId, boolean folksonomy)
1357        throws SystemException {
1358        Object[] finderArgs = new Object[] {
1359                new Long(groupId), Boolean.valueOf(folksonomy)
1360            };
1361
1362        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
1363                finderArgs, this);
1364
1365        if (count == null) {
1366            Session session = null;
1367
1368            try {
1369                session = openSession();
1370
1371                StringBuilder query = new StringBuilder();
1372
1373                query.append("SELECT COUNT(tagsVocabulary) ");
1374                query.append("FROM TagsVocabulary tagsVocabulary WHERE ");
1375
1376                query.append("tagsVocabulary.groupId = ?");
1377
1378                query.append(" AND ");
1379
1380                query.append("tagsVocabulary.folksonomy = ?");
1381
1382                query.append(" ");
1383
1384                Query q = session.createQuery(query.toString());
1385
1386                QueryPos qPos = QueryPos.getInstance(q);
1387
1388                qPos.add(groupId);
1389
1390                qPos.add(folksonomy);
1391
1392                count = (Long)q.uniqueResult();
1393            }
1394            catch (Exception e) {
1395                throw processException(e);
1396            }
1397            finally {
1398                if (count == null) {
1399                    count = Long.valueOf(0);
1400                }
1401
1402                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
1403                    count);
1404
1405                closeSession(session);
1406            }
1407        }
1408
1409        return count.intValue();
1410    }
1411
1412    public int countByC_F(long companyId, boolean folksonomy)
1413        throws SystemException {
1414        Object[] finderArgs = new Object[] {
1415                new Long(companyId), Boolean.valueOf(folksonomy)
1416            };
1417
1418        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
1419                finderArgs, this);
1420
1421        if (count == null) {
1422            Session session = null;
1423
1424            try {
1425                session = openSession();
1426
1427                StringBuilder query = new StringBuilder();
1428
1429                query.append("SELECT COUNT(tagsVocabulary) ");
1430                query.append("FROM TagsVocabulary tagsVocabulary WHERE ");
1431
1432                query.append("tagsVocabulary.companyId = ?");
1433
1434                query.append(" AND ");
1435
1436                query.append("tagsVocabulary.folksonomy = ?");
1437
1438                query.append(" ");
1439
1440                Query q = session.createQuery(query.toString());
1441
1442                QueryPos qPos = QueryPos.getInstance(q);
1443
1444                qPos.add(companyId);
1445
1446                qPos.add(folksonomy);
1447
1448                count = (Long)q.uniqueResult();
1449            }
1450            catch (Exception e) {
1451                throw processException(e);
1452            }
1453            finally {
1454                if (count == null) {
1455                    count = Long.valueOf(0);
1456                }
1457
1458                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
1459                    count);
1460
1461                closeSession(session);
1462            }
1463        }
1464
1465        return count.intValue();
1466    }
1467
1468    public int countAll() throws SystemException {
1469        Object[] finderArgs = new Object[0];
1470
1471        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1472                finderArgs, this);
1473
1474        if (count == null) {
1475            Session session = null;
1476
1477            try {
1478                session = openSession();
1479
1480                Query q = session.createQuery(
1481                        "SELECT COUNT(tagsVocabulary) FROM TagsVocabulary tagsVocabulary");
1482
1483                count = (Long)q.uniqueResult();
1484            }
1485            catch (Exception e) {
1486                throw processException(e);
1487            }
1488            finally {
1489                if (count == null) {
1490                    count = Long.valueOf(0);
1491                }
1492
1493                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1494                    count);
1495
1496                closeSession(session);
1497            }
1498        }
1499
1500        return count.intValue();
1501    }
1502
1503    public void afterPropertiesSet() {
1504        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1505                    com.liferay.portal.util.PropsUtil.get(
1506                        "value.object.listener.com.liferay.portlet.tags.model.TagsVocabulary")));
1507
1508        if (listenerClassNames.length > 0) {
1509            try {
1510                List<ModelListener<TagsVocabulary>> listenersList = new ArrayList<ModelListener<TagsVocabulary>>();
1511
1512                for (String listenerClassName : listenerClassNames) {
1513                    listenersList.add((ModelListener<TagsVocabulary>)Class.forName(
1514                            listenerClassName).newInstance());
1515                }
1516
1517                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1518            }
1519            catch (Exception e) {
1520                _log.error(e);
1521            }
1522        }
1523    }
1524
1525    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
1526    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
1527    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
1528    protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
1529    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence.impl")
1530    protected com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence tagsPropertyPersistence;
1531    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsSourcePersistence.impl")
1532    protected com.liferay.portlet.tags.service.persistence.TagsSourcePersistence tagsSourcePersistence;
1533    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence.impl")
1534    protected com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence tagsVocabularyPersistence;
1535    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1536    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1537    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1538    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1539    private static Log _log = LogFactoryUtil.getLog(TagsVocabularyPersistenceImpl.class);
1540}