1
22
23 package com.liferay.portlet.documentlibrary.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.GetterUtil;
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.kernel.util.StringUtil;
33 import com.liferay.portal.kernel.util.Validator;
34 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
35 import com.liferay.portal.model.ModelListener;
36 import com.liferay.portal.service.persistence.BasePersistence;
37 import com.liferay.portal.spring.hibernate.FinderCache;
38 import com.liferay.portal.spring.hibernate.HibernateUtil;
39 import com.liferay.portal.util.PropsUtil;
40
41 import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
42 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
43 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
44 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
45
46 import com.liferay.util.dao.hibernate.QueryUtil;
47
48 import org.apache.commons.logging.Log;
49 import org.apache.commons.logging.LogFactory;
50
51 import org.hibernate.Query;
52 import org.hibernate.Session;
53
54 import java.util.ArrayList;
55 import java.util.Collections;
56 import java.util.Iterator;
57 import java.util.List;
58
59
65 public class DLFileEntryPersistenceImpl extends BasePersistence
66 implements DLFileEntryPersistence {
67 public DLFileEntry create(long fileEntryId) {
68 DLFileEntry dlFileEntry = new DLFileEntryImpl();
69
70 dlFileEntry.setNew(true);
71 dlFileEntry.setPrimaryKey(fileEntryId);
72
73 String uuid = PortalUUIDUtil.generate();
74
75 dlFileEntry.setUuid(uuid);
76
77 return dlFileEntry;
78 }
79
80 public DLFileEntry remove(long fileEntryId)
81 throws NoSuchFileEntryException, SystemException {
82 Session session = null;
83
84 try {
85 session = openSession();
86
87 DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
88 new Long(fileEntryId));
89
90 if (dlFileEntry == null) {
91 if (_log.isWarnEnabled()) {
92 _log.warn("No DLFileEntry exists with the primary key " +
93 fileEntryId);
94 }
95
96 throw new NoSuchFileEntryException(
97 "No DLFileEntry exists with the primary key " +
98 fileEntryId);
99 }
100
101 return remove(dlFileEntry);
102 }
103 catch (NoSuchFileEntryException nsee) {
104 throw nsee;
105 }
106 catch (Exception e) {
107 throw HibernateUtil.processException(e);
108 }
109 finally {
110 closeSession(session);
111 }
112 }
113
114 public DLFileEntry remove(DLFileEntry dlFileEntry)
115 throws SystemException {
116 if (_listeners != null) {
117 for (ModelListener listener : _listeners) {
118 listener.onBeforeRemove(dlFileEntry);
119 }
120 }
121
122 dlFileEntry = removeImpl(dlFileEntry);
123
124 if (_listeners != null) {
125 for (ModelListener listener : _listeners) {
126 listener.onAfterRemove(dlFileEntry);
127 }
128 }
129
130 return dlFileEntry;
131 }
132
133 protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
134 throws SystemException {
135 Session session = null;
136
137 try {
138 session = openSession();
139
140 session.delete(dlFileEntry);
141
142 session.flush();
143
144 return dlFileEntry;
145 }
146 catch (Exception e) {
147 throw HibernateUtil.processException(e);
148 }
149 finally {
150 closeSession(session);
151
152 FinderCache.clearCache(DLFileEntry.class.getName());
153 }
154 }
155
156
159 public DLFileEntry update(DLFileEntry dlFileEntry)
160 throws SystemException {
161 if (_log.isWarnEnabled()) {
162 _log.warn(
163 "Using the deprecated update(DLFileEntry dlFileEntry) method. Use update(DLFileEntry dlFileEntry, boolean merge) instead.");
164 }
165
166 return update(dlFileEntry, false);
167 }
168
169
182 public DLFileEntry update(DLFileEntry dlFileEntry, boolean merge)
183 throws SystemException {
184 boolean isNew = dlFileEntry.isNew();
185
186 if (_listeners != null) {
187 for (ModelListener listener : _listeners) {
188 if (isNew) {
189 listener.onBeforeCreate(dlFileEntry);
190 }
191 else {
192 listener.onBeforeUpdate(dlFileEntry);
193 }
194 }
195 }
196
197 dlFileEntry = updateImpl(dlFileEntry, merge);
198
199 if (_listeners != null) {
200 for (ModelListener listener : _listeners) {
201 if (isNew) {
202 listener.onAfterCreate(dlFileEntry);
203 }
204 else {
205 listener.onAfterUpdate(dlFileEntry);
206 }
207 }
208 }
209
210 return dlFileEntry;
211 }
212
213 public DLFileEntry updateImpl(
214 com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
215 boolean merge) throws SystemException {
216 if (Validator.isNull(dlFileEntry.getUuid())) {
217 String uuid = PortalUUIDUtil.generate();
218
219 dlFileEntry.setUuid(uuid);
220 }
221
222 Session session = null;
223
224 try {
225 session = openSession();
226
227 if (merge) {
228 session.merge(dlFileEntry);
229 }
230 else {
231 if (dlFileEntry.isNew()) {
232 session.save(dlFileEntry);
233 }
234 }
235
236 session.flush();
237
238 dlFileEntry.setNew(false);
239
240 return dlFileEntry;
241 }
242 catch (Exception e) {
243 throw HibernateUtil.processException(e);
244 }
245 finally {
246 closeSession(session);
247
248 FinderCache.clearCache(DLFileEntry.class.getName());
249 }
250 }
251
252 public DLFileEntry findByPrimaryKey(long fileEntryId)
253 throws NoSuchFileEntryException, SystemException {
254 DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
255
256 if (dlFileEntry == null) {
257 if (_log.isWarnEnabled()) {
258 _log.warn("No DLFileEntry exists with the primary key " +
259 fileEntryId);
260 }
261
262 throw new NoSuchFileEntryException(
263 "No DLFileEntry exists with the primary key " + fileEntryId);
264 }
265
266 return dlFileEntry;
267 }
268
269 public DLFileEntry fetchByPrimaryKey(long fileEntryId)
270 throws SystemException {
271 Session session = null;
272
273 try {
274 session = openSession();
275
276 return (DLFileEntry)session.get(DLFileEntryImpl.class,
277 new Long(fileEntryId));
278 }
279 catch (Exception e) {
280 throw HibernateUtil.processException(e);
281 }
282 finally {
283 closeSession(session);
284 }
285 }
286
287 public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
288 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
289 String finderClassName = DLFileEntry.class.getName();
290 String finderMethodName = "findByUuid";
291 String[] finderParams = new String[] { String.class.getName() };
292 Object[] finderArgs = new Object[] { uuid };
293
294 Object result = null;
295
296 if (finderClassNameCacheEnabled) {
297 result = FinderCache.getResult(finderClassName, finderMethodName,
298 finderParams, finderArgs, getSessionFactory());
299 }
300
301 if (result == null) {
302 Session session = null;
303
304 try {
305 session = openSession();
306
307 StringMaker query = new StringMaker();
308
309 query.append(
310 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
311
312 if (uuid == null) {
313 query.append("uuid_ IS NULL");
314 }
315 else {
316 query.append("uuid_ = ?");
317 }
318
319 query.append(" ");
320
321 query.append("ORDER BY ");
322
323 query.append("folderId ASC, ");
324 query.append("name ASC");
325
326 Query q = session.createQuery(query.toString());
327
328 int queryPos = 0;
329
330 if (uuid != null) {
331 q.setString(queryPos++, uuid);
332 }
333
334 List<DLFileEntry> list = q.list();
335
336 FinderCache.putResult(finderClassNameCacheEnabled,
337 finderClassName, finderMethodName, finderParams,
338 finderArgs, list);
339
340 return list;
341 }
342 catch (Exception e) {
343 throw HibernateUtil.processException(e);
344 }
345 finally {
346 closeSession(session);
347 }
348 }
349 else {
350 return (List<DLFileEntry>)result;
351 }
352 }
353
354 public List<DLFileEntry> findByUuid(String uuid, int begin, int end)
355 throws SystemException {
356 return findByUuid(uuid, begin, end, null);
357 }
358
359 public List<DLFileEntry> findByUuid(String uuid, int begin, int end,
360 OrderByComparator obc) throws SystemException {
361 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
362 String finderClassName = DLFileEntry.class.getName();
363 String finderMethodName = "findByUuid";
364 String[] finderParams = new String[] {
365 String.class.getName(),
366
367 "java.lang.Integer", "java.lang.Integer",
368 "com.liferay.portal.kernel.util.OrderByComparator"
369 };
370 Object[] finderArgs = new Object[] {
371 uuid,
372
373 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
374 };
375
376 Object result = null;
377
378 if (finderClassNameCacheEnabled) {
379 result = FinderCache.getResult(finderClassName, finderMethodName,
380 finderParams, finderArgs, getSessionFactory());
381 }
382
383 if (result == null) {
384 Session session = null;
385
386 try {
387 session = openSession();
388
389 StringMaker query = new StringMaker();
390
391 query.append(
392 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
393
394 if (uuid == null) {
395 query.append("uuid_ IS NULL");
396 }
397 else {
398 query.append("uuid_ = ?");
399 }
400
401 query.append(" ");
402
403 if (obc != null) {
404 query.append("ORDER BY ");
405 query.append(obc.getOrderBy());
406 }
407
408 else {
409 query.append("ORDER BY ");
410
411 query.append("folderId ASC, ");
412 query.append("name ASC");
413 }
414
415 Query q = session.createQuery(query.toString());
416
417 int queryPos = 0;
418
419 if (uuid != null) {
420 q.setString(queryPos++, uuid);
421 }
422
423 List<DLFileEntry> list = (List<DLFileEntry>)QueryUtil.list(q,
424 getDialect(), begin, end);
425
426 FinderCache.putResult(finderClassNameCacheEnabled,
427 finderClassName, finderMethodName, finderParams,
428 finderArgs, list);
429
430 return list;
431 }
432 catch (Exception e) {
433 throw HibernateUtil.processException(e);
434 }
435 finally {
436 closeSession(session);
437 }
438 }
439 else {
440 return (List<DLFileEntry>)result;
441 }
442 }
443
444 public DLFileEntry findByUuid_First(String uuid, OrderByComparator obc)
445 throws NoSuchFileEntryException, SystemException {
446 List<DLFileEntry> list = findByUuid(uuid, 0, 1, obc);
447
448 if (list.size() == 0) {
449 StringMaker msg = new StringMaker();
450
451 msg.append("No DLFileEntry exists with the key {");
452
453 msg.append("uuid=" + uuid);
454
455 msg.append(StringPool.CLOSE_CURLY_BRACE);
456
457 throw new NoSuchFileEntryException(msg.toString());
458 }
459 else {
460 return list.get(0);
461 }
462 }
463
464 public DLFileEntry findByUuid_Last(String uuid, OrderByComparator obc)
465 throws NoSuchFileEntryException, SystemException {
466 int count = countByUuid(uuid);
467
468 List<DLFileEntry> list = findByUuid(uuid, count - 1, count, obc);
469
470 if (list.size() == 0) {
471 StringMaker msg = new StringMaker();
472
473 msg.append("No DLFileEntry exists with the key {");
474
475 msg.append("uuid=" + uuid);
476
477 msg.append(StringPool.CLOSE_CURLY_BRACE);
478
479 throw new NoSuchFileEntryException(msg.toString());
480 }
481 else {
482 return list.get(0);
483 }
484 }
485
486 public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
487 OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
488 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
489
490 int count = countByUuid(uuid);
491
492 Session session = null;
493
494 try {
495 session = openSession();
496
497 StringMaker query = new StringMaker();
498
499 query.append(
500 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
501
502 if (uuid == null) {
503 query.append("uuid_ IS NULL");
504 }
505 else {
506 query.append("uuid_ = ?");
507 }
508
509 query.append(" ");
510
511 if (obc != null) {
512 query.append("ORDER BY ");
513 query.append(obc.getOrderBy());
514 }
515
516 else {
517 query.append("ORDER BY ");
518
519 query.append("folderId ASC, ");
520 query.append("name ASC");
521 }
522
523 Query q = session.createQuery(query.toString());
524
525 int queryPos = 0;
526
527 if (uuid != null) {
528 q.setString(queryPos++, uuid);
529 }
530
531 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
532 dlFileEntry);
533
534 DLFileEntry[] array = new DLFileEntryImpl[3];
535
536 array[0] = (DLFileEntry)objArray[0];
537 array[1] = (DLFileEntry)objArray[1];
538 array[2] = (DLFileEntry)objArray[2];
539
540 return array;
541 }
542 catch (Exception e) {
543 throw HibernateUtil.processException(e);
544 }
545 finally {
546 closeSession(session);
547 }
548 }
549
550 public List<DLFileEntry> findByCompanyId(long companyId)
551 throws SystemException {
552 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
553 String finderClassName = DLFileEntry.class.getName();
554 String finderMethodName = "findByCompanyId";
555 String[] finderParams = new String[] { Long.class.getName() };
556 Object[] finderArgs = new Object[] { new Long(companyId) };
557
558 Object result = null;
559
560 if (finderClassNameCacheEnabled) {
561 result = FinderCache.getResult(finderClassName, finderMethodName,
562 finderParams, finderArgs, getSessionFactory());
563 }
564
565 if (result == null) {
566 Session session = null;
567
568 try {
569 session = openSession();
570
571 StringMaker query = new StringMaker();
572
573 query.append(
574 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
575
576 query.append("companyId = ?");
577
578 query.append(" ");
579
580 query.append("ORDER BY ");
581
582 query.append("folderId ASC, ");
583 query.append("name ASC");
584
585 Query q = session.createQuery(query.toString());
586
587 int queryPos = 0;
588
589 q.setLong(queryPos++, companyId);
590
591 List<DLFileEntry> list = q.list();
592
593 FinderCache.putResult(finderClassNameCacheEnabled,
594 finderClassName, finderMethodName, finderParams,
595 finderArgs, list);
596
597 return list;
598 }
599 catch (Exception e) {
600 throw HibernateUtil.processException(e);
601 }
602 finally {
603 closeSession(session);
604 }
605 }
606 else {
607 return (List<DLFileEntry>)result;
608 }
609 }
610
611 public List<DLFileEntry> findByCompanyId(long companyId, int begin, int end)
612 throws SystemException {
613 return findByCompanyId(companyId, begin, end, null);
614 }
615
616 public List<DLFileEntry> findByCompanyId(long companyId, int begin,
617 int end, OrderByComparator obc) throws SystemException {
618 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
619 String finderClassName = DLFileEntry.class.getName();
620 String finderMethodName = "findByCompanyId";
621 String[] finderParams = new String[] {
622 Long.class.getName(),
623
624 "java.lang.Integer", "java.lang.Integer",
625 "com.liferay.portal.kernel.util.OrderByComparator"
626 };
627 Object[] finderArgs = new Object[] {
628 new Long(companyId),
629
630 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
631 };
632
633 Object result = null;
634
635 if (finderClassNameCacheEnabled) {
636 result = FinderCache.getResult(finderClassName, finderMethodName,
637 finderParams, finderArgs, getSessionFactory());
638 }
639
640 if (result == null) {
641 Session session = null;
642
643 try {
644 session = openSession();
645
646 StringMaker query = new StringMaker();
647
648 query.append(
649 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
650
651 query.append("companyId = ?");
652
653 query.append(" ");
654
655 if (obc != null) {
656 query.append("ORDER BY ");
657 query.append(obc.getOrderBy());
658 }
659
660 else {
661 query.append("ORDER BY ");
662
663 query.append("folderId ASC, ");
664 query.append("name ASC");
665 }
666
667 Query q = session.createQuery(query.toString());
668
669 int queryPos = 0;
670
671 q.setLong(queryPos++, companyId);
672
673 List<DLFileEntry> list = (List<DLFileEntry>)QueryUtil.list(q,
674 getDialect(), begin, end);
675
676 FinderCache.putResult(finderClassNameCacheEnabled,
677 finderClassName, finderMethodName, finderParams,
678 finderArgs, list);
679
680 return list;
681 }
682 catch (Exception e) {
683 throw HibernateUtil.processException(e);
684 }
685 finally {
686 closeSession(session);
687 }
688 }
689 else {
690 return (List<DLFileEntry>)result;
691 }
692 }
693
694 public DLFileEntry findByCompanyId_First(long companyId,
695 OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
696 List<DLFileEntry> list = findByCompanyId(companyId, 0, 1, obc);
697
698 if (list.size() == 0) {
699 StringMaker msg = new StringMaker();
700
701 msg.append("No DLFileEntry exists with the key {");
702
703 msg.append("companyId=" + companyId);
704
705 msg.append(StringPool.CLOSE_CURLY_BRACE);
706
707 throw new NoSuchFileEntryException(msg.toString());
708 }
709 else {
710 return list.get(0);
711 }
712 }
713
714 public DLFileEntry findByCompanyId_Last(long companyId,
715 OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
716 int count = countByCompanyId(companyId);
717
718 List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
719 obc);
720
721 if (list.size() == 0) {
722 StringMaker msg = new StringMaker();
723
724 msg.append("No DLFileEntry exists with the key {");
725
726 msg.append("companyId=" + companyId);
727
728 msg.append(StringPool.CLOSE_CURLY_BRACE);
729
730 throw new NoSuchFileEntryException(msg.toString());
731 }
732 else {
733 return list.get(0);
734 }
735 }
736
737 public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
738 long companyId, OrderByComparator obc)
739 throws NoSuchFileEntryException, SystemException {
740 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
741
742 int count = countByCompanyId(companyId);
743
744 Session session = null;
745
746 try {
747 session = openSession();
748
749 StringMaker query = new StringMaker();
750
751 query.append(
752 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
753
754 query.append("companyId = ?");
755
756 query.append(" ");
757
758 if (obc != null) {
759 query.append("ORDER BY ");
760 query.append(obc.getOrderBy());
761 }
762
763 else {
764 query.append("ORDER BY ");
765
766 query.append("folderId ASC, ");
767 query.append("name ASC");
768 }
769
770 Query q = session.createQuery(query.toString());
771
772 int queryPos = 0;
773
774 q.setLong(queryPos++, companyId);
775
776 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
777 dlFileEntry);
778
779 DLFileEntry[] array = new DLFileEntryImpl[3];
780
781 array[0] = (DLFileEntry)objArray[0];
782 array[1] = (DLFileEntry)objArray[1];
783 array[2] = (DLFileEntry)objArray[2];
784
785 return array;
786 }
787 catch (Exception e) {
788 throw HibernateUtil.processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793 }
794
795 public List<DLFileEntry> findByFolderId(long folderId)
796 throws SystemException {
797 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
798 String finderClassName = DLFileEntry.class.getName();
799 String finderMethodName = "findByFolderId";
800 String[] finderParams = new String[] { Long.class.getName() };
801 Object[] finderArgs = new Object[] { new Long(folderId) };
802
803 Object result = null;
804
805 if (finderClassNameCacheEnabled) {
806 result = FinderCache.getResult(finderClassName, finderMethodName,
807 finderParams, finderArgs, getSessionFactory());
808 }
809
810 if (result == null) {
811 Session session = null;
812
813 try {
814 session = openSession();
815
816 StringMaker query = new StringMaker();
817
818 query.append(
819 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
820
821 query.append("folderId = ?");
822
823 query.append(" ");
824
825 query.append("ORDER BY ");
826
827 query.append("folderId ASC, ");
828 query.append("name ASC");
829
830 Query q = session.createQuery(query.toString());
831
832 int queryPos = 0;
833
834 q.setLong(queryPos++, folderId);
835
836 List<DLFileEntry> list = q.list();
837
838 FinderCache.putResult(finderClassNameCacheEnabled,
839 finderClassName, finderMethodName, finderParams,
840 finderArgs, list);
841
842 return list;
843 }
844 catch (Exception e) {
845 throw HibernateUtil.processException(e);
846 }
847 finally {
848 closeSession(session);
849 }
850 }
851 else {
852 return (List<DLFileEntry>)result;
853 }
854 }
855
856 public List<DLFileEntry> findByFolderId(long folderId, int begin, int end)
857 throws SystemException {
858 return findByFolderId(folderId, begin, end, null);
859 }
860
861 public List<DLFileEntry> findByFolderId(long folderId, int begin, int end,
862 OrderByComparator obc) throws SystemException {
863 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
864 String finderClassName = DLFileEntry.class.getName();
865 String finderMethodName = "findByFolderId";
866 String[] finderParams = new String[] {
867 Long.class.getName(),
868
869 "java.lang.Integer", "java.lang.Integer",
870 "com.liferay.portal.kernel.util.OrderByComparator"
871 };
872 Object[] finderArgs = new Object[] {
873 new Long(folderId),
874
875 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
876 };
877
878 Object result = null;
879
880 if (finderClassNameCacheEnabled) {
881 result = FinderCache.getResult(finderClassName, finderMethodName,
882 finderParams, finderArgs, getSessionFactory());
883 }
884
885 if (result == null) {
886 Session session = null;
887
888 try {
889 session = openSession();
890
891 StringMaker query = new StringMaker();
892
893 query.append(
894 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
895
896 query.append("folderId = ?");
897
898 query.append(" ");
899
900 if (obc != null) {
901 query.append("ORDER BY ");
902 query.append(obc.getOrderBy());
903 }
904
905 else {
906 query.append("ORDER BY ");
907
908 query.append("folderId ASC, ");
909 query.append("name ASC");
910 }
911
912 Query q = session.createQuery(query.toString());
913
914 int queryPos = 0;
915
916 q.setLong(queryPos++, folderId);
917
918 List<DLFileEntry> list = (List<DLFileEntry>)QueryUtil.list(q,
919 getDialect(), begin, end);
920
921 FinderCache.putResult(finderClassNameCacheEnabled,
922 finderClassName, finderMethodName, finderParams,
923 finderArgs, list);
924
925 return list;
926 }
927 catch (Exception e) {
928 throw HibernateUtil.processException(e);
929 }
930 finally {
931 closeSession(session);
932 }
933 }
934 else {
935 return (List<DLFileEntry>)result;
936 }
937 }
938
939 public DLFileEntry findByFolderId_First(long folderId, OrderByComparator obc)
940 throws NoSuchFileEntryException, SystemException {
941 List<DLFileEntry> list = findByFolderId(folderId, 0, 1, obc);
942
943 if (list.size() == 0) {
944 StringMaker msg = new StringMaker();
945
946 msg.append("No DLFileEntry exists with the key {");
947
948 msg.append("folderId=" + folderId);
949
950 msg.append(StringPool.CLOSE_CURLY_BRACE);
951
952 throw new NoSuchFileEntryException(msg.toString());
953 }
954 else {
955 return list.get(0);
956 }
957 }
958
959 public DLFileEntry findByFolderId_Last(long folderId, OrderByComparator obc)
960 throws NoSuchFileEntryException, SystemException {
961 int count = countByFolderId(folderId);
962
963 List<DLFileEntry> list = findByFolderId(folderId, count - 1, count, obc);
964
965 if (list.size() == 0) {
966 StringMaker msg = new StringMaker();
967
968 msg.append("No DLFileEntry exists with the key {");
969
970 msg.append("folderId=" + folderId);
971
972 msg.append(StringPool.CLOSE_CURLY_BRACE);
973
974 throw new NoSuchFileEntryException(msg.toString());
975 }
976 else {
977 return list.get(0);
978 }
979 }
980
981 public DLFileEntry[] findByFolderId_PrevAndNext(long fileEntryId,
982 long folderId, OrderByComparator obc)
983 throws NoSuchFileEntryException, SystemException {
984 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
985
986 int count = countByFolderId(folderId);
987
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 StringMaker query = new StringMaker();
994
995 query.append(
996 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
997
998 query.append("folderId = ?");
999
1000 query.append(" ");
1001
1002 if (obc != null) {
1003 query.append("ORDER BY ");
1004 query.append(obc.getOrderBy());
1005 }
1006
1007 else {
1008 query.append("ORDER BY ");
1009
1010 query.append("folderId ASC, ");
1011 query.append("name ASC");
1012 }
1013
1014 Query q = session.createQuery(query.toString());
1015
1016 int queryPos = 0;
1017
1018 q.setLong(queryPos++, folderId);
1019
1020 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1021 dlFileEntry);
1022
1023 DLFileEntry[] array = new DLFileEntryImpl[3];
1024
1025 array[0] = (DLFileEntry)objArray[0];
1026 array[1] = (DLFileEntry)objArray[1];
1027 array[2] = (DLFileEntry)objArray[2];
1028
1029 return array;
1030 }
1031 catch (Exception e) {
1032 throw HibernateUtil.processException(e);
1033 }
1034 finally {
1035 closeSession(session);
1036 }
1037 }
1038
1039 public DLFileEntry findByF_N(long folderId, String name)
1040 throws NoSuchFileEntryException, SystemException {
1041 DLFileEntry dlFileEntry = fetchByF_N(folderId, name);
1042
1043 if (dlFileEntry == null) {
1044 StringMaker msg = new StringMaker();
1045
1046 msg.append("No DLFileEntry exists with the key {");
1047
1048 msg.append("folderId=" + folderId);
1049
1050 msg.append(", ");
1051 msg.append("name=" + name);
1052
1053 msg.append(StringPool.CLOSE_CURLY_BRACE);
1054
1055 if (_log.isWarnEnabled()) {
1056 _log.warn(msg.toString());
1057 }
1058
1059 throw new NoSuchFileEntryException(msg.toString());
1060 }
1061
1062 return dlFileEntry;
1063 }
1064
1065 public DLFileEntry fetchByF_N(long folderId, String name)
1066 throws SystemException {
1067 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1068 String finderClassName = DLFileEntry.class.getName();
1069 String finderMethodName = "fetchByF_N";
1070 String[] finderParams = new String[] {
1071 Long.class.getName(), String.class.getName()
1072 };
1073 Object[] finderArgs = new Object[] { new Long(folderId), name };
1074
1075 Object result = null;
1076
1077 if (finderClassNameCacheEnabled) {
1078 result = FinderCache.getResult(finderClassName, finderMethodName,
1079 finderParams, finderArgs, getSessionFactory());
1080 }
1081
1082 if (result == null) {
1083 Session session = null;
1084
1085 try {
1086 session = openSession();
1087
1088 StringMaker query = new StringMaker();
1089
1090 query.append(
1091 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1092
1093 query.append("folderId = ?");
1094
1095 query.append(" AND ");
1096
1097 if (name == null) {
1098 query.append("name IS NULL");
1099 }
1100 else {
1101 query.append("name = ?");
1102 }
1103
1104 query.append(" ");
1105
1106 query.append("ORDER BY ");
1107
1108 query.append("folderId ASC, ");
1109 query.append("name ASC");
1110
1111 Query q = session.createQuery(query.toString());
1112
1113 int queryPos = 0;
1114
1115 q.setLong(queryPos++, folderId);
1116
1117 if (name != null) {
1118 q.setString(queryPos++, name);
1119 }
1120
1121 List<DLFileEntry> list = q.list();
1122
1123 FinderCache.putResult(finderClassNameCacheEnabled,
1124 finderClassName, finderMethodName, finderParams,
1125 finderArgs, list);
1126
1127 if (list.size() == 0) {
1128 return null;
1129 }
1130 else {
1131 return list.get(0);
1132 }
1133 }
1134 catch (Exception e) {
1135 throw HibernateUtil.processException(e);
1136 }
1137 finally {
1138 closeSession(session);
1139 }
1140 }
1141 else {
1142 List<DLFileEntry> list = (List<DLFileEntry>)result;
1143
1144 if (list.size() == 0) {
1145 return null;
1146 }
1147 else {
1148 return list.get(0);
1149 }
1150 }
1151 }
1152
1153 public List<DLFileEntry> findByF_T(long folderId, String title)
1154 throws SystemException {
1155 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1156 String finderClassName = DLFileEntry.class.getName();
1157 String finderMethodName = "findByF_T";
1158 String[] finderParams = new String[] {
1159 Long.class.getName(), String.class.getName()
1160 };
1161 Object[] finderArgs = new Object[] { new Long(folderId), title };
1162
1163 Object result = null;
1164
1165 if (finderClassNameCacheEnabled) {
1166 result = FinderCache.getResult(finderClassName, finderMethodName,
1167 finderParams, finderArgs, getSessionFactory());
1168 }
1169
1170 if (result == null) {
1171 Session session = null;
1172
1173 try {
1174 session = openSession();
1175
1176 StringMaker query = new StringMaker();
1177
1178 query.append(
1179 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1180
1181 query.append("folderId = ?");
1182
1183 query.append(" AND ");
1184
1185 if (title == null) {
1186 query.append("title IS NULL");
1187 }
1188 else {
1189 query.append("title = ?");
1190 }
1191
1192 query.append(" ");
1193
1194 query.append("ORDER BY ");
1195
1196 query.append("folderId ASC, ");
1197 query.append("name ASC");
1198
1199 Query q = session.createQuery(query.toString());
1200
1201 int queryPos = 0;
1202
1203 q.setLong(queryPos++, folderId);
1204
1205 if (title != null) {
1206 q.setString(queryPos++, title);
1207 }
1208
1209 List<DLFileEntry> list = q.list();
1210
1211 FinderCache.putResult(finderClassNameCacheEnabled,
1212 finderClassName, finderMethodName, finderParams,
1213 finderArgs, list);
1214
1215 return list;
1216 }
1217 catch (Exception e) {
1218 throw HibernateUtil.processException(e);
1219 }
1220 finally {
1221 closeSession(session);
1222 }
1223 }
1224 else {
1225 return (List<DLFileEntry>)result;
1226 }
1227 }
1228
1229 public List<DLFileEntry> findByF_T(long folderId, String title, int begin,
1230 int end) throws SystemException {
1231 return findByF_T(folderId, title, begin, end, null);
1232 }
1233
1234 public List<DLFileEntry> findByF_T(long folderId, String title, int begin,
1235 int end, OrderByComparator obc) throws SystemException {
1236 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1237 String finderClassName = DLFileEntry.class.getName();
1238 String finderMethodName = "findByF_T";
1239 String[] finderParams = new String[] {
1240 Long.class.getName(), String.class.getName(),
1241
1242 "java.lang.Integer", "java.lang.Integer",
1243 "com.liferay.portal.kernel.util.OrderByComparator"
1244 };
1245 Object[] finderArgs = new Object[] {
1246 new Long(folderId),
1247
1248 title,
1249
1250 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1251 };
1252
1253 Object result = null;
1254
1255 if (finderClassNameCacheEnabled) {
1256 result = FinderCache.getResult(finderClassName, finderMethodName,
1257 finderParams, finderArgs, getSessionFactory());
1258 }
1259
1260 if (result == null) {
1261 Session session = null;
1262
1263 try {
1264 session = openSession();
1265
1266 StringMaker query = new StringMaker();
1267
1268 query.append(
1269 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1270
1271 query.append("folderId = ?");
1272
1273 query.append(" AND ");
1274
1275 if (title == null) {
1276 query.append("title IS NULL");
1277 }
1278 else {
1279 query.append("title = ?");
1280 }
1281
1282 query.append(" ");
1283
1284 if (obc != null) {
1285 query.append("ORDER BY ");
1286 query.append(obc.getOrderBy());
1287 }
1288
1289 else {
1290 query.append("ORDER BY ");
1291
1292 query.append("folderId ASC, ");
1293 query.append("name ASC");
1294 }
1295
1296 Query q = session.createQuery(query.toString());
1297
1298 int queryPos = 0;
1299
1300 q.setLong(queryPos++, folderId);
1301
1302 if (title != null) {
1303 q.setString(queryPos++, title);
1304 }
1305
1306 List<DLFileEntry> list = (List<DLFileEntry>)QueryUtil.list(q,
1307 getDialect(), begin, end);
1308
1309 FinderCache.putResult(finderClassNameCacheEnabled,
1310 finderClassName, finderMethodName, finderParams,
1311 finderArgs, list);
1312
1313 return list;
1314 }
1315 catch (Exception e) {
1316 throw HibernateUtil.processException(e);
1317 }
1318 finally {
1319 closeSession(session);
1320 }
1321 }
1322 else {
1323 return (List<DLFileEntry>)result;
1324 }
1325 }
1326
1327 public DLFileEntry findByF_T_First(long folderId, String title,
1328 OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1329 List<DLFileEntry> list = findByF_T(folderId, title, 0, 1, obc);
1330
1331 if (list.size() == 0) {
1332 StringMaker msg = new StringMaker();
1333
1334 msg.append("No DLFileEntry exists with the key {");
1335
1336 msg.append("folderId=" + folderId);
1337
1338 msg.append(", ");
1339 msg.append("title=" + title);
1340
1341 msg.append(StringPool.CLOSE_CURLY_BRACE);
1342
1343 throw new NoSuchFileEntryException(msg.toString());
1344 }
1345 else {
1346 return list.get(0);
1347 }
1348 }
1349
1350 public DLFileEntry findByF_T_Last(long folderId, String title,
1351 OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1352 int count = countByF_T(folderId, title);
1353
1354 List<DLFileEntry> list = findByF_T(folderId, title, count - 1, count,
1355 obc);
1356
1357 if (list.size() == 0) {
1358 StringMaker msg = new StringMaker();
1359
1360 msg.append("No DLFileEntry exists with the key {");
1361
1362 msg.append("folderId=" + folderId);
1363
1364 msg.append(", ");
1365 msg.append("title=" + title);
1366
1367 msg.append(StringPool.CLOSE_CURLY_BRACE);
1368
1369 throw new NoSuchFileEntryException(msg.toString());
1370 }
1371 else {
1372 return list.get(0);
1373 }
1374 }
1375
1376 public DLFileEntry[] findByF_T_PrevAndNext(long fileEntryId, long folderId,
1377 String title, OrderByComparator obc)
1378 throws NoSuchFileEntryException, SystemException {
1379 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1380
1381 int count = countByF_T(folderId, title);
1382
1383 Session session = null;
1384
1385 try {
1386 session = openSession();
1387
1388 StringMaker query = new StringMaker();
1389
1390 query.append(
1391 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1392
1393 query.append("folderId = ?");
1394
1395 query.append(" AND ");
1396
1397 if (title == null) {
1398 query.append("title IS NULL");
1399 }
1400 else {
1401 query.append("title = ?");
1402 }
1403
1404 query.append(" ");
1405
1406 if (obc != null) {
1407 query.append("ORDER BY ");
1408 query.append(obc.getOrderBy());
1409 }
1410
1411 else {
1412 query.append("ORDER BY ");
1413
1414 query.append("folderId ASC, ");
1415 query.append("name ASC");
1416 }
1417
1418 Query q = session.createQuery(query.toString());
1419
1420 int queryPos = 0;
1421
1422 q.setLong(queryPos++, folderId);
1423
1424 if (title != null) {
1425 q.setString(queryPos++, title);
1426 }
1427
1428 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1429 dlFileEntry);
1430
1431 DLFileEntry[] array = new DLFileEntryImpl[3];
1432
1433 array[0] = (DLFileEntry)objArray[0];
1434 array[1] = (DLFileEntry)objArray[1];
1435 array[2] = (DLFileEntry)objArray[2];
1436
1437 return array;
1438 }
1439 catch (Exception e) {
1440 throw HibernateUtil.processException(e);
1441 }
1442 finally {
1443 closeSession(session);
1444 }
1445 }
1446
1447 public List<DLFileEntry> findWithDynamicQuery(
1448 DynamicQueryInitializer queryInitializer) throws SystemException {
1449 Session session = null;
1450
1451 try {
1452 session = openSession();
1453
1454 DynamicQuery query = queryInitializer.initialize(session);
1455
1456 return query.list();
1457 }
1458 catch (Exception e) {
1459 throw HibernateUtil.processException(e);
1460 }
1461 finally {
1462 closeSession(session);
1463 }
1464 }
1465
1466 public List<DLFileEntry> findWithDynamicQuery(
1467 DynamicQueryInitializer queryInitializer, int begin, int end)
1468 throws SystemException {
1469 Session session = null;
1470
1471 try {
1472 session = openSession();
1473
1474 DynamicQuery query = queryInitializer.initialize(session);
1475
1476 query.setLimit(begin, end);
1477
1478 return query.list();
1479 }
1480 catch (Exception e) {
1481 throw HibernateUtil.processException(e);
1482 }
1483 finally {
1484 closeSession(session);
1485 }
1486 }
1487
1488 public List<DLFileEntry> findAll() throws SystemException {
1489 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1490 }
1491
1492 public List<DLFileEntry> findAll(int begin, int end)
1493 throws SystemException {
1494 return findAll(begin, end, null);
1495 }
1496
1497 public List<DLFileEntry> findAll(int begin, int end, OrderByComparator obc)
1498 throws SystemException {
1499 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1500 String finderClassName = DLFileEntry.class.getName();
1501 String finderMethodName = "findAll";
1502 String[] finderParams = new String[] {
1503 "java.lang.Integer", "java.lang.Integer",
1504 "com.liferay.portal.kernel.util.OrderByComparator"
1505 };
1506 Object[] finderArgs = new Object[] {
1507 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1508 };
1509
1510 Object result = null;
1511
1512 if (finderClassNameCacheEnabled) {
1513 result = FinderCache.getResult(finderClassName, finderMethodName,
1514 finderParams, finderArgs, getSessionFactory());
1515 }
1516
1517 if (result == null) {
1518 Session session = null;
1519
1520 try {
1521 session = openSession();
1522
1523 StringMaker query = new StringMaker();
1524
1525 query.append(
1526 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry ");
1527
1528 if (obc != null) {
1529 query.append("ORDER BY ");
1530 query.append(obc.getOrderBy());
1531 }
1532
1533 else {
1534 query.append("ORDER BY ");
1535
1536 query.append("folderId ASC, ");
1537 query.append("name ASC");
1538 }
1539
1540 Query q = session.createQuery(query.toString());
1541
1542 List<DLFileEntry> list = (List<DLFileEntry>)QueryUtil.list(q,
1543 getDialect(), begin, end);
1544
1545 if (obc == null) {
1546 Collections.sort(list);
1547 }
1548
1549 FinderCache.putResult(finderClassNameCacheEnabled,
1550 finderClassName, finderMethodName, finderParams,
1551 finderArgs, list);
1552
1553 return list;
1554 }
1555 catch (Exception e) {
1556 throw HibernateUtil.processException(e);
1557 }
1558 finally {
1559 closeSession(session);
1560 }
1561 }
1562 else {
1563 return (List<DLFileEntry>)result;
1564 }
1565 }
1566
1567 public void removeByUuid(String uuid) throws SystemException {
1568 for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
1569 remove(dlFileEntry);
1570 }
1571 }
1572
1573 public void removeByCompanyId(long companyId) throws SystemException {
1574 for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
1575 remove(dlFileEntry);
1576 }
1577 }
1578
1579 public void removeByFolderId(long folderId) throws SystemException {
1580 for (DLFileEntry dlFileEntry : findByFolderId(folderId)) {
1581 remove(dlFileEntry);
1582 }
1583 }
1584
1585 public void removeByF_N(long folderId, String name)
1586 throws NoSuchFileEntryException, SystemException {
1587 DLFileEntry dlFileEntry = findByF_N(folderId, name);
1588
1589 remove(dlFileEntry);
1590 }
1591
1592 public void removeByF_T(long folderId, String title)
1593 throws SystemException {
1594 for (DLFileEntry dlFileEntry : findByF_T(folderId, title)) {
1595 remove(dlFileEntry);
1596 }
1597 }
1598
1599 public void removeAll() throws SystemException {
1600 for (DLFileEntry dlFileEntry : findAll()) {
1601 remove(dlFileEntry);
1602 }
1603 }
1604
1605 public int countByUuid(String uuid) throws SystemException {
1606 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1607 String finderClassName = DLFileEntry.class.getName();
1608 String finderMethodName = "countByUuid";
1609 String[] finderParams = new String[] { String.class.getName() };
1610 Object[] finderArgs = new Object[] { uuid };
1611
1612 Object result = null;
1613
1614 if (finderClassNameCacheEnabled) {
1615 result = FinderCache.getResult(finderClassName, finderMethodName,
1616 finderParams, finderArgs, getSessionFactory());
1617 }
1618
1619 if (result == null) {
1620 Session session = null;
1621
1622 try {
1623 session = openSession();
1624
1625 StringMaker query = new StringMaker();
1626
1627 query.append("SELECT COUNT(*) ");
1628 query.append(
1629 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1630
1631 if (uuid == null) {
1632 query.append("uuid_ IS NULL");
1633 }
1634 else {
1635 query.append("uuid_ = ?");
1636 }
1637
1638 query.append(" ");
1639
1640 Query q = session.createQuery(query.toString());
1641
1642 int queryPos = 0;
1643
1644 if (uuid != null) {
1645 q.setString(queryPos++, uuid);
1646 }
1647
1648 Long count = null;
1649
1650 Iterator<Long> itr = q.list().iterator();
1651
1652 if (itr.hasNext()) {
1653 count = itr.next();
1654 }
1655
1656 if (count == null) {
1657 count = new Long(0);
1658 }
1659
1660 FinderCache.putResult(finderClassNameCacheEnabled,
1661 finderClassName, finderMethodName, finderParams,
1662 finderArgs, count);
1663
1664 return count.intValue();
1665 }
1666 catch (Exception e) {
1667 throw HibernateUtil.processException(e);
1668 }
1669 finally {
1670 closeSession(session);
1671 }
1672 }
1673 else {
1674 return ((Long)result).intValue();
1675 }
1676 }
1677
1678 public int countByCompanyId(long companyId) throws SystemException {
1679 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1680 String finderClassName = DLFileEntry.class.getName();
1681 String finderMethodName = "countByCompanyId";
1682 String[] finderParams = new String[] { Long.class.getName() };
1683 Object[] finderArgs = new Object[] { new Long(companyId) };
1684
1685 Object result = null;
1686
1687 if (finderClassNameCacheEnabled) {
1688 result = FinderCache.getResult(finderClassName, finderMethodName,
1689 finderParams, finderArgs, getSessionFactory());
1690 }
1691
1692 if (result == null) {
1693 Session session = null;
1694
1695 try {
1696 session = openSession();
1697
1698 StringMaker query = new StringMaker();
1699
1700 query.append("SELECT COUNT(*) ");
1701 query.append(
1702 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1703
1704 query.append("companyId = ?");
1705
1706 query.append(" ");
1707
1708 Query q = session.createQuery(query.toString());
1709
1710 int queryPos = 0;
1711
1712 q.setLong(queryPos++, companyId);
1713
1714 Long count = null;
1715
1716 Iterator<Long> itr = q.list().iterator();
1717
1718 if (itr.hasNext()) {
1719 count = itr.next();
1720 }
1721
1722 if (count == null) {
1723 count = new Long(0);
1724 }
1725
1726 FinderCache.putResult(finderClassNameCacheEnabled,
1727 finderClassName, finderMethodName, finderParams,
1728 finderArgs, count);
1729
1730 return count.intValue();
1731 }
1732 catch (Exception e) {
1733 throw HibernateUtil.processException(e);
1734 }
1735 finally {
1736 closeSession(session);
1737 }
1738 }
1739 else {
1740 return ((Long)result).intValue();
1741 }
1742 }
1743
1744 public int countByFolderId(long folderId) throws SystemException {
1745 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1746 String finderClassName = DLFileEntry.class.getName();
1747 String finderMethodName = "countByFolderId";
1748 String[] finderParams = new String[] { Long.class.getName() };
1749 Object[] finderArgs = new Object[] { new Long(folderId) };
1750
1751 Object result = null;
1752
1753 if (finderClassNameCacheEnabled) {
1754 result = FinderCache.getResult(finderClassName, finderMethodName,
1755 finderParams, finderArgs, getSessionFactory());
1756 }
1757
1758 if (result == null) {
1759 Session session = null;
1760
1761 try {
1762 session = openSession();
1763
1764 StringMaker query = new StringMaker();
1765
1766 query.append("SELECT COUNT(*) ");
1767 query.append(
1768 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1769
1770 query.append("folderId = ?");
1771
1772 query.append(" ");
1773
1774 Query q = session.createQuery(query.toString());
1775
1776 int queryPos = 0;
1777
1778 q.setLong(queryPos++, folderId);
1779
1780 Long count = null;
1781
1782 Iterator<Long> itr = q.list().iterator();
1783
1784 if (itr.hasNext()) {
1785 count = itr.next();
1786 }
1787
1788 if (count == null) {
1789 count = new Long(0);
1790 }
1791
1792 FinderCache.putResult(finderClassNameCacheEnabled,
1793 finderClassName, finderMethodName, finderParams,
1794 finderArgs, count);
1795
1796 return count.intValue();
1797 }
1798 catch (Exception e) {
1799 throw HibernateUtil.processException(e);
1800 }
1801 finally {
1802 closeSession(session);
1803 }
1804 }
1805 else {
1806 return ((Long)result).intValue();
1807 }
1808 }
1809
1810 public int countByF_N(long folderId, String name) throws SystemException {
1811 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1812 String finderClassName = DLFileEntry.class.getName();
1813 String finderMethodName = "countByF_N";
1814 String[] finderParams = new String[] {
1815 Long.class.getName(), String.class.getName()
1816 };
1817 Object[] finderArgs = new Object[] { new Long(folderId), name };
1818
1819 Object result = null;
1820
1821 if (finderClassNameCacheEnabled) {
1822 result = FinderCache.getResult(finderClassName, finderMethodName,
1823 finderParams, finderArgs, getSessionFactory());
1824 }
1825
1826 if (result == null) {
1827 Session session = null;
1828
1829 try {
1830 session = openSession();
1831
1832 StringMaker query = new StringMaker();
1833
1834 query.append("SELECT COUNT(*) ");
1835 query.append(
1836 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1837
1838 query.append("folderId = ?");
1839
1840 query.append(" AND ");
1841
1842 if (name == null) {
1843 query.append("name IS NULL");
1844 }
1845 else {
1846 query.append("name = ?");
1847 }
1848
1849 query.append(" ");
1850
1851 Query q = session.createQuery(query.toString());
1852
1853 int queryPos = 0;
1854
1855 q.setLong(queryPos++, folderId);
1856
1857 if (name != null) {
1858 q.setString(queryPos++, name);
1859 }
1860
1861 Long count = null;
1862
1863 Iterator<Long> itr = q.list().iterator();
1864
1865 if (itr.hasNext()) {
1866 count = itr.next();
1867 }
1868
1869 if (count == null) {
1870 count = new Long(0);
1871 }
1872
1873 FinderCache.putResult(finderClassNameCacheEnabled,
1874 finderClassName, finderMethodName, finderParams,
1875 finderArgs, count);
1876
1877 return count.intValue();
1878 }
1879 catch (Exception e) {
1880 throw HibernateUtil.processException(e);
1881 }
1882 finally {
1883 closeSession(session);
1884 }
1885 }
1886 else {
1887 return ((Long)result).intValue();
1888 }
1889 }
1890
1891 public int countByF_T(long folderId, String title)
1892 throws SystemException {
1893 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1894 String finderClassName = DLFileEntry.class.getName();
1895 String finderMethodName = "countByF_T";
1896 String[] finderParams = new String[] {
1897 Long.class.getName(), String.class.getName()
1898 };
1899 Object[] finderArgs = new Object[] { new Long(folderId), title };
1900
1901 Object result = null;
1902
1903 if (finderClassNameCacheEnabled) {
1904 result = FinderCache.getResult(finderClassName, finderMethodName,
1905 finderParams, finderArgs, getSessionFactory());
1906 }
1907
1908 if (result == null) {
1909 Session session = null;
1910
1911 try {
1912 session = openSession();
1913
1914 StringMaker query = new StringMaker();
1915
1916 query.append("SELECT COUNT(*) ");
1917 query.append(
1918 "FROM com.liferay.portlet.documentlibrary.model.DLFileEntry WHERE ");
1919
1920 query.append("folderId = ?");
1921
1922 query.append(" AND ");
1923
1924 if (title == null) {
1925 query.append("title IS NULL");
1926 }
1927 else {
1928 query.append("title = ?");
1929 }
1930
1931 query.append(" ");
1932
1933 Query q = session.createQuery(query.toString());
1934
1935 int queryPos = 0;
1936
1937 q.setLong(queryPos++, folderId);
1938
1939 if (title != null) {
1940 q.setString(queryPos++, title);
1941 }
1942
1943 Long count = null;
1944
1945 Iterator<Long> itr = q.list().iterator();
1946
1947 if (itr.hasNext()) {
1948 count = itr.next();
1949 }
1950
1951 if (count == null) {
1952 count = new Long(0);
1953 }
1954
1955 FinderCache.putResult(finderClassNameCacheEnabled,
1956 finderClassName, finderMethodName, finderParams,
1957 finderArgs, count);
1958
1959 return count.intValue();
1960 }
1961 catch (Exception e) {
1962 throw HibernateUtil.processException(e);
1963 }
1964 finally {
1965 closeSession(session);
1966 }
1967 }
1968 else {
1969 return ((Long)result).intValue();
1970 }
1971 }
1972
1973 public int countAll() throws SystemException {
1974 boolean finderClassNameCacheEnabled = DLFileEntryModelImpl.CACHE_ENABLED;
1975 String finderClassName = DLFileEntry.class.getName();
1976 String finderMethodName = "countAll";
1977 String[] finderParams = new String[] { };
1978 Object[] finderArgs = new Object[] { };
1979
1980 Object result = null;
1981
1982 if (finderClassNameCacheEnabled) {
1983 result = FinderCache.getResult(finderClassName, finderMethodName,
1984 finderParams, finderArgs, getSessionFactory());
1985 }
1986
1987 if (result == null) {
1988 Session session = null;
1989
1990 try {
1991 session = openSession();
1992
1993 Query q = session.createQuery(
1994 "SELECT COUNT(*) FROM com.liferay.portlet.documentlibrary.model.DLFileEntry");
1995
1996 Long count = null;
1997
1998 Iterator<Long> itr = q.list().iterator();
1999
2000 if (itr.hasNext()) {
2001 count = itr.next();
2002 }
2003
2004 if (count == null) {
2005 count = new Long(0);
2006 }
2007
2008 FinderCache.putResult(finderClassNameCacheEnabled,
2009 finderClassName, finderMethodName, finderParams,
2010 finderArgs, count);
2011
2012 return count.intValue();
2013 }
2014 catch (Exception e) {
2015 throw HibernateUtil.processException(e);
2016 }
2017 finally {
2018 closeSession(session);
2019 }
2020 }
2021 else {
2022 return ((Long)result).intValue();
2023 }
2024 }
2025
2026 protected void initDao() {
2027 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2028 PropsUtil.get(
2029 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
2030
2031 if (listenerClassNames.length > 0) {
2032 try {
2033 List<ModelListener> listeners = new ArrayList<ModelListener>();
2034
2035 for (String listenerClassName : listenerClassNames) {
2036 listeners.add((ModelListener)Class.forName(
2037 listenerClassName).newInstance());
2038 }
2039
2040 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2041 }
2042 catch (Exception e) {
2043 _log.error(e);
2044 }
2045 }
2046 }
2047
2048 private static Log _log = LogFactory.getLog(DLFileEntryPersistenceImpl.class);
2049 private ModelListener[] _listeners;
2050}