1
22
23 package com.liferay.portlet.tags.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.OrderByComparator;
29 import com.liferay.portal.kernel.util.StringMaker;
30 import com.liferay.portal.kernel.util.StringPool;
31 import com.liferay.portal.service.persistence.BasePersistence;
32 import com.liferay.portal.spring.hibernate.FinderCache;
33 import com.liferay.portal.spring.hibernate.HibernateUtil;
34
35 import com.liferay.portlet.tags.NoSuchPropertyException;
36 import com.liferay.portlet.tags.model.TagsProperty;
37 import com.liferay.portlet.tags.model.impl.TagsPropertyImpl;
38
39 import com.liferay.util.dao.hibernate.QueryUtil;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44 import org.hibernate.Query;
45 import org.hibernate.Session;
46
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class TagsPropertyPersistenceImpl extends BasePersistence
58 implements TagsPropertyPersistence {
59 public TagsProperty create(long propertyId) {
60 TagsProperty tagsProperty = new TagsPropertyImpl();
61 tagsProperty.setNew(true);
62 tagsProperty.setPrimaryKey(propertyId);
63
64 return tagsProperty;
65 }
66
67 public TagsProperty remove(long propertyId)
68 throws NoSuchPropertyException, SystemException {
69 Session session = null;
70
71 try {
72 session = openSession();
73
74 TagsProperty tagsProperty = (TagsProperty)session.get(TagsPropertyImpl.class,
75 new Long(propertyId));
76
77 if (tagsProperty == null) {
78 if (_log.isWarnEnabled()) {
79 _log.warn("No TagsProperty exists with the primary key " +
80 propertyId);
81 }
82
83 throw new NoSuchPropertyException(
84 "No TagsProperty exists with the primary key " +
85 propertyId);
86 }
87
88 return remove(tagsProperty);
89 }
90 catch (NoSuchPropertyException nsee) {
91 throw nsee;
92 }
93 catch (Exception e) {
94 throw HibernateUtil.processException(e);
95 }
96 finally {
97 closeSession(session);
98 }
99 }
100
101 public TagsProperty remove(TagsProperty tagsProperty)
102 throws SystemException {
103 Session session = null;
104
105 try {
106 session = openSession();
107 session.delete(tagsProperty);
108 session.flush();
109
110 return tagsProperty;
111 }
112 catch (Exception e) {
113 throw HibernateUtil.processException(e);
114 }
115 finally {
116 closeSession(session);
117 FinderCache.clearCache(TagsProperty.class.getName());
118 }
119 }
120
121 public TagsProperty update(
122 com.liferay.portlet.tags.model.TagsProperty tagsProperty)
123 throws SystemException {
124 return update(tagsProperty, false);
125 }
126
127 public TagsProperty update(
128 com.liferay.portlet.tags.model.TagsProperty tagsProperty, boolean merge)
129 throws SystemException {
130 Session session = null;
131
132 try {
133 session = openSession();
134
135 if (merge) {
136 session.merge(tagsProperty);
137 }
138 else {
139 if (tagsProperty.isNew()) {
140 session.save(tagsProperty);
141 }
142 }
143
144 session.flush();
145 tagsProperty.setNew(false);
146
147 return tagsProperty;
148 }
149 catch (Exception e) {
150 throw HibernateUtil.processException(e);
151 }
152 finally {
153 closeSession(session);
154 FinderCache.clearCache(TagsProperty.class.getName());
155 }
156 }
157
158 public TagsProperty findByPrimaryKey(long propertyId)
159 throws NoSuchPropertyException, SystemException {
160 TagsProperty tagsProperty = fetchByPrimaryKey(propertyId);
161
162 if (tagsProperty == null) {
163 if (_log.isWarnEnabled()) {
164 _log.warn("No TagsProperty exists with the primary key " +
165 propertyId);
166 }
167
168 throw new NoSuchPropertyException(
169 "No TagsProperty exists with the primary key " + propertyId);
170 }
171
172 return tagsProperty;
173 }
174
175 public TagsProperty fetchByPrimaryKey(long propertyId)
176 throws SystemException {
177 Session session = null;
178
179 try {
180 session = openSession();
181
182 return (TagsProperty)session.get(TagsPropertyImpl.class,
183 new Long(propertyId));
184 }
185 catch (Exception e) {
186 throw HibernateUtil.processException(e);
187 }
188 finally {
189 closeSession(session);
190 }
191 }
192
193 public List findByCompanyId(long companyId) throws SystemException {
194 String finderClassName = TagsProperty.class.getName();
195 String finderMethodName = "findByCompanyId";
196 String[] finderParams = new String[] { Long.class.getName() };
197 Object[] finderArgs = new Object[] { new Long(companyId) };
198 Object result = FinderCache.getResult(finderClassName,
199 finderMethodName, finderParams, finderArgs, getSessionFactory());
200
201 if (result == null) {
202 Session session = null;
203
204 try {
205 session = openSession();
206
207 StringMaker query = new StringMaker();
208 query.append(
209 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
210 query.append("companyId = ?");
211 query.append(" ");
212 query.append("ORDER BY ");
213 query.append("key_ ASC");
214
215 Query q = session.createQuery(query.toString());
216 int queryPos = 0;
217 q.setLong(queryPos++, companyId);
218
219 List list = q.list();
220 FinderCache.putResult(finderClassName, finderMethodName,
221 finderParams, finderArgs, list);
222
223 return list;
224 }
225 catch (Exception e) {
226 throw HibernateUtil.processException(e);
227 }
228 finally {
229 closeSession(session);
230 }
231 }
232 else {
233 return (List)result;
234 }
235 }
236
237 public List findByCompanyId(long companyId, int begin, int end)
238 throws SystemException {
239 return findByCompanyId(companyId, begin, end, null);
240 }
241
242 public List findByCompanyId(long companyId, int begin, int end,
243 OrderByComparator obc) throws SystemException {
244 String finderClassName = TagsProperty.class.getName();
245 String finderMethodName = "findByCompanyId";
246 String[] finderParams = new String[] {
247 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
248 "com.liferay.portal.kernel.util.OrderByComparator"
249 };
250 Object[] finderArgs = new Object[] {
251 new Long(companyId), String.valueOf(begin), String.valueOf(end),
252 String.valueOf(obc)
253 };
254 Object result = FinderCache.getResult(finderClassName,
255 finderMethodName, finderParams, finderArgs, getSessionFactory());
256
257 if (result == null) {
258 Session session = null;
259
260 try {
261 session = openSession();
262
263 StringMaker query = new StringMaker();
264 query.append(
265 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
266 query.append("companyId = ?");
267 query.append(" ");
268
269 if (obc != null) {
270 query.append("ORDER BY ");
271 query.append(obc.getOrderBy());
272 }
273 else {
274 query.append("ORDER BY ");
275 query.append("key_ ASC");
276 }
277
278 Query q = session.createQuery(query.toString());
279 int queryPos = 0;
280 q.setLong(queryPos++, companyId);
281
282 List list = QueryUtil.list(q, getDialect(), begin, end);
283 FinderCache.putResult(finderClassName, finderMethodName,
284 finderParams, finderArgs, list);
285
286 return list;
287 }
288 catch (Exception e) {
289 throw HibernateUtil.processException(e);
290 }
291 finally {
292 closeSession(session);
293 }
294 }
295 else {
296 return (List)result;
297 }
298 }
299
300 public TagsProperty findByCompanyId_First(long companyId,
301 OrderByComparator obc) throws NoSuchPropertyException, SystemException {
302 List list = findByCompanyId(companyId, 0, 1, obc);
303
304 if (list.size() == 0) {
305 StringMaker msg = new StringMaker();
306 msg.append("No TagsProperty exists with the key ");
307 msg.append(StringPool.OPEN_CURLY_BRACE);
308 msg.append("companyId=");
309 msg.append(companyId);
310 msg.append(StringPool.CLOSE_CURLY_BRACE);
311 throw new NoSuchPropertyException(msg.toString());
312 }
313 else {
314 return (TagsProperty)list.get(0);
315 }
316 }
317
318 public TagsProperty findByCompanyId_Last(long companyId,
319 OrderByComparator obc) throws NoSuchPropertyException, SystemException {
320 int count = countByCompanyId(companyId);
321 List list = findByCompanyId(companyId, count - 1, count, obc);
322
323 if (list.size() == 0) {
324 StringMaker msg = new StringMaker();
325 msg.append("No TagsProperty exists with the key ");
326 msg.append(StringPool.OPEN_CURLY_BRACE);
327 msg.append("companyId=");
328 msg.append(companyId);
329 msg.append(StringPool.CLOSE_CURLY_BRACE);
330 throw new NoSuchPropertyException(msg.toString());
331 }
332 else {
333 return (TagsProperty)list.get(0);
334 }
335 }
336
337 public TagsProperty[] findByCompanyId_PrevAndNext(long propertyId,
338 long companyId, OrderByComparator obc)
339 throws NoSuchPropertyException, SystemException {
340 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
341 int count = countByCompanyId(companyId);
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 StringMaker query = new StringMaker();
348 query.append(
349 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
350 query.append("companyId = ?");
351 query.append(" ");
352
353 if (obc != null) {
354 query.append("ORDER BY ");
355 query.append(obc.getOrderBy());
356 }
357 else {
358 query.append("ORDER BY ");
359 query.append("key_ ASC");
360 }
361
362 Query q = session.createQuery(query.toString());
363 int queryPos = 0;
364 q.setLong(queryPos++, companyId);
365
366 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
367 tagsProperty);
368 TagsProperty[] array = new TagsPropertyImpl[3];
369 array[0] = (TagsProperty)objArray[0];
370 array[1] = (TagsProperty)objArray[1];
371 array[2] = (TagsProperty)objArray[2];
372
373 return array;
374 }
375 catch (Exception e) {
376 throw HibernateUtil.processException(e);
377 }
378 finally {
379 closeSession(session);
380 }
381 }
382
383 public List findByEntryId(long entryId) throws SystemException {
384 String finderClassName = TagsProperty.class.getName();
385 String finderMethodName = "findByEntryId";
386 String[] finderParams = new String[] { Long.class.getName() };
387 Object[] finderArgs = new Object[] { new Long(entryId) };
388 Object result = FinderCache.getResult(finderClassName,
389 finderMethodName, finderParams, finderArgs, getSessionFactory());
390
391 if (result == null) {
392 Session session = null;
393
394 try {
395 session = openSession();
396
397 StringMaker query = new StringMaker();
398 query.append(
399 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
400 query.append("entryId = ?");
401 query.append(" ");
402 query.append("ORDER BY ");
403 query.append("key_ ASC");
404
405 Query q = session.createQuery(query.toString());
406 int queryPos = 0;
407 q.setLong(queryPos++, entryId);
408
409 List list = q.list();
410 FinderCache.putResult(finderClassName, finderMethodName,
411 finderParams, finderArgs, list);
412
413 return list;
414 }
415 catch (Exception e) {
416 throw HibernateUtil.processException(e);
417 }
418 finally {
419 closeSession(session);
420 }
421 }
422 else {
423 return (List)result;
424 }
425 }
426
427 public List findByEntryId(long entryId, int begin, int end)
428 throws SystemException {
429 return findByEntryId(entryId, begin, end, null);
430 }
431
432 public List findByEntryId(long entryId, int begin, int end,
433 OrderByComparator obc) throws SystemException {
434 String finderClassName = TagsProperty.class.getName();
435 String finderMethodName = "findByEntryId";
436 String[] finderParams = new String[] {
437 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
438 "com.liferay.portal.kernel.util.OrderByComparator"
439 };
440 Object[] finderArgs = new Object[] {
441 new Long(entryId), String.valueOf(begin), String.valueOf(end),
442 String.valueOf(obc)
443 };
444 Object result = FinderCache.getResult(finderClassName,
445 finderMethodName, finderParams, finderArgs, getSessionFactory());
446
447 if (result == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 StringMaker query = new StringMaker();
454 query.append(
455 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
456 query.append("entryId = ?");
457 query.append(" ");
458
459 if (obc != null) {
460 query.append("ORDER BY ");
461 query.append(obc.getOrderBy());
462 }
463 else {
464 query.append("ORDER BY ");
465 query.append("key_ ASC");
466 }
467
468 Query q = session.createQuery(query.toString());
469 int queryPos = 0;
470 q.setLong(queryPos++, entryId);
471
472 List list = QueryUtil.list(q, getDialect(), begin, end);
473 FinderCache.putResult(finderClassName, finderMethodName,
474 finderParams, finderArgs, list);
475
476 return list;
477 }
478 catch (Exception e) {
479 throw HibernateUtil.processException(e);
480 }
481 finally {
482 closeSession(session);
483 }
484 }
485 else {
486 return (List)result;
487 }
488 }
489
490 public TagsProperty findByEntryId_First(long entryId, OrderByComparator obc)
491 throws NoSuchPropertyException, SystemException {
492 List list = findByEntryId(entryId, 0, 1, obc);
493
494 if (list.size() == 0) {
495 StringMaker msg = new StringMaker();
496 msg.append("No TagsProperty exists with the key ");
497 msg.append(StringPool.OPEN_CURLY_BRACE);
498 msg.append("entryId=");
499 msg.append(entryId);
500 msg.append(StringPool.CLOSE_CURLY_BRACE);
501 throw new NoSuchPropertyException(msg.toString());
502 }
503 else {
504 return (TagsProperty)list.get(0);
505 }
506 }
507
508 public TagsProperty findByEntryId_Last(long entryId, OrderByComparator obc)
509 throws NoSuchPropertyException, SystemException {
510 int count = countByEntryId(entryId);
511 List list = findByEntryId(entryId, count - 1, count, obc);
512
513 if (list.size() == 0) {
514 StringMaker msg = new StringMaker();
515 msg.append("No TagsProperty exists with the key ");
516 msg.append(StringPool.OPEN_CURLY_BRACE);
517 msg.append("entryId=");
518 msg.append(entryId);
519 msg.append(StringPool.CLOSE_CURLY_BRACE);
520 throw new NoSuchPropertyException(msg.toString());
521 }
522 else {
523 return (TagsProperty)list.get(0);
524 }
525 }
526
527 public TagsProperty[] findByEntryId_PrevAndNext(long propertyId,
528 long entryId, OrderByComparator obc)
529 throws NoSuchPropertyException, SystemException {
530 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
531 int count = countByEntryId(entryId);
532 Session session = null;
533
534 try {
535 session = openSession();
536
537 StringMaker query = new StringMaker();
538 query.append(
539 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
540 query.append("entryId = ?");
541 query.append(" ");
542
543 if (obc != null) {
544 query.append("ORDER BY ");
545 query.append(obc.getOrderBy());
546 }
547 else {
548 query.append("ORDER BY ");
549 query.append("key_ ASC");
550 }
551
552 Query q = session.createQuery(query.toString());
553 int queryPos = 0;
554 q.setLong(queryPos++, entryId);
555
556 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
557 tagsProperty);
558 TagsProperty[] array = new TagsPropertyImpl[3];
559 array[0] = (TagsProperty)objArray[0];
560 array[1] = (TagsProperty)objArray[1];
561 array[2] = (TagsProperty)objArray[2];
562
563 return array;
564 }
565 catch (Exception e) {
566 throw HibernateUtil.processException(e);
567 }
568 finally {
569 closeSession(session);
570 }
571 }
572
573 public List findByC_K(long companyId, String key) throws SystemException {
574 String finderClassName = TagsProperty.class.getName();
575 String finderMethodName = "findByC_K";
576 String[] finderParams = new String[] {
577 Long.class.getName(), String.class.getName()
578 };
579 Object[] finderArgs = new Object[] { new Long(companyId), key };
580 Object result = FinderCache.getResult(finderClassName,
581 finderMethodName, finderParams, finderArgs, getSessionFactory());
582
583 if (result == null) {
584 Session session = null;
585
586 try {
587 session = openSession();
588
589 StringMaker query = new StringMaker();
590 query.append(
591 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
592 query.append("companyId = ?");
593 query.append(" AND ");
594
595 if (key == null) {
596 query.append("key_ IS NULL");
597 }
598 else {
599 query.append("key_ = ?");
600 }
601
602 query.append(" ");
603 query.append("ORDER BY ");
604 query.append("key_ ASC");
605
606 Query q = session.createQuery(query.toString());
607 int queryPos = 0;
608 q.setLong(queryPos++, companyId);
609
610 if (key != null) {
611 q.setString(queryPos++, key);
612 }
613
614 List list = q.list();
615 FinderCache.putResult(finderClassName, finderMethodName,
616 finderParams, finderArgs, list);
617
618 return list;
619 }
620 catch (Exception e) {
621 throw HibernateUtil.processException(e);
622 }
623 finally {
624 closeSession(session);
625 }
626 }
627 else {
628 return (List)result;
629 }
630 }
631
632 public List findByC_K(long companyId, String key, int begin, int end)
633 throws SystemException {
634 return findByC_K(companyId, key, begin, end, null);
635 }
636
637 public List findByC_K(long companyId, String key, int begin, int end,
638 OrderByComparator obc) throws SystemException {
639 String finderClassName = TagsProperty.class.getName();
640 String finderMethodName = "findByC_K";
641 String[] finderParams = new String[] {
642 Long.class.getName(), String.class.getName(),
643 "java.lang.Integer", "java.lang.Integer",
644 "com.liferay.portal.kernel.util.OrderByComparator"
645 };
646 Object[] finderArgs = new Object[] {
647 new Long(companyId), key, String.valueOf(begin),
648 String.valueOf(end), String.valueOf(obc)
649 };
650 Object result = FinderCache.getResult(finderClassName,
651 finderMethodName, finderParams, finderArgs, getSessionFactory());
652
653 if (result == null) {
654 Session session = null;
655
656 try {
657 session = openSession();
658
659 StringMaker query = new StringMaker();
660 query.append(
661 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
662 query.append("companyId = ?");
663 query.append(" AND ");
664
665 if (key == null) {
666 query.append("key_ IS NULL");
667 }
668 else {
669 query.append("key_ = ?");
670 }
671
672 query.append(" ");
673
674 if (obc != null) {
675 query.append("ORDER BY ");
676 query.append(obc.getOrderBy());
677 }
678 else {
679 query.append("ORDER BY ");
680 query.append("key_ ASC");
681 }
682
683 Query q = session.createQuery(query.toString());
684 int queryPos = 0;
685 q.setLong(queryPos++, companyId);
686
687 if (key != null) {
688 q.setString(queryPos++, key);
689 }
690
691 List list = QueryUtil.list(q, getDialect(), begin, end);
692 FinderCache.putResult(finderClassName, finderMethodName,
693 finderParams, finderArgs, list);
694
695 return list;
696 }
697 catch (Exception e) {
698 throw HibernateUtil.processException(e);
699 }
700 finally {
701 closeSession(session);
702 }
703 }
704 else {
705 return (List)result;
706 }
707 }
708
709 public TagsProperty findByC_K_First(long companyId, String key,
710 OrderByComparator obc) throws NoSuchPropertyException, SystemException {
711 List list = findByC_K(companyId, key, 0, 1, obc);
712
713 if (list.size() == 0) {
714 StringMaker msg = new StringMaker();
715 msg.append("No TagsProperty exists with the key ");
716 msg.append(StringPool.OPEN_CURLY_BRACE);
717 msg.append("companyId=");
718 msg.append(companyId);
719 msg.append(", ");
720 msg.append("key=");
721 msg.append(key);
722 msg.append(StringPool.CLOSE_CURLY_BRACE);
723 throw new NoSuchPropertyException(msg.toString());
724 }
725 else {
726 return (TagsProperty)list.get(0);
727 }
728 }
729
730 public TagsProperty findByC_K_Last(long companyId, String key,
731 OrderByComparator obc) throws NoSuchPropertyException, SystemException {
732 int count = countByC_K(companyId, key);
733 List list = findByC_K(companyId, key, count - 1, count, obc);
734
735 if (list.size() == 0) {
736 StringMaker msg = new StringMaker();
737 msg.append("No TagsProperty exists with the key ");
738 msg.append(StringPool.OPEN_CURLY_BRACE);
739 msg.append("companyId=");
740 msg.append(companyId);
741 msg.append(", ");
742 msg.append("key=");
743 msg.append(key);
744 msg.append(StringPool.CLOSE_CURLY_BRACE);
745 throw new NoSuchPropertyException(msg.toString());
746 }
747 else {
748 return (TagsProperty)list.get(0);
749 }
750 }
751
752 public TagsProperty[] findByC_K_PrevAndNext(long propertyId,
753 long companyId, String key, OrderByComparator obc)
754 throws NoSuchPropertyException, SystemException {
755 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
756 int count = countByC_K(companyId, key);
757 Session session = null;
758
759 try {
760 session = openSession();
761
762 StringMaker query = new StringMaker();
763 query.append(
764 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
765 query.append("companyId = ?");
766 query.append(" AND ");
767
768 if (key == null) {
769 query.append("key_ IS NULL");
770 }
771 else {
772 query.append("key_ = ?");
773 }
774
775 query.append(" ");
776
777 if (obc != null) {
778 query.append("ORDER BY ");
779 query.append(obc.getOrderBy());
780 }
781 else {
782 query.append("ORDER BY ");
783 query.append("key_ ASC");
784 }
785
786 Query q = session.createQuery(query.toString());
787 int queryPos = 0;
788 q.setLong(queryPos++, companyId);
789
790 if (key != null) {
791 q.setString(queryPos++, key);
792 }
793
794 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
795 tagsProperty);
796 TagsProperty[] array = new TagsPropertyImpl[3];
797 array[0] = (TagsProperty)objArray[0];
798 array[1] = (TagsProperty)objArray[1];
799 array[2] = (TagsProperty)objArray[2];
800
801 return array;
802 }
803 catch (Exception e) {
804 throw HibernateUtil.processException(e);
805 }
806 finally {
807 closeSession(session);
808 }
809 }
810
811 public TagsProperty findByE_K(long entryId, String key)
812 throws NoSuchPropertyException, SystemException {
813 TagsProperty tagsProperty = fetchByE_K(entryId, key);
814
815 if (tagsProperty == null) {
816 StringMaker msg = new StringMaker();
817 msg.append("No TagsProperty exists with the key ");
818 msg.append(StringPool.OPEN_CURLY_BRACE);
819 msg.append("entryId=");
820 msg.append(entryId);
821 msg.append(", ");
822 msg.append("key=");
823 msg.append(key);
824 msg.append(StringPool.CLOSE_CURLY_BRACE);
825
826 if (_log.isWarnEnabled()) {
827 _log.warn(msg.toString());
828 }
829
830 throw new NoSuchPropertyException(msg.toString());
831 }
832
833 return tagsProperty;
834 }
835
836 public TagsProperty fetchByE_K(long entryId, String key)
837 throws SystemException {
838 String finderClassName = TagsProperty.class.getName();
839 String finderMethodName = "fetchByE_K";
840 String[] finderParams = new String[] {
841 Long.class.getName(), String.class.getName()
842 };
843 Object[] finderArgs = new Object[] { new Long(entryId), key };
844 Object result = FinderCache.getResult(finderClassName,
845 finderMethodName, finderParams, finderArgs, getSessionFactory());
846
847 if (result == null) {
848 Session session = null;
849
850 try {
851 session = openSession();
852
853 StringMaker query = new StringMaker();
854 query.append(
855 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
856 query.append("entryId = ?");
857 query.append(" AND ");
858
859 if (key == null) {
860 query.append("key_ IS NULL");
861 }
862 else {
863 query.append("key_ = ?");
864 }
865
866 query.append(" ");
867 query.append("ORDER BY ");
868 query.append("key_ ASC");
869
870 Query q = session.createQuery(query.toString());
871 int queryPos = 0;
872 q.setLong(queryPos++, entryId);
873
874 if (key != null) {
875 q.setString(queryPos++, key);
876 }
877
878 List list = q.list();
879 FinderCache.putResult(finderClassName, finderMethodName,
880 finderParams, finderArgs, list);
881
882 if (list.size() == 0) {
883 return null;
884 }
885 else {
886 return (TagsProperty)list.get(0);
887 }
888 }
889 catch (Exception e) {
890 throw HibernateUtil.processException(e);
891 }
892 finally {
893 closeSession(session);
894 }
895 }
896 else {
897 List list = (List)result;
898
899 if (list.size() == 0) {
900 return null;
901 }
902 else {
903 return (TagsProperty)list.get(0);
904 }
905 }
906 }
907
908 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
909 throws SystemException {
910 Session session = null;
911
912 try {
913 session = openSession();
914
915 DynamicQuery query = queryInitializer.initialize(session);
916
917 return query.list();
918 }
919 catch (Exception e) {
920 throw HibernateUtil.processException(e);
921 }
922 finally {
923 closeSession(session);
924 }
925 }
926
927 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
928 int begin, int end) throws SystemException {
929 Session session = null;
930
931 try {
932 session = openSession();
933
934 DynamicQuery query = queryInitializer.initialize(session);
935 query.setLimit(begin, end);
936
937 return query.list();
938 }
939 catch (Exception e) {
940 throw HibernateUtil.processException(e);
941 }
942 finally {
943 closeSession(session);
944 }
945 }
946
947 public List findAll() throws SystemException {
948 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
949 }
950
951 public List findAll(int begin, int end) throws SystemException {
952 return findAll(begin, end, null);
953 }
954
955 public List findAll(int begin, int end, OrderByComparator obc)
956 throws SystemException {
957 String finderClassName = TagsProperty.class.getName();
958 String finderMethodName = "findAll";
959 String[] finderParams = new String[] {
960 "java.lang.Integer", "java.lang.Integer",
961 "com.liferay.portal.kernel.util.OrderByComparator"
962 };
963 Object[] finderArgs = new Object[] {
964 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
965 };
966 Object result = FinderCache.getResult(finderClassName,
967 finderMethodName, finderParams, finderArgs, getSessionFactory());
968
969 if (result == null) {
970 Session session = null;
971
972 try {
973 session = openSession();
974
975 StringMaker query = new StringMaker();
976 query.append(
977 "FROM com.liferay.portlet.tags.model.TagsProperty ");
978
979 if (obc != null) {
980 query.append("ORDER BY ");
981 query.append(obc.getOrderBy());
982 }
983 else {
984 query.append("ORDER BY ");
985 query.append("key_ ASC");
986 }
987
988 Query q = session.createQuery(query.toString());
989 List list = QueryUtil.list(q, getDialect(), begin, end);
990
991 if (obc == null) {
992 Collections.sort(list);
993 }
994
995 FinderCache.putResult(finderClassName, finderMethodName,
996 finderParams, finderArgs, list);
997
998 return list;
999 }
1000 catch (Exception e) {
1001 throw HibernateUtil.processException(e);
1002 }
1003 finally {
1004 closeSession(session);
1005 }
1006 }
1007 else {
1008 return (List)result;
1009 }
1010 }
1011
1012 public void removeByCompanyId(long companyId) throws SystemException {
1013 Iterator itr = findByCompanyId(companyId).iterator();
1014
1015 while (itr.hasNext()) {
1016 TagsProperty tagsProperty = (TagsProperty)itr.next();
1017 remove(tagsProperty);
1018 }
1019 }
1020
1021 public void removeByEntryId(long entryId) throws SystemException {
1022 Iterator itr = findByEntryId(entryId).iterator();
1023
1024 while (itr.hasNext()) {
1025 TagsProperty tagsProperty = (TagsProperty)itr.next();
1026 remove(tagsProperty);
1027 }
1028 }
1029
1030 public void removeByC_K(long companyId, String key)
1031 throws SystemException {
1032 Iterator itr = findByC_K(companyId, key).iterator();
1033
1034 while (itr.hasNext()) {
1035 TagsProperty tagsProperty = (TagsProperty)itr.next();
1036 remove(tagsProperty);
1037 }
1038 }
1039
1040 public void removeByE_K(long entryId, String key)
1041 throws NoSuchPropertyException, SystemException {
1042 TagsProperty tagsProperty = findByE_K(entryId, key);
1043 remove(tagsProperty);
1044 }
1045
1046 public void removeAll() throws SystemException {
1047 Iterator itr = findAll().iterator();
1048
1049 while (itr.hasNext()) {
1050 remove((TagsProperty)itr.next());
1051 }
1052 }
1053
1054 public int countByCompanyId(long companyId) throws SystemException {
1055 String finderClassName = TagsProperty.class.getName();
1056 String finderMethodName = "countByCompanyId";
1057 String[] finderParams = new String[] { Long.class.getName() };
1058 Object[] finderArgs = new Object[] { new Long(companyId) };
1059 Object result = FinderCache.getResult(finderClassName,
1060 finderMethodName, finderParams, finderArgs, getSessionFactory());
1061
1062 if (result == null) {
1063 Session session = null;
1064
1065 try {
1066 session = openSession();
1067
1068 StringMaker query = new StringMaker();
1069 query.append("SELECT COUNT(*) ");
1070 query.append(
1071 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
1072 query.append("companyId = ?");
1073 query.append(" ");
1074
1075 Query q = session.createQuery(query.toString());
1076 int queryPos = 0;
1077 q.setLong(queryPos++, companyId);
1078
1079 Long count = null;
1080 Iterator itr = q.list().iterator();
1081
1082 if (itr.hasNext()) {
1083 count = (Long)itr.next();
1084 }
1085
1086 if (count == null) {
1087 count = new Long(0);
1088 }
1089
1090 FinderCache.putResult(finderClassName, finderMethodName,
1091 finderParams, finderArgs, count);
1092
1093 return count.intValue();
1094 }
1095 catch (Exception e) {
1096 throw HibernateUtil.processException(e);
1097 }
1098 finally {
1099 closeSession(session);
1100 }
1101 }
1102 else {
1103 return ((Long)result).intValue();
1104 }
1105 }
1106
1107 public int countByEntryId(long entryId) throws SystemException {
1108 String finderClassName = TagsProperty.class.getName();
1109 String finderMethodName = "countByEntryId";
1110 String[] finderParams = new String[] { Long.class.getName() };
1111 Object[] finderArgs = new Object[] { new Long(entryId) };
1112 Object result = FinderCache.getResult(finderClassName,
1113 finderMethodName, finderParams, finderArgs, getSessionFactory());
1114
1115 if (result == null) {
1116 Session session = null;
1117
1118 try {
1119 session = openSession();
1120
1121 StringMaker query = new StringMaker();
1122 query.append("SELECT COUNT(*) ");
1123 query.append(
1124 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
1125 query.append("entryId = ?");
1126 query.append(" ");
1127
1128 Query q = session.createQuery(query.toString());
1129 int queryPos = 0;
1130 q.setLong(queryPos++, entryId);
1131
1132 Long count = null;
1133 Iterator itr = q.list().iterator();
1134
1135 if (itr.hasNext()) {
1136 count = (Long)itr.next();
1137 }
1138
1139 if (count == null) {
1140 count = new Long(0);
1141 }
1142
1143 FinderCache.putResult(finderClassName, finderMethodName,
1144 finderParams, finderArgs, count);
1145
1146 return count.intValue();
1147 }
1148 catch (Exception e) {
1149 throw HibernateUtil.processException(e);
1150 }
1151 finally {
1152 closeSession(session);
1153 }
1154 }
1155 else {
1156 return ((Long)result).intValue();
1157 }
1158 }
1159
1160 public int countByC_K(long companyId, String key) throws SystemException {
1161 String finderClassName = TagsProperty.class.getName();
1162 String finderMethodName = "countByC_K";
1163 String[] finderParams = new String[] {
1164 Long.class.getName(), String.class.getName()
1165 };
1166 Object[] finderArgs = new Object[] { new Long(companyId), key };
1167 Object result = FinderCache.getResult(finderClassName,
1168 finderMethodName, finderParams, finderArgs, getSessionFactory());
1169
1170 if (result == null) {
1171 Session session = null;
1172
1173 try {
1174 session = openSession();
1175
1176 StringMaker query = new StringMaker();
1177 query.append("SELECT COUNT(*) ");
1178 query.append(
1179 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
1180 query.append("companyId = ?");
1181 query.append(" AND ");
1182
1183 if (key == null) {
1184 query.append("key_ IS NULL");
1185 }
1186 else {
1187 query.append("key_ = ?");
1188 }
1189
1190 query.append(" ");
1191
1192 Query q = session.createQuery(query.toString());
1193 int queryPos = 0;
1194 q.setLong(queryPos++, companyId);
1195
1196 if (key != null) {
1197 q.setString(queryPos++, key);
1198 }
1199
1200 Long count = null;
1201 Iterator itr = q.list().iterator();
1202
1203 if (itr.hasNext()) {
1204 count = (Long)itr.next();
1205 }
1206
1207 if (count == null) {
1208 count = new Long(0);
1209 }
1210
1211 FinderCache.putResult(finderClassName, finderMethodName,
1212 finderParams, finderArgs, count);
1213
1214 return count.intValue();
1215 }
1216 catch (Exception e) {
1217 throw HibernateUtil.processException(e);
1218 }
1219 finally {
1220 closeSession(session);
1221 }
1222 }
1223 else {
1224 return ((Long)result).intValue();
1225 }
1226 }
1227
1228 public int countByE_K(long entryId, String key) throws SystemException {
1229 String finderClassName = TagsProperty.class.getName();
1230 String finderMethodName = "countByE_K";
1231 String[] finderParams = new String[] {
1232 Long.class.getName(), String.class.getName()
1233 };
1234 Object[] finderArgs = new Object[] { new Long(entryId), key };
1235 Object result = FinderCache.getResult(finderClassName,
1236 finderMethodName, finderParams, finderArgs, getSessionFactory());
1237
1238 if (result == null) {
1239 Session session = null;
1240
1241 try {
1242 session = openSession();
1243
1244 StringMaker query = new StringMaker();
1245 query.append("SELECT COUNT(*) ");
1246 query.append(
1247 "FROM com.liferay.portlet.tags.model.TagsProperty WHERE ");
1248 query.append("entryId = ?");
1249 query.append(" AND ");
1250
1251 if (key == null) {
1252 query.append("key_ IS NULL");
1253 }
1254 else {
1255 query.append("key_ = ?");
1256 }
1257
1258 query.append(" ");
1259
1260 Query q = session.createQuery(query.toString());
1261 int queryPos = 0;
1262 q.setLong(queryPos++, entryId);
1263
1264 if (key != null) {
1265 q.setString(queryPos++, key);
1266 }
1267
1268 Long count = null;
1269 Iterator itr = q.list().iterator();
1270
1271 if (itr.hasNext()) {
1272 count = (Long)itr.next();
1273 }
1274
1275 if (count == null) {
1276 count = new Long(0);
1277 }
1278
1279 FinderCache.putResult(finderClassName, finderMethodName,
1280 finderParams, finderArgs, count);
1281
1282 return count.intValue();
1283 }
1284 catch (Exception e) {
1285 throw HibernateUtil.processException(e);
1286 }
1287 finally {
1288 closeSession(session);
1289 }
1290 }
1291 else {
1292 return ((Long)result).intValue();
1293 }
1294 }
1295
1296 public int countAll() throws SystemException {
1297 String finderClassName = TagsProperty.class.getName();
1298 String finderMethodName = "countAll";
1299 String[] finderParams = new String[] { };
1300 Object[] finderArgs = new Object[] { };
1301 Object result = FinderCache.getResult(finderClassName,
1302 finderMethodName, finderParams, finderArgs, getSessionFactory());
1303
1304 if (result == null) {
1305 Session session = null;
1306
1307 try {
1308 session = openSession();
1309
1310 StringMaker query = new StringMaker();
1311 query.append("SELECT COUNT(*) ");
1312 query.append("FROM com.liferay.portlet.tags.model.TagsProperty");
1313
1314 Query q = session.createQuery(query.toString());
1315 Long count = null;
1316 Iterator itr = q.list().iterator();
1317
1318 if (itr.hasNext()) {
1319 count = (Long)itr.next();
1320 }
1321
1322 if (count == null) {
1323 count = new Long(0);
1324 }
1325
1326 FinderCache.putResult(finderClassName, finderMethodName,
1327 finderParams, finderArgs, count);
1328
1329 return count.intValue();
1330 }
1331 catch (Exception e) {
1332 throw HibernateUtil.processException(e);
1333 }
1334 finally {
1335 closeSession(session);
1336 }
1337 }
1338 else {
1339 return ((Long)result).intValue();
1340 }
1341 }
1342
1343 protected void initDao() {
1344 }
1345
1346 private static Log _log = LogFactory.getLog(TagsPropertyPersistenceImpl.class);
1347}