1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchPhoneException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.dao.DynamicQuery;
28 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.model.Phone;
33 import com.liferay.portal.model.impl.PhoneImpl;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37
38 import com.liferay.util.dao.hibernate.QueryUtil;
39
40 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42
43 import org.hibernate.Query;
44 import org.hibernate.Session;
45
46 import java.util.Collections;
47 import java.util.Iterator;
48 import java.util.List;
49
50
56 public class PhonePersistenceImpl extends BasePersistence
57 implements PhonePersistence {
58 public Phone create(long phoneId) {
59 Phone phone = new PhoneImpl();
60 phone.setNew(true);
61 phone.setPrimaryKey(phoneId);
62
63 return phone;
64 }
65
66 public Phone remove(long phoneId)
67 throws NoSuchPhoneException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 Phone phone = (Phone)session.get(PhoneImpl.class, new Long(phoneId));
74
75 if (phone == null) {
76 if (_log.isWarnEnabled()) {
77 _log.warn("No Phone exists with the primary key " +
78 phoneId);
79 }
80
81 throw new NoSuchPhoneException(
82 "No Phone exists with the primary key " + phoneId);
83 }
84
85 return remove(phone);
86 }
87 catch (NoSuchPhoneException nsee) {
88 throw nsee;
89 }
90 catch (Exception e) {
91 throw HibernateUtil.processException(e);
92 }
93 finally {
94 closeSession(session);
95 }
96 }
97
98 public Phone remove(Phone phone) throws SystemException {
99 Session session = null;
100
101 try {
102 session = openSession();
103 session.delete(phone);
104 session.flush();
105
106 return phone;
107 }
108 catch (Exception e) {
109 throw HibernateUtil.processException(e);
110 }
111 finally {
112 closeSession(session);
113 FinderCache.clearCache(Phone.class.getName());
114 }
115 }
116
117 public Phone update(com.liferay.portal.model.Phone phone)
118 throws SystemException {
119 return update(phone, false);
120 }
121
122 public Phone update(com.liferay.portal.model.Phone phone, boolean merge)
123 throws SystemException {
124 Session session = null;
125
126 try {
127 session = openSession();
128
129 if (merge) {
130 session.merge(phone);
131 }
132 else {
133 if (phone.isNew()) {
134 session.save(phone);
135 }
136 }
137
138 session.flush();
139 phone.setNew(false);
140
141 return phone;
142 }
143 catch (Exception e) {
144 throw HibernateUtil.processException(e);
145 }
146 finally {
147 closeSession(session);
148 FinderCache.clearCache(Phone.class.getName());
149 }
150 }
151
152 public Phone findByPrimaryKey(long phoneId)
153 throws NoSuchPhoneException, SystemException {
154 Phone phone = fetchByPrimaryKey(phoneId);
155
156 if (phone == null) {
157 if (_log.isWarnEnabled()) {
158 _log.warn("No Phone exists with the primary key " + phoneId);
159 }
160
161 throw new NoSuchPhoneException(
162 "No Phone exists with the primary key " + phoneId);
163 }
164
165 return phone;
166 }
167
168 public Phone fetchByPrimaryKey(long phoneId) throws SystemException {
169 Session session = null;
170
171 try {
172 session = openSession();
173
174 return (Phone)session.get(PhoneImpl.class, new Long(phoneId));
175 }
176 catch (Exception e) {
177 throw HibernateUtil.processException(e);
178 }
179 finally {
180 closeSession(session);
181 }
182 }
183
184 public List findByCompanyId(long companyId) throws SystemException {
185 String finderClassName = Phone.class.getName();
186 String finderMethodName = "findByCompanyId";
187 String[] finderParams = new String[] { Long.class.getName() };
188 Object[] finderArgs = new Object[] { new Long(companyId) };
189 Object result = FinderCache.getResult(finderClassName,
190 finderMethodName, finderParams, finderArgs, getSessionFactory());
191
192 if (result == null) {
193 Session session = null;
194
195 try {
196 session = openSession();
197
198 StringMaker query = new StringMaker();
199 query.append("FROM com.liferay.portal.model.Phone WHERE ");
200 query.append("companyId = ?");
201 query.append(" ");
202 query.append("ORDER BY ");
203 query.append("createDate ASC");
204
205 Query q = session.createQuery(query.toString());
206 int queryPos = 0;
207 q.setLong(queryPos++, companyId);
208
209 List list = q.list();
210 FinderCache.putResult(finderClassName, finderMethodName,
211 finderParams, finderArgs, list);
212
213 return list;
214 }
215 catch (Exception e) {
216 throw HibernateUtil.processException(e);
217 }
218 finally {
219 closeSession(session);
220 }
221 }
222 else {
223 return (List)result;
224 }
225 }
226
227 public List findByCompanyId(long companyId, int begin, int end)
228 throws SystemException {
229 return findByCompanyId(companyId, begin, end, null);
230 }
231
232 public List findByCompanyId(long companyId, int begin, int end,
233 OrderByComparator obc) throws SystemException {
234 String finderClassName = Phone.class.getName();
235 String finderMethodName = "findByCompanyId";
236 String[] finderParams = new String[] {
237 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
238 "com.liferay.portal.kernel.util.OrderByComparator"
239 };
240 Object[] finderArgs = new Object[] {
241 new Long(companyId), String.valueOf(begin), String.valueOf(end),
242 String.valueOf(obc)
243 };
244 Object result = FinderCache.getResult(finderClassName,
245 finderMethodName, finderParams, finderArgs, getSessionFactory());
246
247 if (result == null) {
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 StringMaker query = new StringMaker();
254 query.append("FROM com.liferay.portal.model.Phone WHERE ");
255 query.append("companyId = ?");
256 query.append(" ");
257
258 if (obc != null) {
259 query.append("ORDER BY ");
260 query.append(obc.getOrderBy());
261 }
262 else {
263 query.append("ORDER BY ");
264 query.append("createDate ASC");
265 }
266
267 Query q = session.createQuery(query.toString());
268 int queryPos = 0;
269 q.setLong(queryPos++, companyId);
270
271 List list = QueryUtil.list(q, getDialect(), begin, end);
272 FinderCache.putResult(finderClassName, finderMethodName,
273 finderParams, finderArgs, list);
274
275 return list;
276 }
277 catch (Exception e) {
278 throw HibernateUtil.processException(e);
279 }
280 finally {
281 closeSession(session);
282 }
283 }
284 else {
285 return (List)result;
286 }
287 }
288
289 public Phone findByCompanyId_First(long companyId, OrderByComparator obc)
290 throws NoSuchPhoneException, SystemException {
291 List list = findByCompanyId(companyId, 0, 1, obc);
292
293 if (list.size() == 0) {
294 StringMaker msg = new StringMaker();
295 msg.append("No Phone exists with the key ");
296 msg.append(StringPool.OPEN_CURLY_BRACE);
297 msg.append("companyId=");
298 msg.append(companyId);
299 msg.append(StringPool.CLOSE_CURLY_BRACE);
300 throw new NoSuchPhoneException(msg.toString());
301 }
302 else {
303 return (Phone)list.get(0);
304 }
305 }
306
307 public Phone findByCompanyId_Last(long companyId, OrderByComparator obc)
308 throws NoSuchPhoneException, SystemException {
309 int count = countByCompanyId(companyId);
310 List list = findByCompanyId(companyId, count - 1, count, obc);
311
312 if (list.size() == 0) {
313 StringMaker msg = new StringMaker();
314 msg.append("No Phone exists with the key ");
315 msg.append(StringPool.OPEN_CURLY_BRACE);
316 msg.append("companyId=");
317 msg.append(companyId);
318 msg.append(StringPool.CLOSE_CURLY_BRACE);
319 throw new NoSuchPhoneException(msg.toString());
320 }
321 else {
322 return (Phone)list.get(0);
323 }
324 }
325
326 public Phone[] findByCompanyId_PrevAndNext(long phoneId, long companyId,
327 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
328 Phone phone = findByPrimaryKey(phoneId);
329 int count = countByCompanyId(companyId);
330 Session session = null;
331
332 try {
333 session = openSession();
334
335 StringMaker query = new StringMaker();
336 query.append("FROM com.liferay.portal.model.Phone WHERE ");
337 query.append("companyId = ?");
338 query.append(" ");
339
340 if (obc != null) {
341 query.append("ORDER BY ");
342 query.append(obc.getOrderBy());
343 }
344 else {
345 query.append("ORDER BY ");
346 query.append("createDate ASC");
347 }
348
349 Query q = session.createQuery(query.toString());
350 int queryPos = 0;
351 q.setLong(queryPos++, companyId);
352
353 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
354 Phone[] array = new PhoneImpl[3];
355 array[0] = (Phone)objArray[0];
356 array[1] = (Phone)objArray[1];
357 array[2] = (Phone)objArray[2];
358
359 return array;
360 }
361 catch (Exception e) {
362 throw HibernateUtil.processException(e);
363 }
364 finally {
365 closeSession(session);
366 }
367 }
368
369 public List findByUserId(long userId) throws SystemException {
370 String finderClassName = Phone.class.getName();
371 String finderMethodName = "findByUserId";
372 String[] finderParams = new String[] { Long.class.getName() };
373 Object[] finderArgs = new Object[] { new Long(userId) };
374 Object result = FinderCache.getResult(finderClassName,
375 finderMethodName, finderParams, finderArgs, getSessionFactory());
376
377 if (result == null) {
378 Session session = null;
379
380 try {
381 session = openSession();
382
383 StringMaker query = new StringMaker();
384 query.append("FROM com.liferay.portal.model.Phone WHERE ");
385 query.append("userId = ?");
386 query.append(" ");
387 query.append("ORDER BY ");
388 query.append("createDate ASC");
389
390 Query q = session.createQuery(query.toString());
391 int queryPos = 0;
392 q.setLong(queryPos++, userId);
393
394 List list = q.list();
395 FinderCache.putResult(finderClassName, finderMethodName,
396 finderParams, finderArgs, list);
397
398 return list;
399 }
400 catch (Exception e) {
401 throw HibernateUtil.processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406 }
407 else {
408 return (List)result;
409 }
410 }
411
412 public List findByUserId(long userId, int begin, int end)
413 throws SystemException {
414 return findByUserId(userId, begin, end, null);
415 }
416
417 public List findByUserId(long userId, int begin, int end,
418 OrderByComparator obc) throws SystemException {
419 String finderClassName = Phone.class.getName();
420 String finderMethodName = "findByUserId";
421 String[] finderParams = new String[] {
422 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
423 "com.liferay.portal.kernel.util.OrderByComparator"
424 };
425 Object[] finderArgs = new Object[] {
426 new Long(userId), String.valueOf(begin), String.valueOf(end),
427 String.valueOf(obc)
428 };
429 Object result = FinderCache.getResult(finderClassName,
430 finderMethodName, finderParams, finderArgs, getSessionFactory());
431
432 if (result == null) {
433 Session session = null;
434
435 try {
436 session = openSession();
437
438 StringMaker query = new StringMaker();
439 query.append("FROM com.liferay.portal.model.Phone WHERE ");
440 query.append("userId = ?");
441 query.append(" ");
442
443 if (obc != null) {
444 query.append("ORDER BY ");
445 query.append(obc.getOrderBy());
446 }
447 else {
448 query.append("ORDER BY ");
449 query.append("createDate ASC");
450 }
451
452 Query q = session.createQuery(query.toString());
453 int queryPos = 0;
454 q.setLong(queryPos++, userId);
455
456 List list = QueryUtil.list(q, getDialect(), begin, end);
457 FinderCache.putResult(finderClassName, finderMethodName,
458 finderParams, finderArgs, list);
459
460 return list;
461 }
462 catch (Exception e) {
463 throw HibernateUtil.processException(e);
464 }
465 finally {
466 closeSession(session);
467 }
468 }
469 else {
470 return (List)result;
471 }
472 }
473
474 public Phone findByUserId_First(long userId, OrderByComparator obc)
475 throws NoSuchPhoneException, SystemException {
476 List list = findByUserId(userId, 0, 1, obc);
477
478 if (list.size() == 0) {
479 StringMaker msg = new StringMaker();
480 msg.append("No Phone exists with the key ");
481 msg.append(StringPool.OPEN_CURLY_BRACE);
482 msg.append("userId=");
483 msg.append(userId);
484 msg.append(StringPool.CLOSE_CURLY_BRACE);
485 throw new NoSuchPhoneException(msg.toString());
486 }
487 else {
488 return (Phone)list.get(0);
489 }
490 }
491
492 public Phone findByUserId_Last(long userId, OrderByComparator obc)
493 throws NoSuchPhoneException, SystemException {
494 int count = countByUserId(userId);
495 List list = findByUserId(userId, count - 1, count, obc);
496
497 if (list.size() == 0) {
498 StringMaker msg = new StringMaker();
499 msg.append("No Phone exists with the key ");
500 msg.append(StringPool.OPEN_CURLY_BRACE);
501 msg.append("userId=");
502 msg.append(userId);
503 msg.append(StringPool.CLOSE_CURLY_BRACE);
504 throw new NoSuchPhoneException(msg.toString());
505 }
506 else {
507 return (Phone)list.get(0);
508 }
509 }
510
511 public Phone[] findByUserId_PrevAndNext(long phoneId, long userId,
512 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
513 Phone phone = findByPrimaryKey(phoneId);
514 int count = countByUserId(userId);
515 Session session = null;
516
517 try {
518 session = openSession();
519
520 StringMaker query = new StringMaker();
521 query.append("FROM com.liferay.portal.model.Phone WHERE ");
522 query.append("userId = ?");
523 query.append(" ");
524
525 if (obc != null) {
526 query.append("ORDER BY ");
527 query.append(obc.getOrderBy());
528 }
529 else {
530 query.append("ORDER BY ");
531 query.append("createDate ASC");
532 }
533
534 Query q = session.createQuery(query.toString());
535 int queryPos = 0;
536 q.setLong(queryPos++, userId);
537
538 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
539 Phone[] array = new PhoneImpl[3];
540 array[0] = (Phone)objArray[0];
541 array[1] = (Phone)objArray[1];
542 array[2] = (Phone)objArray[2];
543
544 return array;
545 }
546 catch (Exception e) {
547 throw HibernateUtil.processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552 }
553
554 public List findByC_C(long companyId, long classNameId)
555 throws SystemException {
556 String finderClassName = Phone.class.getName();
557 String finderMethodName = "findByC_C";
558 String[] finderParams = new String[] {
559 Long.class.getName(), Long.class.getName()
560 };
561 Object[] finderArgs = new Object[] {
562 new Long(companyId), new Long(classNameId)
563 };
564 Object result = FinderCache.getResult(finderClassName,
565 finderMethodName, finderParams, finderArgs, getSessionFactory());
566
567 if (result == null) {
568 Session session = null;
569
570 try {
571 session = openSession();
572
573 StringMaker query = new StringMaker();
574 query.append("FROM com.liferay.portal.model.Phone WHERE ");
575 query.append("companyId = ?");
576 query.append(" AND ");
577 query.append("classNameId = ?");
578 query.append(" ");
579 query.append("ORDER BY ");
580 query.append("createDate ASC");
581
582 Query q = session.createQuery(query.toString());
583 int queryPos = 0;
584 q.setLong(queryPos++, companyId);
585 q.setLong(queryPos++, classNameId);
586
587 List list = q.list();
588 FinderCache.putResult(finderClassName, finderMethodName,
589 finderParams, finderArgs, list);
590
591 return list;
592 }
593 catch (Exception e) {
594 throw HibernateUtil.processException(e);
595 }
596 finally {
597 closeSession(session);
598 }
599 }
600 else {
601 return (List)result;
602 }
603 }
604
605 public List findByC_C(long companyId, long classNameId, int begin, int end)
606 throws SystemException {
607 return findByC_C(companyId, classNameId, begin, end, null);
608 }
609
610 public List findByC_C(long companyId, long classNameId, int begin, int end,
611 OrderByComparator obc) throws SystemException {
612 String finderClassName = Phone.class.getName();
613 String finderMethodName = "findByC_C";
614 String[] finderParams = new String[] {
615 Long.class.getName(), Long.class.getName(), "java.lang.Integer",
616 "java.lang.Integer",
617 "com.liferay.portal.kernel.util.OrderByComparator"
618 };
619 Object[] finderArgs = new Object[] {
620 new Long(companyId), new Long(classNameId),
621 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
622 };
623 Object result = FinderCache.getResult(finderClassName,
624 finderMethodName, finderParams, finderArgs, getSessionFactory());
625
626 if (result == null) {
627 Session session = null;
628
629 try {
630 session = openSession();
631
632 StringMaker query = new StringMaker();
633 query.append("FROM com.liferay.portal.model.Phone WHERE ");
634 query.append("companyId = ?");
635 query.append(" AND ");
636 query.append("classNameId = ?");
637 query.append(" ");
638
639 if (obc != null) {
640 query.append("ORDER BY ");
641 query.append(obc.getOrderBy());
642 }
643 else {
644 query.append("ORDER BY ");
645 query.append("createDate ASC");
646 }
647
648 Query q = session.createQuery(query.toString());
649 int queryPos = 0;
650 q.setLong(queryPos++, companyId);
651 q.setLong(queryPos++, classNameId);
652
653 List list = QueryUtil.list(q, getDialect(), begin, end);
654 FinderCache.putResult(finderClassName, finderMethodName,
655 finderParams, finderArgs, list);
656
657 return list;
658 }
659 catch (Exception e) {
660 throw HibernateUtil.processException(e);
661 }
662 finally {
663 closeSession(session);
664 }
665 }
666 else {
667 return (List)result;
668 }
669 }
670
671 public Phone findByC_C_First(long companyId, long classNameId,
672 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
673 List list = findByC_C(companyId, classNameId, 0, 1, obc);
674
675 if (list.size() == 0) {
676 StringMaker msg = new StringMaker();
677 msg.append("No Phone exists with the key ");
678 msg.append(StringPool.OPEN_CURLY_BRACE);
679 msg.append("companyId=");
680 msg.append(companyId);
681 msg.append(", ");
682 msg.append("classNameId=");
683 msg.append(classNameId);
684 msg.append(StringPool.CLOSE_CURLY_BRACE);
685 throw new NoSuchPhoneException(msg.toString());
686 }
687 else {
688 return (Phone)list.get(0);
689 }
690 }
691
692 public Phone findByC_C_Last(long companyId, long classNameId,
693 OrderByComparator obc) throws NoSuchPhoneException, SystemException {
694 int count = countByC_C(companyId, classNameId);
695 List list = findByC_C(companyId, classNameId, count - 1, count, obc);
696
697 if (list.size() == 0) {
698 StringMaker msg = new StringMaker();
699 msg.append("No Phone exists with the key ");
700 msg.append(StringPool.OPEN_CURLY_BRACE);
701 msg.append("companyId=");
702 msg.append(companyId);
703 msg.append(", ");
704 msg.append("classNameId=");
705 msg.append(classNameId);
706 msg.append(StringPool.CLOSE_CURLY_BRACE);
707 throw new NoSuchPhoneException(msg.toString());
708 }
709 else {
710 return (Phone)list.get(0);
711 }
712 }
713
714 public Phone[] findByC_C_PrevAndNext(long phoneId, long companyId,
715 long classNameId, OrderByComparator obc)
716 throws NoSuchPhoneException, SystemException {
717 Phone phone = findByPrimaryKey(phoneId);
718 int count = countByC_C(companyId, classNameId);
719 Session session = null;
720
721 try {
722 session = openSession();
723
724 StringMaker query = new StringMaker();
725 query.append("FROM com.liferay.portal.model.Phone WHERE ");
726 query.append("companyId = ?");
727 query.append(" AND ");
728 query.append("classNameId = ?");
729 query.append(" ");
730
731 if (obc != null) {
732 query.append("ORDER BY ");
733 query.append(obc.getOrderBy());
734 }
735 else {
736 query.append("ORDER BY ");
737 query.append("createDate ASC");
738 }
739
740 Query q = session.createQuery(query.toString());
741 int queryPos = 0;
742 q.setLong(queryPos++, companyId);
743 q.setLong(queryPos++, classNameId);
744
745 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
746 Phone[] array = new PhoneImpl[3];
747 array[0] = (Phone)objArray[0];
748 array[1] = (Phone)objArray[1];
749 array[2] = (Phone)objArray[2];
750
751 return array;
752 }
753 catch (Exception e) {
754 throw HibernateUtil.processException(e);
755 }
756 finally {
757 closeSession(session);
758 }
759 }
760
761 public List findByC_C_C(long companyId, long classNameId, long classPK)
762 throws SystemException {
763 String finderClassName = Phone.class.getName();
764 String finderMethodName = "findByC_C_C";
765 String[] finderParams = new String[] {
766 Long.class.getName(), Long.class.getName(), Long.class.getName()
767 };
768 Object[] finderArgs = new Object[] {
769 new Long(companyId), new Long(classNameId), new Long(classPK)
770 };
771 Object result = FinderCache.getResult(finderClassName,
772 finderMethodName, finderParams, finderArgs, getSessionFactory());
773
774 if (result == null) {
775 Session session = null;
776
777 try {
778 session = openSession();
779
780 StringMaker query = new StringMaker();
781 query.append("FROM com.liferay.portal.model.Phone WHERE ");
782 query.append("companyId = ?");
783 query.append(" AND ");
784 query.append("classNameId = ?");
785 query.append(" AND ");
786 query.append("classPK = ?");
787 query.append(" ");
788 query.append("ORDER BY ");
789 query.append("createDate ASC");
790
791 Query q = session.createQuery(query.toString());
792 int queryPos = 0;
793 q.setLong(queryPos++, companyId);
794 q.setLong(queryPos++, classNameId);
795 q.setLong(queryPos++, classPK);
796
797 List list = q.list();
798 FinderCache.putResult(finderClassName, finderMethodName,
799 finderParams, finderArgs, list);
800
801 return list;
802 }
803 catch (Exception e) {
804 throw HibernateUtil.processException(e);
805 }
806 finally {
807 closeSession(session);
808 }
809 }
810 else {
811 return (List)result;
812 }
813 }
814
815 public List findByC_C_C(long companyId, long classNameId, long classPK,
816 int begin, int end) throws SystemException {
817 return findByC_C_C(companyId, classNameId, classPK, begin, end, null);
818 }
819
820 public List findByC_C_C(long companyId, long classNameId, long classPK,
821 int begin, int end, OrderByComparator obc) throws SystemException {
822 String finderClassName = Phone.class.getName();
823 String finderMethodName = "findByC_C_C";
824 String[] finderParams = new String[] {
825 Long.class.getName(), Long.class.getName(), Long.class.getName(),
826 "java.lang.Integer", "java.lang.Integer",
827 "com.liferay.portal.kernel.util.OrderByComparator"
828 };
829 Object[] finderArgs = new Object[] {
830 new Long(companyId), new Long(classNameId), new Long(classPK),
831 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
832 };
833 Object result = FinderCache.getResult(finderClassName,
834 finderMethodName, finderParams, finderArgs, getSessionFactory());
835
836 if (result == null) {
837 Session session = null;
838
839 try {
840 session = openSession();
841
842 StringMaker query = new StringMaker();
843 query.append("FROM com.liferay.portal.model.Phone WHERE ");
844 query.append("companyId = ?");
845 query.append(" AND ");
846 query.append("classNameId = ?");
847 query.append(" AND ");
848 query.append("classPK = ?");
849 query.append(" ");
850
851 if (obc != null) {
852 query.append("ORDER BY ");
853 query.append(obc.getOrderBy());
854 }
855 else {
856 query.append("ORDER BY ");
857 query.append("createDate ASC");
858 }
859
860 Query q = session.createQuery(query.toString());
861 int queryPos = 0;
862 q.setLong(queryPos++, companyId);
863 q.setLong(queryPos++, classNameId);
864 q.setLong(queryPos++, classPK);
865
866 List list = QueryUtil.list(q, getDialect(), begin, end);
867 FinderCache.putResult(finderClassName, finderMethodName,
868 finderParams, finderArgs, list);
869
870 return list;
871 }
872 catch (Exception e) {
873 throw HibernateUtil.processException(e);
874 }
875 finally {
876 closeSession(session);
877 }
878 }
879 else {
880 return (List)result;
881 }
882 }
883
884 public Phone findByC_C_C_First(long companyId, long classNameId,
885 long classPK, OrderByComparator obc)
886 throws NoSuchPhoneException, SystemException {
887 List list = findByC_C_C(companyId, classNameId, classPK, 0, 1, obc);
888
889 if (list.size() == 0) {
890 StringMaker msg = new StringMaker();
891 msg.append("No Phone exists with the key ");
892 msg.append(StringPool.OPEN_CURLY_BRACE);
893 msg.append("companyId=");
894 msg.append(companyId);
895 msg.append(", ");
896 msg.append("classNameId=");
897 msg.append(classNameId);
898 msg.append(", ");
899 msg.append("classPK=");
900 msg.append(classPK);
901 msg.append(StringPool.CLOSE_CURLY_BRACE);
902 throw new NoSuchPhoneException(msg.toString());
903 }
904 else {
905 return (Phone)list.get(0);
906 }
907 }
908
909 public Phone findByC_C_C_Last(long companyId, long classNameId,
910 long classPK, OrderByComparator obc)
911 throws NoSuchPhoneException, SystemException {
912 int count = countByC_C_C(companyId, classNameId, classPK);
913 List list = findByC_C_C(companyId, classNameId, classPK, count - 1,
914 count, obc);
915
916 if (list.size() == 0) {
917 StringMaker msg = new StringMaker();
918 msg.append("No Phone exists with the key ");
919 msg.append(StringPool.OPEN_CURLY_BRACE);
920 msg.append("companyId=");
921 msg.append(companyId);
922 msg.append(", ");
923 msg.append("classNameId=");
924 msg.append(classNameId);
925 msg.append(", ");
926 msg.append("classPK=");
927 msg.append(classPK);
928 msg.append(StringPool.CLOSE_CURLY_BRACE);
929 throw new NoSuchPhoneException(msg.toString());
930 }
931 else {
932 return (Phone)list.get(0);
933 }
934 }
935
936 public Phone[] findByC_C_C_PrevAndNext(long phoneId, long companyId,
937 long classNameId, long classPK, OrderByComparator obc)
938 throws NoSuchPhoneException, SystemException {
939 Phone phone = findByPrimaryKey(phoneId);
940 int count = countByC_C_C(companyId, classNameId, classPK);
941 Session session = null;
942
943 try {
944 session = openSession();
945
946 StringMaker query = new StringMaker();
947 query.append("FROM com.liferay.portal.model.Phone WHERE ");
948 query.append("companyId = ?");
949 query.append(" AND ");
950 query.append("classNameId = ?");
951 query.append(" AND ");
952 query.append("classPK = ?");
953 query.append(" ");
954
955 if (obc != null) {
956 query.append("ORDER BY ");
957 query.append(obc.getOrderBy());
958 }
959 else {
960 query.append("ORDER BY ");
961 query.append("createDate ASC");
962 }
963
964 Query q = session.createQuery(query.toString());
965 int queryPos = 0;
966 q.setLong(queryPos++, companyId);
967 q.setLong(queryPos++, classNameId);
968 q.setLong(queryPos++, classPK);
969
970 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
971 Phone[] array = new PhoneImpl[3];
972 array[0] = (Phone)objArray[0];
973 array[1] = (Phone)objArray[1];
974 array[2] = (Phone)objArray[2];
975
976 return array;
977 }
978 catch (Exception e) {
979 throw HibernateUtil.processException(e);
980 }
981 finally {
982 closeSession(session);
983 }
984 }
985
986 public List findByC_C_C_P(long companyId, long classNameId, long classPK,
987 boolean primary) throws SystemException {
988 String finderClassName = Phone.class.getName();
989 String finderMethodName = "findByC_C_C_P";
990 String[] finderParams = new String[] {
991 Long.class.getName(), Long.class.getName(), Long.class.getName(),
992 Boolean.class.getName()
993 };
994 Object[] finderArgs = new Object[] {
995 new Long(companyId), new Long(classNameId), new Long(classPK),
996 Boolean.valueOf(primary)
997 };
998 Object result = FinderCache.getResult(finderClassName,
999 finderMethodName, finderParams, finderArgs, getSessionFactory());
1000
1001 if (result == null) {
1002 Session session = null;
1003
1004 try {
1005 session = openSession();
1006
1007 StringMaker query = new StringMaker();
1008 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1009 query.append("companyId = ?");
1010 query.append(" AND ");
1011 query.append("classNameId = ?");
1012 query.append(" AND ");
1013 query.append("classPK = ?");
1014 query.append(" AND ");
1015 query.append("primary_ = ?");
1016 query.append(" ");
1017 query.append("ORDER BY ");
1018 query.append("createDate ASC");
1019
1020 Query q = session.createQuery(query.toString());
1021 int queryPos = 0;
1022 q.setLong(queryPos++, companyId);
1023 q.setLong(queryPos++, classNameId);
1024 q.setLong(queryPos++, classPK);
1025 q.setBoolean(queryPos++, primary);
1026
1027 List list = q.list();
1028 FinderCache.putResult(finderClassName, finderMethodName,
1029 finderParams, finderArgs, list);
1030
1031 return list;
1032 }
1033 catch (Exception e) {
1034 throw HibernateUtil.processException(e);
1035 }
1036 finally {
1037 closeSession(session);
1038 }
1039 }
1040 else {
1041 return (List)result;
1042 }
1043 }
1044
1045 public List findByC_C_C_P(long companyId, long classNameId, long classPK,
1046 boolean primary, int begin, int end) throws SystemException {
1047 return findByC_C_C_P(companyId, classNameId, classPK, primary, begin,
1048 end, null);
1049 }
1050
1051 public List findByC_C_C_P(long companyId, long classNameId, long classPK,
1052 boolean primary, int begin, int end, OrderByComparator obc)
1053 throws SystemException {
1054 String finderClassName = Phone.class.getName();
1055 String finderMethodName = "findByC_C_C_P";
1056 String[] finderParams = new String[] {
1057 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1058 Boolean.class.getName(), "java.lang.Integer",
1059 "java.lang.Integer",
1060 "com.liferay.portal.kernel.util.OrderByComparator"
1061 };
1062 Object[] finderArgs = new Object[] {
1063 new Long(companyId), new Long(classNameId), new Long(classPK),
1064 Boolean.valueOf(primary), String.valueOf(begin),
1065 String.valueOf(end), String.valueOf(obc)
1066 };
1067 Object result = FinderCache.getResult(finderClassName,
1068 finderMethodName, finderParams, finderArgs, getSessionFactory());
1069
1070 if (result == null) {
1071 Session session = null;
1072
1073 try {
1074 session = openSession();
1075
1076 StringMaker query = new StringMaker();
1077 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1078 query.append("companyId = ?");
1079 query.append(" AND ");
1080 query.append("classNameId = ?");
1081 query.append(" AND ");
1082 query.append("classPK = ?");
1083 query.append(" AND ");
1084 query.append("primary_ = ?");
1085 query.append(" ");
1086
1087 if (obc != null) {
1088 query.append("ORDER BY ");
1089 query.append(obc.getOrderBy());
1090 }
1091 else {
1092 query.append("ORDER BY ");
1093 query.append("createDate ASC");
1094 }
1095
1096 Query q = session.createQuery(query.toString());
1097 int queryPos = 0;
1098 q.setLong(queryPos++, companyId);
1099 q.setLong(queryPos++, classNameId);
1100 q.setLong(queryPos++, classPK);
1101 q.setBoolean(queryPos++, primary);
1102
1103 List list = QueryUtil.list(q, getDialect(), begin, end);
1104 FinderCache.putResult(finderClassName, finderMethodName,
1105 finderParams, finderArgs, list);
1106
1107 return list;
1108 }
1109 catch (Exception e) {
1110 throw HibernateUtil.processException(e);
1111 }
1112 finally {
1113 closeSession(session);
1114 }
1115 }
1116 else {
1117 return (List)result;
1118 }
1119 }
1120
1121 public Phone findByC_C_C_P_First(long companyId, long classNameId,
1122 long classPK, boolean primary, OrderByComparator obc)
1123 throws NoSuchPhoneException, SystemException {
1124 List list = findByC_C_C_P(companyId, classNameId, classPK, primary, 0,
1125 1, obc);
1126
1127 if (list.size() == 0) {
1128 StringMaker msg = new StringMaker();
1129 msg.append("No Phone exists with the key ");
1130 msg.append(StringPool.OPEN_CURLY_BRACE);
1131 msg.append("companyId=");
1132 msg.append(companyId);
1133 msg.append(", ");
1134 msg.append("classNameId=");
1135 msg.append(classNameId);
1136 msg.append(", ");
1137 msg.append("classPK=");
1138 msg.append(classPK);
1139 msg.append(", ");
1140 msg.append("primary=");
1141 msg.append(primary);
1142 msg.append(StringPool.CLOSE_CURLY_BRACE);
1143 throw new NoSuchPhoneException(msg.toString());
1144 }
1145 else {
1146 return (Phone)list.get(0);
1147 }
1148 }
1149
1150 public Phone findByC_C_C_P_Last(long companyId, long classNameId,
1151 long classPK, boolean primary, OrderByComparator obc)
1152 throws NoSuchPhoneException, SystemException {
1153 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1154 List list = findByC_C_C_P(companyId, classNameId, classPK, primary,
1155 count - 1, count, obc);
1156
1157 if (list.size() == 0) {
1158 StringMaker msg = new StringMaker();
1159 msg.append("No Phone exists with the key ");
1160 msg.append(StringPool.OPEN_CURLY_BRACE);
1161 msg.append("companyId=");
1162 msg.append(companyId);
1163 msg.append(", ");
1164 msg.append("classNameId=");
1165 msg.append(classNameId);
1166 msg.append(", ");
1167 msg.append("classPK=");
1168 msg.append(classPK);
1169 msg.append(", ");
1170 msg.append("primary=");
1171 msg.append(primary);
1172 msg.append(StringPool.CLOSE_CURLY_BRACE);
1173 throw new NoSuchPhoneException(msg.toString());
1174 }
1175 else {
1176 return (Phone)list.get(0);
1177 }
1178 }
1179
1180 public Phone[] findByC_C_C_P_PrevAndNext(long phoneId, long companyId,
1181 long classNameId, long classPK, boolean primary, OrderByComparator obc)
1182 throws NoSuchPhoneException, SystemException {
1183 Phone phone = findByPrimaryKey(phoneId);
1184 int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1185 Session session = null;
1186
1187 try {
1188 session = openSession();
1189
1190 StringMaker query = new StringMaker();
1191 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1192 query.append("companyId = ?");
1193 query.append(" AND ");
1194 query.append("classNameId = ?");
1195 query.append(" AND ");
1196 query.append("classPK = ?");
1197 query.append(" AND ");
1198 query.append("primary_ = ?");
1199 query.append(" ");
1200
1201 if (obc != null) {
1202 query.append("ORDER BY ");
1203 query.append(obc.getOrderBy());
1204 }
1205 else {
1206 query.append("ORDER BY ");
1207 query.append("createDate ASC");
1208 }
1209
1210 Query q = session.createQuery(query.toString());
1211 int queryPos = 0;
1212 q.setLong(queryPos++, companyId);
1213 q.setLong(queryPos++, classNameId);
1214 q.setLong(queryPos++, classPK);
1215 q.setBoolean(queryPos++, primary);
1216
1217 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, phone);
1218 Phone[] array = new PhoneImpl[3];
1219 array[0] = (Phone)objArray[0];
1220 array[1] = (Phone)objArray[1];
1221 array[2] = (Phone)objArray[2];
1222
1223 return array;
1224 }
1225 catch (Exception e) {
1226 throw HibernateUtil.processException(e);
1227 }
1228 finally {
1229 closeSession(session);
1230 }
1231 }
1232
1233 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1234 throws SystemException {
1235 Session session = null;
1236
1237 try {
1238 session = openSession();
1239
1240 DynamicQuery query = queryInitializer.initialize(session);
1241
1242 return query.list();
1243 }
1244 catch (Exception e) {
1245 throw HibernateUtil.processException(e);
1246 }
1247 finally {
1248 closeSession(session);
1249 }
1250 }
1251
1252 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1253 int begin, int end) throws SystemException {
1254 Session session = null;
1255
1256 try {
1257 session = openSession();
1258
1259 DynamicQuery query = queryInitializer.initialize(session);
1260 query.setLimit(begin, end);
1261
1262 return query.list();
1263 }
1264 catch (Exception e) {
1265 throw HibernateUtil.processException(e);
1266 }
1267 finally {
1268 closeSession(session);
1269 }
1270 }
1271
1272 public List findAll() throws SystemException {
1273 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1274 }
1275
1276 public List findAll(int begin, int end) throws SystemException {
1277 return findAll(begin, end, null);
1278 }
1279
1280 public List findAll(int begin, int end, OrderByComparator obc)
1281 throws SystemException {
1282 String finderClassName = Phone.class.getName();
1283 String finderMethodName = "findAll";
1284 String[] finderParams = new String[] {
1285 "java.lang.Integer", "java.lang.Integer",
1286 "com.liferay.portal.kernel.util.OrderByComparator"
1287 };
1288 Object[] finderArgs = new Object[] {
1289 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1290 };
1291 Object result = FinderCache.getResult(finderClassName,
1292 finderMethodName, finderParams, finderArgs, getSessionFactory());
1293
1294 if (result == null) {
1295 Session session = null;
1296
1297 try {
1298 session = openSession();
1299
1300 StringMaker query = new StringMaker();
1301 query.append("FROM com.liferay.portal.model.Phone ");
1302
1303 if (obc != null) {
1304 query.append("ORDER BY ");
1305 query.append(obc.getOrderBy());
1306 }
1307 else {
1308 query.append("ORDER BY ");
1309 query.append("createDate ASC");
1310 }
1311
1312 Query q = session.createQuery(query.toString());
1313 List list = QueryUtil.list(q, getDialect(), begin, end);
1314
1315 if (obc == null) {
1316 Collections.sort(list);
1317 }
1318
1319 FinderCache.putResult(finderClassName, finderMethodName,
1320 finderParams, finderArgs, list);
1321
1322 return list;
1323 }
1324 catch (Exception e) {
1325 throw HibernateUtil.processException(e);
1326 }
1327 finally {
1328 closeSession(session);
1329 }
1330 }
1331 else {
1332 return (List)result;
1333 }
1334 }
1335
1336 public void removeByCompanyId(long companyId) throws SystemException {
1337 Iterator itr = findByCompanyId(companyId).iterator();
1338
1339 while (itr.hasNext()) {
1340 Phone phone = (Phone)itr.next();
1341 remove(phone);
1342 }
1343 }
1344
1345 public void removeByUserId(long userId) throws SystemException {
1346 Iterator itr = findByUserId(userId).iterator();
1347
1348 while (itr.hasNext()) {
1349 Phone phone = (Phone)itr.next();
1350 remove(phone);
1351 }
1352 }
1353
1354 public void removeByC_C(long companyId, long classNameId)
1355 throws SystemException {
1356 Iterator itr = findByC_C(companyId, classNameId).iterator();
1357
1358 while (itr.hasNext()) {
1359 Phone phone = (Phone)itr.next();
1360 remove(phone);
1361 }
1362 }
1363
1364 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1365 throws SystemException {
1366 Iterator itr = findByC_C_C(companyId, classNameId, classPK).iterator();
1367
1368 while (itr.hasNext()) {
1369 Phone phone = (Phone)itr.next();
1370 remove(phone);
1371 }
1372 }
1373
1374 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1375 boolean primary) throws SystemException {
1376 Iterator itr = findByC_C_C_P(companyId, classNameId, classPK, primary)
1377 .iterator();
1378
1379 while (itr.hasNext()) {
1380 Phone phone = (Phone)itr.next();
1381 remove(phone);
1382 }
1383 }
1384
1385 public void removeAll() throws SystemException {
1386 Iterator itr = findAll().iterator();
1387
1388 while (itr.hasNext()) {
1389 remove((Phone)itr.next());
1390 }
1391 }
1392
1393 public int countByCompanyId(long companyId) throws SystemException {
1394 String finderClassName = Phone.class.getName();
1395 String finderMethodName = "countByCompanyId";
1396 String[] finderParams = new String[] { Long.class.getName() };
1397 Object[] finderArgs = new Object[] { new Long(companyId) };
1398 Object result = FinderCache.getResult(finderClassName,
1399 finderMethodName, finderParams, finderArgs, getSessionFactory());
1400
1401 if (result == null) {
1402 Session session = null;
1403
1404 try {
1405 session = openSession();
1406
1407 StringMaker query = new StringMaker();
1408 query.append("SELECT COUNT(*) ");
1409 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1410 query.append("companyId = ?");
1411 query.append(" ");
1412
1413 Query q = session.createQuery(query.toString());
1414 int queryPos = 0;
1415 q.setLong(queryPos++, companyId);
1416
1417 Long count = null;
1418 Iterator itr = q.list().iterator();
1419
1420 if (itr.hasNext()) {
1421 count = (Long)itr.next();
1422 }
1423
1424 if (count == null) {
1425 count = new Long(0);
1426 }
1427
1428 FinderCache.putResult(finderClassName, finderMethodName,
1429 finderParams, finderArgs, count);
1430
1431 return count.intValue();
1432 }
1433 catch (Exception e) {
1434 throw HibernateUtil.processException(e);
1435 }
1436 finally {
1437 closeSession(session);
1438 }
1439 }
1440 else {
1441 return ((Long)result).intValue();
1442 }
1443 }
1444
1445 public int countByUserId(long userId) throws SystemException {
1446 String finderClassName = Phone.class.getName();
1447 String finderMethodName = "countByUserId";
1448 String[] finderParams = new String[] { Long.class.getName() };
1449 Object[] finderArgs = new Object[] { new Long(userId) };
1450 Object result = FinderCache.getResult(finderClassName,
1451 finderMethodName, finderParams, finderArgs, getSessionFactory());
1452
1453 if (result == null) {
1454 Session session = null;
1455
1456 try {
1457 session = openSession();
1458
1459 StringMaker query = new StringMaker();
1460 query.append("SELECT COUNT(*) ");
1461 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1462 query.append("userId = ?");
1463 query.append(" ");
1464
1465 Query q = session.createQuery(query.toString());
1466 int queryPos = 0;
1467 q.setLong(queryPos++, userId);
1468
1469 Long count = null;
1470 Iterator itr = q.list().iterator();
1471
1472 if (itr.hasNext()) {
1473 count = (Long)itr.next();
1474 }
1475
1476 if (count == null) {
1477 count = new Long(0);
1478 }
1479
1480 FinderCache.putResult(finderClassName, finderMethodName,
1481 finderParams, finderArgs, count);
1482
1483 return count.intValue();
1484 }
1485 catch (Exception e) {
1486 throw HibernateUtil.processException(e);
1487 }
1488 finally {
1489 closeSession(session);
1490 }
1491 }
1492 else {
1493 return ((Long)result).intValue();
1494 }
1495 }
1496
1497 public int countByC_C(long companyId, long classNameId)
1498 throws SystemException {
1499 String finderClassName = Phone.class.getName();
1500 String finderMethodName = "countByC_C";
1501 String[] finderParams = new String[] {
1502 Long.class.getName(), Long.class.getName()
1503 };
1504 Object[] finderArgs = new Object[] {
1505 new Long(companyId), new Long(classNameId)
1506 };
1507 Object result = FinderCache.getResult(finderClassName,
1508 finderMethodName, finderParams, finderArgs, getSessionFactory());
1509
1510 if (result == null) {
1511 Session session = null;
1512
1513 try {
1514 session = openSession();
1515
1516 StringMaker query = new StringMaker();
1517 query.append("SELECT COUNT(*) ");
1518 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1519 query.append("companyId = ?");
1520 query.append(" AND ");
1521 query.append("classNameId = ?");
1522 query.append(" ");
1523
1524 Query q = session.createQuery(query.toString());
1525 int queryPos = 0;
1526 q.setLong(queryPos++, companyId);
1527 q.setLong(queryPos++, classNameId);
1528
1529 Long count = null;
1530 Iterator itr = q.list().iterator();
1531
1532 if (itr.hasNext()) {
1533 count = (Long)itr.next();
1534 }
1535
1536 if (count == null) {
1537 count = new Long(0);
1538 }
1539
1540 FinderCache.putResult(finderClassName, finderMethodName,
1541 finderParams, finderArgs, count);
1542
1543 return count.intValue();
1544 }
1545 catch (Exception e) {
1546 throw HibernateUtil.processException(e);
1547 }
1548 finally {
1549 closeSession(session);
1550 }
1551 }
1552 else {
1553 return ((Long)result).intValue();
1554 }
1555 }
1556
1557 public int countByC_C_C(long companyId, long classNameId, long classPK)
1558 throws SystemException {
1559 String finderClassName = Phone.class.getName();
1560 String finderMethodName = "countByC_C_C";
1561 String[] finderParams = new String[] {
1562 Long.class.getName(), Long.class.getName(), Long.class.getName()
1563 };
1564 Object[] finderArgs = new Object[] {
1565 new Long(companyId), new Long(classNameId), new Long(classPK)
1566 };
1567 Object result = FinderCache.getResult(finderClassName,
1568 finderMethodName, finderParams, finderArgs, getSessionFactory());
1569
1570 if (result == null) {
1571 Session session = null;
1572
1573 try {
1574 session = openSession();
1575
1576 StringMaker query = new StringMaker();
1577 query.append("SELECT COUNT(*) ");
1578 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1579 query.append("companyId = ?");
1580 query.append(" AND ");
1581 query.append("classNameId = ?");
1582 query.append(" AND ");
1583 query.append("classPK = ?");
1584 query.append(" ");
1585
1586 Query q = session.createQuery(query.toString());
1587 int queryPos = 0;
1588 q.setLong(queryPos++, companyId);
1589 q.setLong(queryPos++, classNameId);
1590 q.setLong(queryPos++, classPK);
1591
1592 Long count = null;
1593 Iterator itr = q.list().iterator();
1594
1595 if (itr.hasNext()) {
1596 count = (Long)itr.next();
1597 }
1598
1599 if (count == null) {
1600 count = new Long(0);
1601 }
1602
1603 FinderCache.putResult(finderClassName, finderMethodName,
1604 finderParams, finderArgs, count);
1605
1606 return count.intValue();
1607 }
1608 catch (Exception e) {
1609 throw HibernateUtil.processException(e);
1610 }
1611 finally {
1612 closeSession(session);
1613 }
1614 }
1615 else {
1616 return ((Long)result).intValue();
1617 }
1618 }
1619
1620 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
1621 boolean primary) throws SystemException {
1622 String finderClassName = Phone.class.getName();
1623 String finderMethodName = "countByC_C_C_P";
1624 String[] finderParams = new String[] {
1625 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1626 Boolean.class.getName()
1627 };
1628 Object[] finderArgs = new Object[] {
1629 new Long(companyId), new Long(classNameId), new Long(classPK),
1630 Boolean.valueOf(primary)
1631 };
1632 Object result = FinderCache.getResult(finderClassName,
1633 finderMethodName, finderParams, finderArgs, getSessionFactory());
1634
1635 if (result == null) {
1636 Session session = null;
1637
1638 try {
1639 session = openSession();
1640
1641 StringMaker query = new StringMaker();
1642 query.append("SELECT COUNT(*) ");
1643 query.append("FROM com.liferay.portal.model.Phone WHERE ");
1644 query.append("companyId = ?");
1645 query.append(" AND ");
1646 query.append("classNameId = ?");
1647 query.append(" AND ");
1648 query.append("classPK = ?");
1649 query.append(" AND ");
1650 query.append("primary_ = ?");
1651 query.append(" ");
1652
1653 Query q = session.createQuery(query.toString());
1654 int queryPos = 0;
1655 q.setLong(queryPos++, companyId);
1656 q.setLong(queryPos++, classNameId);
1657 q.setLong(queryPos++, classPK);
1658 q.setBoolean(queryPos++, primary);
1659
1660 Long count = null;
1661 Iterator itr = q.list().iterator();
1662
1663 if (itr.hasNext()) {
1664 count = (Long)itr.next();
1665 }
1666
1667 if (count == null) {
1668 count = new Long(0);
1669 }
1670
1671 FinderCache.putResult(finderClassName, finderMethodName,
1672 finderParams, finderArgs, count);
1673
1674 return count.intValue();
1675 }
1676 catch (Exception e) {
1677 throw HibernateUtil.processException(e);
1678 }
1679 finally {
1680 closeSession(session);
1681 }
1682 }
1683 else {
1684 return ((Long)result).intValue();
1685 }
1686 }
1687
1688 public int countAll() throws SystemException {
1689 String finderClassName = Phone.class.getName();
1690 String finderMethodName = "countAll";
1691 String[] finderParams = new String[] { };
1692 Object[] finderArgs = new Object[] { };
1693 Object result = FinderCache.getResult(finderClassName,
1694 finderMethodName, finderParams, finderArgs, getSessionFactory());
1695
1696 if (result == null) {
1697 Session session = null;
1698
1699 try {
1700 session = openSession();
1701
1702 StringMaker query = new StringMaker();
1703 query.append("SELECT COUNT(*) ");
1704 query.append("FROM com.liferay.portal.model.Phone");
1705
1706 Query q = session.createQuery(query.toString());
1707 Long count = null;
1708 Iterator itr = q.list().iterator();
1709
1710 if (itr.hasNext()) {
1711 count = (Long)itr.next();
1712 }
1713
1714 if (count == null) {
1715 count = new Long(0);
1716 }
1717
1718 FinderCache.putResult(finderClassName, finderMethodName,
1719 finderParams, finderArgs, count);
1720
1721 return count.intValue();
1722 }
1723 catch (Exception e) {
1724 throw HibernateUtil.processException(e);
1725 }
1726 finally {
1727 closeSession(session);
1728 }
1729 }
1730 else {
1731 return ((Long)result).intValue();
1732 }
1733 }
1734
1735 protected void initDao() {
1736 }
1737
1738 private static Log _log = LogFactory.getLog(PhonePersistenceImpl.class);
1739}