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