1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchUserIdMapperException;
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.UserIdMapper;
33 import com.liferay.portal.model.impl.UserIdMapperImpl;
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 UserIdMapperPersistenceImpl extends BasePersistence
57 implements UserIdMapperPersistence {
58 public UserIdMapper create(long userIdMapperId) {
59 UserIdMapper userIdMapper = new UserIdMapperImpl();
60 userIdMapper.setNew(true);
61 userIdMapper.setPrimaryKey(userIdMapperId);
62
63 return userIdMapper;
64 }
65
66 public UserIdMapper remove(long userIdMapperId)
67 throws NoSuchUserIdMapperException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 UserIdMapper userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
74 new Long(userIdMapperId));
75
76 if (userIdMapper == null) {
77 if (_log.isWarnEnabled()) {
78 _log.warn("No UserIdMapper exists with the primary key " +
79 userIdMapperId);
80 }
81
82 throw new NoSuchUserIdMapperException(
83 "No UserIdMapper exists with the primary key " +
84 userIdMapperId);
85 }
86
87 return remove(userIdMapper);
88 }
89 catch (NoSuchUserIdMapperException nsee) {
90 throw nsee;
91 }
92 catch (Exception e) {
93 throw HibernateUtil.processException(e);
94 }
95 finally {
96 closeSession(session);
97 }
98 }
99
100 public UserIdMapper remove(UserIdMapper userIdMapper)
101 throws SystemException {
102 Session session = null;
103
104 try {
105 session = openSession();
106 session.delete(userIdMapper);
107 session.flush();
108
109 return userIdMapper;
110 }
111 catch (Exception e) {
112 throw HibernateUtil.processException(e);
113 }
114 finally {
115 closeSession(session);
116 FinderCache.clearCache(UserIdMapper.class.getName());
117 }
118 }
119
120 public UserIdMapper update(
121 com.liferay.portal.model.UserIdMapper userIdMapper)
122 throws SystemException {
123 return update(userIdMapper, false);
124 }
125
126 public UserIdMapper update(
127 com.liferay.portal.model.UserIdMapper userIdMapper, boolean merge)
128 throws SystemException {
129 Session session = null;
130
131 try {
132 session = openSession();
133
134 if (merge) {
135 session.merge(userIdMapper);
136 }
137 else {
138 if (userIdMapper.isNew()) {
139 session.save(userIdMapper);
140 }
141 }
142
143 session.flush();
144 userIdMapper.setNew(false);
145
146 return userIdMapper;
147 }
148 catch (Exception e) {
149 throw HibernateUtil.processException(e);
150 }
151 finally {
152 closeSession(session);
153 FinderCache.clearCache(UserIdMapper.class.getName());
154 }
155 }
156
157 public UserIdMapper findByPrimaryKey(long userIdMapperId)
158 throws NoSuchUserIdMapperException, SystemException {
159 UserIdMapper userIdMapper = fetchByPrimaryKey(userIdMapperId);
160
161 if (userIdMapper == null) {
162 if (_log.isWarnEnabled()) {
163 _log.warn("No UserIdMapper exists with the primary key " +
164 userIdMapperId);
165 }
166
167 throw new NoSuchUserIdMapperException(
168 "No UserIdMapper exists with the primary key " +
169 userIdMapperId);
170 }
171
172 return userIdMapper;
173 }
174
175 public UserIdMapper fetchByPrimaryKey(long userIdMapperId)
176 throws SystemException {
177 Session session = null;
178
179 try {
180 session = openSession();
181
182 return (UserIdMapper)session.get(UserIdMapperImpl.class,
183 new Long(userIdMapperId));
184 }
185 catch (Exception e) {
186 throw HibernateUtil.processException(e);
187 }
188 finally {
189 closeSession(session);
190 }
191 }
192
193 public List findByUserId(long userId) throws SystemException {
194 String finderClassName = UserIdMapper.class.getName();
195 String finderMethodName = "findByUserId";
196 String[] finderParams = new String[] { Long.class.getName() };
197 Object[] finderArgs = new Object[] { new Long(userId) };
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.portal.model.UserIdMapper WHERE ");
210 query.append("userId = ?");
211 query.append(" ");
212
213 Query q = session.createQuery(query.toString());
214 int queryPos = 0;
215 q.setLong(queryPos++, userId);
216
217 List list = q.list();
218 FinderCache.putResult(finderClassName, finderMethodName,
219 finderParams, finderArgs, list);
220
221 return list;
222 }
223 catch (Exception e) {
224 throw HibernateUtil.processException(e);
225 }
226 finally {
227 closeSession(session);
228 }
229 }
230 else {
231 return (List)result;
232 }
233 }
234
235 public List findByUserId(long userId, int begin, int end)
236 throws SystemException {
237 return findByUserId(userId, begin, end, null);
238 }
239
240 public List findByUserId(long userId, int begin, int end,
241 OrderByComparator obc) throws SystemException {
242 String finderClassName = UserIdMapper.class.getName();
243 String finderMethodName = "findByUserId";
244 String[] finderParams = new String[] {
245 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
246 "com.liferay.portal.kernel.util.OrderByComparator"
247 };
248 Object[] finderArgs = new Object[] {
249 new Long(userId), String.valueOf(begin), String.valueOf(end),
250 String.valueOf(obc)
251 };
252 Object result = FinderCache.getResult(finderClassName,
253 finderMethodName, finderParams, finderArgs, getSessionFactory());
254
255 if (result == null) {
256 Session session = null;
257
258 try {
259 session = openSession();
260
261 StringMaker query = new StringMaker();
262 query.append(
263 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
264 query.append("userId = ?");
265 query.append(" ");
266
267 if (obc != null) {
268 query.append("ORDER BY ");
269 query.append(obc.getOrderBy());
270 }
271
272 Query q = session.createQuery(query.toString());
273 int queryPos = 0;
274 q.setLong(queryPos++, userId);
275
276 List list = QueryUtil.list(q, getDialect(), begin, end);
277 FinderCache.putResult(finderClassName, finderMethodName,
278 finderParams, finderArgs, list);
279
280 return list;
281 }
282 catch (Exception e) {
283 throw HibernateUtil.processException(e);
284 }
285 finally {
286 closeSession(session);
287 }
288 }
289 else {
290 return (List)result;
291 }
292 }
293
294 public UserIdMapper findByUserId_First(long userId, OrderByComparator obc)
295 throws NoSuchUserIdMapperException, SystemException {
296 List list = findByUserId(userId, 0, 1, obc);
297
298 if (list.size() == 0) {
299 StringMaker msg = new StringMaker();
300 msg.append("No UserIdMapper exists with the key ");
301 msg.append(StringPool.OPEN_CURLY_BRACE);
302 msg.append("userId=");
303 msg.append(userId);
304 msg.append(StringPool.CLOSE_CURLY_BRACE);
305 throw new NoSuchUserIdMapperException(msg.toString());
306 }
307 else {
308 return (UserIdMapper)list.get(0);
309 }
310 }
311
312 public UserIdMapper findByUserId_Last(long userId, OrderByComparator obc)
313 throws NoSuchUserIdMapperException, SystemException {
314 int count = countByUserId(userId);
315 List list = findByUserId(userId, count - 1, count, obc);
316
317 if (list.size() == 0) {
318 StringMaker msg = new StringMaker();
319 msg.append("No UserIdMapper exists with the key ");
320 msg.append(StringPool.OPEN_CURLY_BRACE);
321 msg.append("userId=");
322 msg.append(userId);
323 msg.append(StringPool.CLOSE_CURLY_BRACE);
324 throw new NoSuchUserIdMapperException(msg.toString());
325 }
326 else {
327 return (UserIdMapper)list.get(0);
328 }
329 }
330
331 public UserIdMapper[] findByUserId_PrevAndNext(long userIdMapperId,
332 long userId, OrderByComparator obc)
333 throws NoSuchUserIdMapperException, SystemException {
334 UserIdMapper userIdMapper = findByPrimaryKey(userIdMapperId);
335 int count = countByUserId(userId);
336 Session session = null;
337
338 try {
339 session = openSession();
340
341 StringMaker query = new StringMaker();
342 query.append("FROM com.liferay.portal.model.UserIdMapper WHERE ");
343 query.append("userId = ?");
344 query.append(" ");
345
346 if (obc != null) {
347 query.append("ORDER BY ");
348 query.append(obc.getOrderBy());
349 }
350
351 Query q = session.createQuery(query.toString());
352 int queryPos = 0;
353 q.setLong(queryPos++, userId);
354
355 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
356 userIdMapper);
357 UserIdMapper[] array = new UserIdMapperImpl[3];
358 array[0] = (UserIdMapper)objArray[0];
359 array[1] = (UserIdMapper)objArray[1];
360 array[2] = (UserIdMapper)objArray[2];
361
362 return array;
363 }
364 catch (Exception e) {
365 throw HibernateUtil.processException(e);
366 }
367 finally {
368 closeSession(session);
369 }
370 }
371
372 public UserIdMapper findByU_T(long userId, String type)
373 throws NoSuchUserIdMapperException, SystemException {
374 UserIdMapper userIdMapper = fetchByU_T(userId, type);
375
376 if (userIdMapper == null) {
377 StringMaker msg = new StringMaker();
378 msg.append("No UserIdMapper exists with the key ");
379 msg.append(StringPool.OPEN_CURLY_BRACE);
380 msg.append("userId=");
381 msg.append(userId);
382 msg.append(", ");
383 msg.append("type=");
384 msg.append(type);
385 msg.append(StringPool.CLOSE_CURLY_BRACE);
386
387 if (_log.isWarnEnabled()) {
388 _log.warn(msg.toString());
389 }
390
391 throw new NoSuchUserIdMapperException(msg.toString());
392 }
393
394 return userIdMapper;
395 }
396
397 public UserIdMapper fetchByU_T(long userId, String type)
398 throws SystemException {
399 String finderClassName = UserIdMapper.class.getName();
400 String finderMethodName = "fetchByU_T";
401 String[] finderParams = new String[] {
402 Long.class.getName(), String.class.getName()
403 };
404 Object[] finderArgs = new Object[] { new Long(userId), type };
405 Object result = FinderCache.getResult(finderClassName,
406 finderMethodName, finderParams, finderArgs, getSessionFactory());
407
408 if (result == null) {
409 Session session = null;
410
411 try {
412 session = openSession();
413
414 StringMaker query = new StringMaker();
415 query.append(
416 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
417 query.append("userId = ?");
418 query.append(" AND ");
419
420 if (type == null) {
421 query.append("type_ IS NULL");
422 }
423 else {
424 query.append("type_ = ?");
425 }
426
427 query.append(" ");
428
429 Query q = session.createQuery(query.toString());
430 int queryPos = 0;
431 q.setLong(queryPos++, userId);
432
433 if (type != null) {
434 q.setString(queryPos++, type);
435 }
436
437 List list = q.list();
438 FinderCache.putResult(finderClassName, finderMethodName,
439 finderParams, finderArgs, list);
440
441 if (list.size() == 0) {
442 return null;
443 }
444 else {
445 return (UserIdMapper)list.get(0);
446 }
447 }
448 catch (Exception e) {
449 throw HibernateUtil.processException(e);
450 }
451 finally {
452 closeSession(session);
453 }
454 }
455 else {
456 List list = (List)result;
457
458 if (list.size() == 0) {
459 return null;
460 }
461 else {
462 return (UserIdMapper)list.get(0);
463 }
464 }
465 }
466
467 public UserIdMapper findByT_E(String type, String externalUserId)
468 throws NoSuchUserIdMapperException, SystemException {
469 UserIdMapper userIdMapper = fetchByT_E(type, externalUserId);
470
471 if (userIdMapper == null) {
472 StringMaker msg = new StringMaker();
473 msg.append("No UserIdMapper exists with the key ");
474 msg.append(StringPool.OPEN_CURLY_BRACE);
475 msg.append("type=");
476 msg.append(type);
477 msg.append(", ");
478 msg.append("externalUserId=");
479 msg.append(externalUserId);
480 msg.append(StringPool.CLOSE_CURLY_BRACE);
481
482 if (_log.isWarnEnabled()) {
483 _log.warn(msg.toString());
484 }
485
486 throw new NoSuchUserIdMapperException(msg.toString());
487 }
488
489 return userIdMapper;
490 }
491
492 public UserIdMapper fetchByT_E(String type, String externalUserId)
493 throws SystemException {
494 String finderClassName = UserIdMapper.class.getName();
495 String finderMethodName = "fetchByT_E";
496 String[] finderParams = new String[] {
497 String.class.getName(), String.class.getName()
498 };
499 Object[] finderArgs = new Object[] { type, externalUserId };
500 Object result = FinderCache.getResult(finderClassName,
501 finderMethodName, finderParams, finderArgs, getSessionFactory());
502
503 if (result == null) {
504 Session session = null;
505
506 try {
507 session = openSession();
508
509 StringMaker query = new StringMaker();
510 query.append(
511 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
512
513 if (type == null) {
514 query.append("type_ IS NULL");
515 }
516 else {
517 query.append("type_ = ?");
518 }
519
520 query.append(" AND ");
521
522 if (externalUserId == null) {
523 query.append("externalUserId IS NULL");
524 }
525 else {
526 query.append("externalUserId = ?");
527 }
528
529 query.append(" ");
530
531 Query q = session.createQuery(query.toString());
532 int queryPos = 0;
533
534 if (type != null) {
535 q.setString(queryPos++, type);
536 }
537
538 if (externalUserId != null) {
539 q.setString(queryPos++, externalUserId);
540 }
541
542 List list = q.list();
543 FinderCache.putResult(finderClassName, finderMethodName,
544 finderParams, finderArgs, list);
545
546 if (list.size() == 0) {
547 return null;
548 }
549 else {
550 return (UserIdMapper)list.get(0);
551 }
552 }
553 catch (Exception e) {
554 throw HibernateUtil.processException(e);
555 }
556 finally {
557 closeSession(session);
558 }
559 }
560 else {
561 List list = (List)result;
562
563 if (list.size() == 0) {
564 return null;
565 }
566 else {
567 return (UserIdMapper)list.get(0);
568 }
569 }
570 }
571
572 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
573 throws SystemException {
574 Session session = null;
575
576 try {
577 session = openSession();
578
579 DynamicQuery query = queryInitializer.initialize(session);
580
581 return query.list();
582 }
583 catch (Exception e) {
584 throw HibernateUtil.processException(e);
585 }
586 finally {
587 closeSession(session);
588 }
589 }
590
591 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
592 int begin, int end) throws SystemException {
593 Session session = null;
594
595 try {
596 session = openSession();
597
598 DynamicQuery query = queryInitializer.initialize(session);
599 query.setLimit(begin, end);
600
601 return query.list();
602 }
603 catch (Exception e) {
604 throw HibernateUtil.processException(e);
605 }
606 finally {
607 closeSession(session);
608 }
609 }
610
611 public List findAll() throws SystemException {
612 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
613 }
614
615 public List findAll(int begin, int end) throws SystemException {
616 return findAll(begin, end, null);
617 }
618
619 public List findAll(int begin, int end, OrderByComparator obc)
620 throws SystemException {
621 String finderClassName = UserIdMapper.class.getName();
622 String finderMethodName = "findAll";
623 String[] finderParams = new String[] {
624 "java.lang.Integer", "java.lang.Integer",
625 "com.liferay.portal.kernel.util.OrderByComparator"
626 };
627 Object[] finderArgs = new Object[] {
628 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
629 };
630 Object result = FinderCache.getResult(finderClassName,
631 finderMethodName, finderParams, finderArgs, getSessionFactory());
632
633 if (result == null) {
634 Session session = null;
635
636 try {
637 session = openSession();
638
639 StringMaker query = new StringMaker();
640 query.append("FROM com.liferay.portal.model.UserIdMapper ");
641
642 if (obc != null) {
643 query.append("ORDER BY ");
644 query.append(obc.getOrderBy());
645 }
646
647 Query q = session.createQuery(query.toString());
648 List list = QueryUtil.list(q, getDialect(), begin, end);
649
650 if (obc == null) {
651 Collections.sort(list);
652 }
653
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 void removeByUserId(long userId) throws SystemException {
672 Iterator itr = findByUserId(userId).iterator();
673
674 while (itr.hasNext()) {
675 UserIdMapper userIdMapper = (UserIdMapper)itr.next();
676 remove(userIdMapper);
677 }
678 }
679
680 public void removeByU_T(long userId, String type)
681 throws NoSuchUserIdMapperException, SystemException {
682 UserIdMapper userIdMapper = findByU_T(userId, type);
683 remove(userIdMapper);
684 }
685
686 public void removeByT_E(String type, String externalUserId)
687 throws NoSuchUserIdMapperException, SystemException {
688 UserIdMapper userIdMapper = findByT_E(type, externalUserId);
689 remove(userIdMapper);
690 }
691
692 public void removeAll() throws SystemException {
693 Iterator itr = findAll().iterator();
694
695 while (itr.hasNext()) {
696 remove((UserIdMapper)itr.next());
697 }
698 }
699
700 public int countByUserId(long userId) throws SystemException {
701 String finderClassName = UserIdMapper.class.getName();
702 String finderMethodName = "countByUserId";
703 String[] finderParams = new String[] { Long.class.getName() };
704 Object[] finderArgs = new Object[] { new Long(userId) };
705 Object result = FinderCache.getResult(finderClassName,
706 finderMethodName, finderParams, finderArgs, getSessionFactory());
707
708 if (result == null) {
709 Session session = null;
710
711 try {
712 session = openSession();
713
714 StringMaker query = new StringMaker();
715 query.append("SELECT COUNT(*) ");
716 query.append(
717 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
718 query.append("userId = ?");
719 query.append(" ");
720
721 Query q = session.createQuery(query.toString());
722 int queryPos = 0;
723 q.setLong(queryPos++, userId);
724
725 Long count = null;
726 Iterator itr = q.list().iterator();
727
728 if (itr.hasNext()) {
729 count = (Long)itr.next();
730 }
731
732 if (count == null) {
733 count = new Long(0);
734 }
735
736 FinderCache.putResult(finderClassName, finderMethodName,
737 finderParams, finderArgs, count);
738
739 return count.intValue();
740 }
741 catch (Exception e) {
742 throw HibernateUtil.processException(e);
743 }
744 finally {
745 closeSession(session);
746 }
747 }
748 else {
749 return ((Long)result).intValue();
750 }
751 }
752
753 public int countByU_T(long userId, String type) throws SystemException {
754 String finderClassName = UserIdMapper.class.getName();
755 String finderMethodName = "countByU_T";
756 String[] finderParams = new String[] {
757 Long.class.getName(), String.class.getName()
758 };
759 Object[] finderArgs = new Object[] { new Long(userId), type };
760 Object result = FinderCache.getResult(finderClassName,
761 finderMethodName, finderParams, finderArgs, getSessionFactory());
762
763 if (result == null) {
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 StringMaker query = new StringMaker();
770 query.append("SELECT COUNT(*) ");
771 query.append(
772 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
773 query.append("userId = ?");
774 query.append(" AND ");
775
776 if (type == null) {
777 query.append("type_ IS NULL");
778 }
779 else {
780 query.append("type_ = ?");
781 }
782
783 query.append(" ");
784
785 Query q = session.createQuery(query.toString());
786 int queryPos = 0;
787 q.setLong(queryPos++, userId);
788
789 if (type != null) {
790 q.setString(queryPos++, type);
791 }
792
793 Long count = null;
794 Iterator itr = q.list().iterator();
795
796 if (itr.hasNext()) {
797 count = (Long)itr.next();
798 }
799
800 if (count == null) {
801 count = new Long(0);
802 }
803
804 FinderCache.putResult(finderClassName, finderMethodName,
805 finderParams, finderArgs, count);
806
807 return count.intValue();
808 }
809 catch (Exception e) {
810 throw HibernateUtil.processException(e);
811 }
812 finally {
813 closeSession(session);
814 }
815 }
816 else {
817 return ((Long)result).intValue();
818 }
819 }
820
821 public int countByT_E(String type, String externalUserId)
822 throws SystemException {
823 String finderClassName = UserIdMapper.class.getName();
824 String finderMethodName = "countByT_E";
825 String[] finderParams = new String[] {
826 String.class.getName(), String.class.getName()
827 };
828 Object[] finderArgs = new Object[] { type, externalUserId };
829 Object result = FinderCache.getResult(finderClassName,
830 finderMethodName, finderParams, finderArgs, getSessionFactory());
831
832 if (result == null) {
833 Session session = null;
834
835 try {
836 session = openSession();
837
838 StringMaker query = new StringMaker();
839 query.append("SELECT COUNT(*) ");
840 query.append(
841 "FROM com.liferay.portal.model.UserIdMapper WHERE ");
842
843 if (type == null) {
844 query.append("type_ IS NULL");
845 }
846 else {
847 query.append("type_ = ?");
848 }
849
850 query.append(" AND ");
851
852 if (externalUserId == null) {
853 query.append("externalUserId IS NULL");
854 }
855 else {
856 query.append("externalUserId = ?");
857 }
858
859 query.append(" ");
860
861 Query q = session.createQuery(query.toString());
862 int queryPos = 0;
863
864 if (type != null) {
865 q.setString(queryPos++, type);
866 }
867
868 if (externalUserId != null) {
869 q.setString(queryPos++, externalUserId);
870 }
871
872 Long count = null;
873 Iterator itr = q.list().iterator();
874
875 if (itr.hasNext()) {
876 count = (Long)itr.next();
877 }
878
879 if (count == null) {
880 count = new Long(0);
881 }
882
883 FinderCache.putResult(finderClassName, finderMethodName,
884 finderParams, finderArgs, count);
885
886 return count.intValue();
887 }
888 catch (Exception e) {
889 throw HibernateUtil.processException(e);
890 }
891 finally {
892 closeSession(session);
893 }
894 }
895 else {
896 return ((Long)result).intValue();
897 }
898 }
899
900 public int countAll() throws SystemException {
901 String finderClassName = UserIdMapper.class.getName();
902 String finderMethodName = "countAll";
903 String[] finderParams = new String[] { };
904 Object[] finderArgs = new Object[] { };
905 Object result = FinderCache.getResult(finderClassName,
906 finderMethodName, finderParams, finderArgs, getSessionFactory());
907
908 if (result == null) {
909 Session session = null;
910
911 try {
912 session = openSession();
913
914 StringMaker query = new StringMaker();
915 query.append("SELECT COUNT(*) ");
916 query.append("FROM com.liferay.portal.model.UserIdMapper");
917
918 Query q = session.createQuery(query.toString());
919 Long count = null;
920 Iterator itr = q.list().iterator();
921
922 if (itr.hasNext()) {
923 count = (Long)itr.next();
924 }
925
926 if (count == null) {
927 count = new Long(0);
928 }
929
930 FinderCache.putResult(finderClassName, finderMethodName,
931 finderParams, finderArgs, count);
932
933 return count.intValue();
934 }
935 catch (Exception e) {
936 throw HibernateUtil.processException(e);
937 }
938 finally {
939 closeSession(session);
940 }
941 }
942 else {
943 return ((Long)result).intValue();
944 }
945 }
946
947 protected void initDao() {
948 }
949
950 private static Log _log = LogFactory.getLog(UserIdMapperPersistenceImpl.class);
951 }