001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchResourceBlockException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.model.ResourceBlock;
041 import com.liferay.portal.model.impl.ResourceBlockImpl;
042 import com.liferay.portal.model.impl.ResourceBlockModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class ResourceBlockPersistenceImpl extends BasePersistenceImpl<ResourceBlock>
064 implements ResourceBlockPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = ResourceBlockImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
076 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
077 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
078 "findByC_N",
079 new String[] {
080 Long.class.getName(), String.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
086 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
087 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
088 "findByC_N",
089 new String[] { Long.class.getName(), String.class.getName() },
090 ResourceBlockModelImpl.COMPANYID_COLUMN_BITMASK |
091 ResourceBlockModelImpl.NAME_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
093 ResourceBlockModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
095 new String[] { Long.class.getName(), String.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
097 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
098 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
099 "findByC_G_N",
100 new String[] {
101 Long.class.getName(), Long.class.getName(),
102 String.class.getName(),
103
104 "java.lang.Integer", "java.lang.Integer",
105 "com.liferay.portal.kernel.util.OrderByComparator"
106 });
107 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
108 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
109 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
110 "findByC_G_N",
111 new String[] {
112 Long.class.getName(), Long.class.getName(),
113 String.class.getName()
114 },
115 ResourceBlockModelImpl.COMPANYID_COLUMN_BITMASK |
116 ResourceBlockModelImpl.GROUPID_COLUMN_BITMASK |
117 ResourceBlockModelImpl.NAME_COLUMN_BITMASK);
118 public static final FinderPath FINDER_PATH_COUNT_BY_C_G_N = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
119 ResourceBlockModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_G_N",
121 new String[] {
122 Long.class.getName(), Long.class.getName(),
123 String.class.getName()
124 });
125 public static final FinderPath FINDER_PATH_FETCH_BY_C_G_N_P = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
126 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
127 ResourceBlockImpl.class, FINDER_CLASS_NAME_ENTITY,
128 "fetchByC_G_N_P",
129 new String[] {
130 Long.class.getName(), Long.class.getName(),
131 String.class.getName(), String.class.getName()
132 },
133 ResourceBlockModelImpl.COMPANYID_COLUMN_BITMASK |
134 ResourceBlockModelImpl.GROUPID_COLUMN_BITMASK |
135 ResourceBlockModelImpl.NAME_COLUMN_BITMASK |
136 ResourceBlockModelImpl.PERMISSIONSHASH_COLUMN_BITMASK);
137 public static final FinderPath FINDER_PATH_COUNT_BY_C_G_N_P = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
138 ResourceBlockModelImpl.FINDER_CACHE_ENABLED, Long.class,
139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_G_N_P",
140 new String[] {
141 Long.class.getName(), Long.class.getName(),
142 String.class.getName(), String.class.getName()
143 });
144 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
145 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
146 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
147 "findAll", new String[0]);
148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
149 ResourceBlockModelImpl.FINDER_CACHE_ENABLED,
150 ResourceBlockImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
151 "findAll", new String[0]);
152 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
153 ResourceBlockModelImpl.FINDER_CACHE_ENABLED, Long.class,
154 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
155
156
161 public void cacheResult(ResourceBlock resourceBlock) {
162 EntityCacheUtil.putResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
163 ResourceBlockImpl.class, resourceBlock.getPrimaryKey(),
164 resourceBlock);
165
166 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_G_N_P,
167 new Object[] {
168 Long.valueOf(resourceBlock.getCompanyId()),
169 Long.valueOf(resourceBlock.getGroupId()),
170
171 resourceBlock.getName(),
172
173 resourceBlock.getPermissionsHash()
174 }, resourceBlock);
175
176 resourceBlock.resetOriginalValues();
177 }
178
179
184 public void cacheResult(List<ResourceBlock> resourceBlocks) {
185 for (ResourceBlock resourceBlock : resourceBlocks) {
186 if (EntityCacheUtil.getResult(
187 ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
188 ResourceBlockImpl.class, resourceBlock.getPrimaryKey()) == null) {
189 cacheResult(resourceBlock);
190 }
191 else {
192 resourceBlock.resetOriginalValues();
193 }
194 }
195 }
196
197
204 @Override
205 public void clearCache() {
206 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
207 CacheRegistryUtil.clear(ResourceBlockImpl.class.getName());
208 }
209
210 EntityCacheUtil.clearCache(ResourceBlockImpl.class.getName());
211
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
215 }
216
217
224 @Override
225 public void clearCache(ResourceBlock resourceBlock) {
226 EntityCacheUtil.removeResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
227 ResourceBlockImpl.class, resourceBlock.getPrimaryKey());
228
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
231
232 clearUniqueFindersCache(resourceBlock);
233 }
234
235 @Override
236 public void clearCache(List<ResourceBlock> resourceBlocks) {
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
238 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
239
240 for (ResourceBlock resourceBlock : resourceBlocks) {
241 EntityCacheUtil.removeResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
242 ResourceBlockImpl.class, resourceBlock.getPrimaryKey());
243
244 clearUniqueFindersCache(resourceBlock);
245 }
246 }
247
248 protected void clearUniqueFindersCache(ResourceBlock resourceBlock) {
249 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_G_N_P,
250 new Object[] {
251 Long.valueOf(resourceBlock.getCompanyId()),
252 Long.valueOf(resourceBlock.getGroupId()),
253
254 resourceBlock.getName(),
255
256 resourceBlock.getPermissionsHash()
257 });
258 }
259
260
266 public ResourceBlock create(long resourceBlockId) {
267 ResourceBlock resourceBlock = new ResourceBlockImpl();
268
269 resourceBlock.setNew(true);
270 resourceBlock.setPrimaryKey(resourceBlockId);
271
272 return resourceBlock;
273 }
274
275
283 public ResourceBlock remove(long resourceBlockId)
284 throws NoSuchResourceBlockException, SystemException {
285 return remove(Long.valueOf(resourceBlockId));
286 }
287
288
296 @Override
297 public ResourceBlock remove(Serializable primaryKey)
298 throws NoSuchResourceBlockException, SystemException {
299 Session session = null;
300
301 try {
302 session = openSession();
303
304 ResourceBlock resourceBlock = (ResourceBlock)session.get(ResourceBlockImpl.class,
305 primaryKey);
306
307 if (resourceBlock == null) {
308 if (_log.isWarnEnabled()) {
309 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
310 }
311
312 throw new NoSuchResourceBlockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
313 primaryKey);
314 }
315
316 return remove(resourceBlock);
317 }
318 catch (NoSuchResourceBlockException nsee) {
319 throw nsee;
320 }
321 catch (Exception e) {
322 throw processException(e);
323 }
324 finally {
325 closeSession(session);
326 }
327 }
328
329 @Override
330 protected ResourceBlock removeImpl(ResourceBlock resourceBlock)
331 throws SystemException {
332 resourceBlock = toUnwrappedModel(resourceBlock);
333
334 Session session = null;
335
336 try {
337 session = openSession();
338
339 BatchSessionUtil.delete(session, resourceBlock);
340 }
341 catch (Exception e) {
342 throw processException(e);
343 }
344 finally {
345 closeSession(session);
346 }
347
348 clearCache(resourceBlock);
349
350 return resourceBlock;
351 }
352
353 @Override
354 public ResourceBlock updateImpl(
355 com.liferay.portal.model.ResourceBlock resourceBlock, boolean merge)
356 throws SystemException {
357 resourceBlock = toUnwrappedModel(resourceBlock);
358
359 boolean isNew = resourceBlock.isNew();
360
361 ResourceBlockModelImpl resourceBlockModelImpl = (ResourceBlockModelImpl)resourceBlock;
362
363 Session session = null;
364
365 try {
366 session = openSession();
367
368 BatchSessionUtil.update(session, resourceBlock, merge);
369
370 resourceBlock.setNew(false);
371 }
372 catch (Exception e) {
373 throw processException(e);
374 }
375 finally {
376 closeSession(session);
377 }
378
379 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
380
381 if (isNew || !ResourceBlockModelImpl.COLUMN_BITMASK_ENABLED) {
382 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
383 }
384
385 else {
386 if ((resourceBlockModelImpl.getColumnBitmask() &
387 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_N.getColumnBitmask()) != 0) {
388 Object[] args = new Object[] {
389 Long.valueOf(resourceBlockModelImpl.getOriginalCompanyId()),
390
391 resourceBlockModelImpl.getOriginalName()
392 };
393
394 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
395 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_N,
396 args);
397
398 args = new Object[] {
399 Long.valueOf(resourceBlockModelImpl.getCompanyId()),
400
401 resourceBlockModelImpl.getName()
402 };
403
404 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
405 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_N,
406 args);
407 }
408
409 if ((resourceBlockModelImpl.getColumnBitmask() &
410 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G_N.getColumnBitmask()) != 0) {
411 Object[] args = new Object[] {
412 Long.valueOf(resourceBlockModelImpl.getOriginalCompanyId()),
413 Long.valueOf(resourceBlockModelImpl.getOriginalGroupId()),
414
415 resourceBlockModelImpl.getOriginalName()
416 };
417
418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_G_N, args);
419 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G_N,
420 args);
421
422 args = new Object[] {
423 Long.valueOf(resourceBlockModelImpl.getCompanyId()),
424 Long.valueOf(resourceBlockModelImpl.getGroupId()),
425
426 resourceBlockModelImpl.getName()
427 };
428
429 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_G_N, args);
430 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G_N,
431 args);
432 }
433 }
434
435 EntityCacheUtil.putResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
436 ResourceBlockImpl.class, resourceBlock.getPrimaryKey(),
437 resourceBlock);
438
439 if (isNew) {
440 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_G_N_P,
441 new Object[] {
442 Long.valueOf(resourceBlock.getCompanyId()),
443 Long.valueOf(resourceBlock.getGroupId()),
444
445 resourceBlock.getName(),
446
447 resourceBlock.getPermissionsHash()
448 }, resourceBlock);
449 }
450 else {
451 if ((resourceBlockModelImpl.getColumnBitmask() &
452 FINDER_PATH_FETCH_BY_C_G_N_P.getColumnBitmask()) != 0) {
453 Object[] args = new Object[] {
454 Long.valueOf(resourceBlockModelImpl.getOriginalCompanyId()),
455 Long.valueOf(resourceBlockModelImpl.getOriginalGroupId()),
456
457 resourceBlockModelImpl.getOriginalName(),
458
459 resourceBlockModelImpl.getOriginalPermissionsHash()
460 };
461
462 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_G_N_P, args);
463
464 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_G_N_P, args);
465
466 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_G_N_P,
467 new Object[] {
468 Long.valueOf(resourceBlock.getCompanyId()),
469 Long.valueOf(resourceBlock.getGroupId()),
470
471 resourceBlock.getName(),
472
473 resourceBlock.getPermissionsHash()
474 }, resourceBlock);
475 }
476 }
477
478 return resourceBlock;
479 }
480
481 protected ResourceBlock toUnwrappedModel(ResourceBlock resourceBlock) {
482 if (resourceBlock instanceof ResourceBlockImpl) {
483 return resourceBlock;
484 }
485
486 ResourceBlockImpl resourceBlockImpl = new ResourceBlockImpl();
487
488 resourceBlockImpl.setNew(resourceBlock.isNew());
489 resourceBlockImpl.setPrimaryKey(resourceBlock.getPrimaryKey());
490
491 resourceBlockImpl.setResourceBlockId(resourceBlock.getResourceBlockId());
492 resourceBlockImpl.setCompanyId(resourceBlock.getCompanyId());
493 resourceBlockImpl.setGroupId(resourceBlock.getGroupId());
494 resourceBlockImpl.setName(resourceBlock.getName());
495 resourceBlockImpl.setPermissionsHash(resourceBlock.getPermissionsHash());
496 resourceBlockImpl.setReferenceCount(resourceBlock.getReferenceCount());
497
498 return resourceBlockImpl;
499 }
500
501
509 @Override
510 public ResourceBlock findByPrimaryKey(Serializable primaryKey)
511 throws NoSuchModelException, SystemException {
512 return findByPrimaryKey(((Long)primaryKey).longValue());
513 }
514
515
523 public ResourceBlock findByPrimaryKey(long resourceBlockId)
524 throws NoSuchResourceBlockException, SystemException {
525 ResourceBlock resourceBlock = fetchByPrimaryKey(resourceBlockId);
526
527 if (resourceBlock == null) {
528 if (_log.isWarnEnabled()) {
529 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + resourceBlockId);
530 }
531
532 throw new NoSuchResourceBlockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
533 resourceBlockId);
534 }
535
536 return resourceBlock;
537 }
538
539
546 @Override
547 public ResourceBlock fetchByPrimaryKey(Serializable primaryKey)
548 throws SystemException {
549 return fetchByPrimaryKey(((Long)primaryKey).longValue());
550 }
551
552
559 public ResourceBlock fetchByPrimaryKey(long resourceBlockId)
560 throws SystemException {
561 ResourceBlock resourceBlock = (ResourceBlock)EntityCacheUtil.getResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
562 ResourceBlockImpl.class, resourceBlockId);
563
564 if (resourceBlock == _nullResourceBlock) {
565 return null;
566 }
567
568 if (resourceBlock == null) {
569 Session session = null;
570
571 boolean hasException = false;
572
573 try {
574 session = openSession();
575
576 resourceBlock = (ResourceBlock)session.get(ResourceBlockImpl.class,
577 Long.valueOf(resourceBlockId));
578 }
579 catch (Exception e) {
580 hasException = true;
581
582 throw processException(e);
583 }
584 finally {
585 if (resourceBlock != null) {
586 cacheResult(resourceBlock);
587 }
588 else if (!hasException) {
589 EntityCacheUtil.putResult(ResourceBlockModelImpl.ENTITY_CACHE_ENABLED,
590 ResourceBlockImpl.class, resourceBlockId,
591 _nullResourceBlock);
592 }
593
594 closeSession(session);
595 }
596 }
597
598 return resourceBlock;
599 }
600
601
609 public List<ResourceBlock> findByC_N(long companyId, String name)
610 throws SystemException {
611 return findByC_N(companyId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
612 null);
613 }
614
615
629 public List<ResourceBlock> findByC_N(long companyId, String name,
630 int start, int end) throws SystemException {
631 return findByC_N(companyId, name, start, end, null);
632 }
633
634
649 public List<ResourceBlock> findByC_N(long companyId, String name,
650 int start, int end, OrderByComparator orderByComparator)
651 throws SystemException {
652 FinderPath finderPath = null;
653 Object[] finderArgs = null;
654
655 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
656 (orderByComparator == null)) {
657 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_N;
658 finderArgs = new Object[] { companyId, name };
659 }
660 else {
661 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_N;
662 finderArgs = new Object[] {
663 companyId, name,
664
665 start, end, orderByComparator
666 };
667 }
668
669 List<ResourceBlock> list = (List<ResourceBlock>)FinderCacheUtil.getResult(finderPath,
670 finderArgs, this);
671
672 if ((list != null) && !list.isEmpty()) {
673 for (ResourceBlock resourceBlock : list) {
674 if ((companyId != resourceBlock.getCompanyId()) ||
675 !Validator.equals(name, resourceBlock.getName())) {
676 list = null;
677
678 break;
679 }
680 }
681 }
682
683 if (list == null) {
684 StringBundler query = null;
685
686 if (orderByComparator != null) {
687 query = new StringBundler(4 +
688 (orderByComparator.getOrderByFields().length * 3));
689 }
690 else {
691 query = new StringBundler(3);
692 }
693
694 query.append(_SQL_SELECT_RESOURCEBLOCK_WHERE);
695
696 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
697
698 if (name == null) {
699 query.append(_FINDER_COLUMN_C_N_NAME_1);
700 }
701 else {
702 if (name.equals(StringPool.BLANK)) {
703 query.append(_FINDER_COLUMN_C_N_NAME_3);
704 }
705 else {
706 query.append(_FINDER_COLUMN_C_N_NAME_2);
707 }
708 }
709
710 if (orderByComparator != null) {
711 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
712 orderByComparator);
713 }
714
715 String sql = query.toString();
716
717 Session session = null;
718
719 try {
720 session = openSession();
721
722 Query q = session.createQuery(sql);
723
724 QueryPos qPos = QueryPos.getInstance(q);
725
726 qPos.add(companyId);
727
728 if (name != null) {
729 qPos.add(name);
730 }
731
732 list = (List<ResourceBlock>)QueryUtil.list(q, getDialect(),
733 start, end);
734 }
735 catch (Exception e) {
736 throw processException(e);
737 }
738 finally {
739 if (list == null) {
740 FinderCacheUtil.removeResult(finderPath, finderArgs);
741 }
742 else {
743 cacheResult(list);
744
745 FinderCacheUtil.putResult(finderPath, finderArgs, list);
746 }
747
748 closeSession(session);
749 }
750 }
751
752 return list;
753 }
754
755
765 public ResourceBlock findByC_N_First(long companyId, String name,
766 OrderByComparator orderByComparator)
767 throws NoSuchResourceBlockException, SystemException {
768 ResourceBlock resourceBlock = fetchByC_N_First(companyId, name,
769 orderByComparator);
770
771 if (resourceBlock != null) {
772 return resourceBlock;
773 }
774
775 StringBundler msg = new StringBundler(6);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("companyId=");
780 msg.append(companyId);
781
782 msg.append(", name=");
783 msg.append(name);
784
785 msg.append(StringPool.CLOSE_CURLY_BRACE);
786
787 throw new NoSuchResourceBlockException(msg.toString());
788 }
789
790
799 public ResourceBlock fetchByC_N_First(long companyId, String name,
800 OrderByComparator orderByComparator) throws SystemException {
801 List<ResourceBlock> list = findByC_N(companyId, name, 0, 1,
802 orderByComparator);
803
804 if (!list.isEmpty()) {
805 return list.get(0);
806 }
807
808 return null;
809 }
810
811
821 public ResourceBlock findByC_N_Last(long companyId, String name,
822 OrderByComparator orderByComparator)
823 throws NoSuchResourceBlockException, SystemException {
824 ResourceBlock resourceBlock = fetchByC_N_Last(companyId, name,
825 orderByComparator);
826
827 if (resourceBlock != null) {
828 return resourceBlock;
829 }
830
831 StringBundler msg = new StringBundler(6);
832
833 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
834
835 msg.append("companyId=");
836 msg.append(companyId);
837
838 msg.append(", name=");
839 msg.append(name);
840
841 msg.append(StringPool.CLOSE_CURLY_BRACE);
842
843 throw new NoSuchResourceBlockException(msg.toString());
844 }
845
846
855 public ResourceBlock fetchByC_N_Last(long companyId, String name,
856 OrderByComparator orderByComparator) throws SystemException {
857 int count = countByC_N(companyId, name);
858
859 List<ResourceBlock> list = findByC_N(companyId, name, count - 1, count,
860 orderByComparator);
861
862 if (!list.isEmpty()) {
863 return list.get(0);
864 }
865
866 return null;
867 }
868
869
880 public ResourceBlock[] findByC_N_PrevAndNext(long resourceBlockId,
881 long companyId, String name, OrderByComparator orderByComparator)
882 throws NoSuchResourceBlockException, SystemException {
883 ResourceBlock resourceBlock = findByPrimaryKey(resourceBlockId);
884
885 Session session = null;
886
887 try {
888 session = openSession();
889
890 ResourceBlock[] array = new ResourceBlockImpl[3];
891
892 array[0] = getByC_N_PrevAndNext(session, resourceBlock, companyId,
893 name, orderByComparator, true);
894
895 array[1] = resourceBlock;
896
897 array[2] = getByC_N_PrevAndNext(session, resourceBlock, companyId,
898 name, orderByComparator, false);
899
900 return array;
901 }
902 catch (Exception e) {
903 throw processException(e);
904 }
905 finally {
906 closeSession(session);
907 }
908 }
909
910 protected ResourceBlock getByC_N_PrevAndNext(Session session,
911 ResourceBlock resourceBlock, long companyId, String name,
912 OrderByComparator orderByComparator, boolean previous) {
913 StringBundler query = null;
914
915 if (orderByComparator != null) {
916 query = new StringBundler(6 +
917 (orderByComparator.getOrderByFields().length * 6));
918 }
919 else {
920 query = new StringBundler(3);
921 }
922
923 query.append(_SQL_SELECT_RESOURCEBLOCK_WHERE);
924
925 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
926
927 if (name == null) {
928 query.append(_FINDER_COLUMN_C_N_NAME_1);
929 }
930 else {
931 if (name.equals(StringPool.BLANK)) {
932 query.append(_FINDER_COLUMN_C_N_NAME_3);
933 }
934 else {
935 query.append(_FINDER_COLUMN_C_N_NAME_2);
936 }
937 }
938
939 if (orderByComparator != null) {
940 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
941
942 if (orderByConditionFields.length > 0) {
943 query.append(WHERE_AND);
944 }
945
946 for (int i = 0; i < orderByConditionFields.length; i++) {
947 query.append(_ORDER_BY_ENTITY_ALIAS);
948 query.append(orderByConditionFields[i]);
949
950 if ((i + 1) < orderByConditionFields.length) {
951 if (orderByComparator.isAscending() ^ previous) {
952 query.append(WHERE_GREATER_THAN_HAS_NEXT);
953 }
954 else {
955 query.append(WHERE_LESSER_THAN_HAS_NEXT);
956 }
957 }
958 else {
959 if (orderByComparator.isAscending() ^ previous) {
960 query.append(WHERE_GREATER_THAN);
961 }
962 else {
963 query.append(WHERE_LESSER_THAN);
964 }
965 }
966 }
967
968 query.append(ORDER_BY_CLAUSE);
969
970 String[] orderByFields = orderByComparator.getOrderByFields();
971
972 for (int i = 0; i < orderByFields.length; i++) {
973 query.append(_ORDER_BY_ENTITY_ALIAS);
974 query.append(orderByFields[i]);
975
976 if ((i + 1) < orderByFields.length) {
977 if (orderByComparator.isAscending() ^ previous) {
978 query.append(ORDER_BY_ASC_HAS_NEXT);
979 }
980 else {
981 query.append(ORDER_BY_DESC_HAS_NEXT);
982 }
983 }
984 else {
985 if (orderByComparator.isAscending() ^ previous) {
986 query.append(ORDER_BY_ASC);
987 }
988 else {
989 query.append(ORDER_BY_DESC);
990 }
991 }
992 }
993 }
994
995 String sql = query.toString();
996
997 Query q = session.createQuery(sql);
998
999 q.setFirstResult(0);
1000 q.setMaxResults(2);
1001
1002 QueryPos qPos = QueryPos.getInstance(q);
1003
1004 qPos.add(companyId);
1005
1006 if (name != null) {
1007 qPos.add(name);
1008 }
1009
1010 if (orderByComparator != null) {
1011 Object[] values = orderByComparator.getOrderByConditionValues(resourceBlock);
1012
1013 for (Object value : values) {
1014 qPos.add(value);
1015 }
1016 }
1017
1018 List<ResourceBlock> list = q.list();
1019
1020 if (list.size() == 2) {
1021 return list.get(1);
1022 }
1023 else {
1024 return null;
1025 }
1026 }
1027
1028
1037 public List<ResourceBlock> findByC_G_N(long companyId, long groupId,
1038 String name) throws SystemException {
1039 return findByC_G_N(companyId, groupId, name, QueryUtil.ALL_POS,
1040 QueryUtil.ALL_POS, null);
1041 }
1042
1043
1058 public List<ResourceBlock> findByC_G_N(long companyId, long groupId,
1059 String name, int start, int end) throws SystemException {
1060 return findByC_G_N(companyId, groupId, name, start, end, null);
1061 }
1062
1063
1079 public List<ResourceBlock> findByC_G_N(long companyId, long groupId,
1080 String name, int start, int end, OrderByComparator orderByComparator)
1081 throws SystemException {
1082 FinderPath finderPath = null;
1083 Object[] finderArgs = null;
1084
1085 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1086 (orderByComparator == null)) {
1087 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G_N;
1088 finderArgs = new Object[] { companyId, groupId, name };
1089 }
1090 else {
1091 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_N;
1092 finderArgs = new Object[] {
1093 companyId, groupId, name,
1094
1095 start, end, orderByComparator
1096 };
1097 }
1098
1099 List<ResourceBlock> list = (List<ResourceBlock>)FinderCacheUtil.getResult(finderPath,
1100 finderArgs, this);
1101
1102 if ((list != null) && !list.isEmpty()) {
1103 for (ResourceBlock resourceBlock : list) {
1104 if ((companyId != resourceBlock.getCompanyId()) ||
1105 (groupId != resourceBlock.getGroupId()) ||
1106 !Validator.equals(name, resourceBlock.getName())) {
1107 list = null;
1108
1109 break;
1110 }
1111 }
1112 }
1113
1114 if (list == null) {
1115 StringBundler query = null;
1116
1117 if (orderByComparator != null) {
1118 query = new StringBundler(5 +
1119 (orderByComparator.getOrderByFields().length * 3));
1120 }
1121 else {
1122 query = new StringBundler(4);
1123 }
1124
1125 query.append(_SQL_SELECT_RESOURCEBLOCK_WHERE);
1126
1127 query.append(_FINDER_COLUMN_C_G_N_COMPANYID_2);
1128
1129 query.append(_FINDER_COLUMN_C_G_N_GROUPID_2);
1130
1131 if (name == null) {
1132 query.append(_FINDER_COLUMN_C_G_N_NAME_1);
1133 }
1134 else {
1135 if (name.equals(StringPool.BLANK)) {
1136 query.append(_FINDER_COLUMN_C_G_N_NAME_3);
1137 }
1138 else {
1139 query.append(_FINDER_COLUMN_C_G_N_NAME_2);
1140 }
1141 }
1142
1143 if (orderByComparator != null) {
1144 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1145 orderByComparator);
1146 }
1147
1148 String sql = query.toString();
1149
1150 Session session = null;
1151
1152 try {
1153 session = openSession();
1154
1155 Query q = session.createQuery(sql);
1156
1157 QueryPos qPos = QueryPos.getInstance(q);
1158
1159 qPos.add(companyId);
1160
1161 qPos.add(groupId);
1162
1163 if (name != null) {
1164 qPos.add(name);
1165 }
1166
1167 list = (List<ResourceBlock>)QueryUtil.list(q, getDialect(),
1168 start, end);
1169 }
1170 catch (Exception e) {
1171 throw processException(e);
1172 }
1173 finally {
1174 if (list == null) {
1175 FinderCacheUtil.removeResult(finderPath, finderArgs);
1176 }
1177 else {
1178 cacheResult(list);
1179
1180 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1181 }
1182
1183 closeSession(session);
1184 }
1185 }
1186
1187 return list;
1188 }
1189
1190
1201 public ResourceBlock findByC_G_N_First(long companyId, long groupId,
1202 String name, OrderByComparator orderByComparator)
1203 throws NoSuchResourceBlockException, SystemException {
1204 ResourceBlock resourceBlock = fetchByC_G_N_First(companyId, groupId,
1205 name, orderByComparator);
1206
1207 if (resourceBlock != null) {
1208 return resourceBlock;
1209 }
1210
1211 StringBundler msg = new StringBundler(8);
1212
1213 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1214
1215 msg.append("companyId=");
1216 msg.append(companyId);
1217
1218 msg.append(", groupId=");
1219 msg.append(groupId);
1220
1221 msg.append(", name=");
1222 msg.append(name);
1223
1224 msg.append(StringPool.CLOSE_CURLY_BRACE);
1225
1226 throw new NoSuchResourceBlockException(msg.toString());
1227 }
1228
1229
1239 public ResourceBlock fetchByC_G_N_First(long companyId, long groupId,
1240 String name, OrderByComparator orderByComparator)
1241 throws SystemException {
1242 List<ResourceBlock> list = findByC_G_N(companyId, groupId, name, 0, 1,
1243 orderByComparator);
1244
1245 if (!list.isEmpty()) {
1246 return list.get(0);
1247 }
1248
1249 return null;
1250 }
1251
1252
1263 public ResourceBlock findByC_G_N_Last(long companyId, long groupId,
1264 String name, OrderByComparator orderByComparator)
1265 throws NoSuchResourceBlockException, SystemException {
1266 ResourceBlock resourceBlock = fetchByC_G_N_Last(companyId, groupId,
1267 name, orderByComparator);
1268
1269 if (resourceBlock != null) {
1270 return resourceBlock;
1271 }
1272
1273 StringBundler msg = new StringBundler(8);
1274
1275 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1276
1277 msg.append("companyId=");
1278 msg.append(companyId);
1279
1280 msg.append(", groupId=");
1281 msg.append(groupId);
1282
1283 msg.append(", name=");
1284 msg.append(name);
1285
1286 msg.append(StringPool.CLOSE_CURLY_BRACE);
1287
1288 throw new NoSuchResourceBlockException(msg.toString());
1289 }
1290
1291
1301 public ResourceBlock fetchByC_G_N_Last(long companyId, long groupId,
1302 String name, OrderByComparator orderByComparator)
1303 throws SystemException {
1304 int count = countByC_G_N(companyId, groupId, name);
1305
1306 List<ResourceBlock> list = findByC_G_N(companyId, groupId, name,
1307 count - 1, count, orderByComparator);
1308
1309 if (!list.isEmpty()) {
1310 return list.get(0);
1311 }
1312
1313 return null;
1314 }
1315
1316
1328 public ResourceBlock[] findByC_G_N_PrevAndNext(long resourceBlockId,
1329 long companyId, long groupId, String name,
1330 OrderByComparator orderByComparator)
1331 throws NoSuchResourceBlockException, SystemException {
1332 ResourceBlock resourceBlock = findByPrimaryKey(resourceBlockId);
1333
1334 Session session = null;
1335
1336 try {
1337 session = openSession();
1338
1339 ResourceBlock[] array = new ResourceBlockImpl[3];
1340
1341 array[0] = getByC_G_N_PrevAndNext(session, resourceBlock,
1342 companyId, groupId, name, orderByComparator, true);
1343
1344 array[1] = resourceBlock;
1345
1346 array[2] = getByC_G_N_PrevAndNext(session, resourceBlock,
1347 companyId, groupId, name, orderByComparator, false);
1348
1349 return array;
1350 }
1351 catch (Exception e) {
1352 throw processException(e);
1353 }
1354 finally {
1355 closeSession(session);
1356 }
1357 }
1358
1359 protected ResourceBlock getByC_G_N_PrevAndNext(Session session,
1360 ResourceBlock resourceBlock, long companyId, long groupId, String name,
1361 OrderByComparator orderByComparator, boolean previous) {
1362 StringBundler query = null;
1363
1364 if (orderByComparator != null) {
1365 query = new StringBundler(6 +
1366 (orderByComparator.getOrderByFields().length * 6));
1367 }
1368 else {
1369 query = new StringBundler(3);
1370 }
1371
1372 query.append(_SQL_SELECT_RESOURCEBLOCK_WHERE);
1373
1374 query.append(_FINDER_COLUMN_C_G_N_COMPANYID_2);
1375
1376 query.append(_FINDER_COLUMN_C_G_N_GROUPID_2);
1377
1378 if (name == null) {
1379 query.append(_FINDER_COLUMN_C_G_N_NAME_1);
1380 }
1381 else {
1382 if (name.equals(StringPool.BLANK)) {
1383 query.append(_FINDER_COLUMN_C_G_N_NAME_3);
1384 }
1385 else {
1386 query.append(_FINDER_COLUMN_C_G_N_NAME_2);
1387 }
1388 }
1389
1390 if (orderByComparator != null) {
1391 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1392
1393 if (orderByConditionFields.length > 0) {
1394 query.append(WHERE_AND);
1395 }
1396
1397 for (int i = 0; i < orderByConditionFields.length; i++) {
1398 query.append(_ORDER_BY_ENTITY_ALIAS);
1399 query.append(orderByConditionFields[i]);
1400
1401 if ((i + 1) < orderByConditionFields.length) {
1402 if (orderByComparator.isAscending() ^ previous) {
1403 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1404 }
1405 else {
1406 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1407 }
1408 }
1409 else {
1410 if (orderByComparator.isAscending() ^ previous) {
1411 query.append(WHERE_GREATER_THAN);
1412 }
1413 else {
1414 query.append(WHERE_LESSER_THAN);
1415 }
1416 }
1417 }
1418
1419 query.append(ORDER_BY_CLAUSE);
1420
1421 String[] orderByFields = orderByComparator.getOrderByFields();
1422
1423 for (int i = 0; i < orderByFields.length; i++) {
1424 query.append(_ORDER_BY_ENTITY_ALIAS);
1425 query.append(orderByFields[i]);
1426
1427 if ((i + 1) < orderByFields.length) {
1428 if (orderByComparator.isAscending() ^ previous) {
1429 query.append(ORDER_BY_ASC_HAS_NEXT);
1430 }
1431 else {
1432 query.append(ORDER_BY_DESC_HAS_NEXT);
1433 }
1434 }
1435 else {
1436 if (orderByComparator.isAscending() ^ previous) {
1437 query.append(ORDER_BY_ASC);
1438 }
1439 else {
1440 query.append(ORDER_BY_DESC);
1441 }
1442 }
1443 }
1444 }
1445
1446 String sql = query.toString();
1447
1448 Query q = session.createQuery(sql);
1449
1450 q.setFirstResult(0);
1451 q.setMaxResults(2);
1452
1453 QueryPos qPos = QueryPos.getInstance(q);
1454
1455 qPos.add(companyId);
1456
1457 qPos.add(groupId);
1458
1459 if (name != null) {
1460 qPos.add(name);
1461 }
1462
1463 if (orderByComparator != null) {
1464 Object[] values = orderByComparator.getOrderByConditionValues(resourceBlock);
1465
1466 for (Object value : values) {
1467 qPos.add(value);
1468 }
1469 }
1470
1471 List<ResourceBlock> list = q.list();
1472
1473 if (list.size() == 2) {
1474 return list.get(1);
1475 }
1476 else {
1477 return null;
1478 }
1479 }
1480
1481
1492 public ResourceBlock findByC_G_N_P(long companyId, long groupId,
1493 String name, String permissionsHash)
1494 throws NoSuchResourceBlockException, SystemException {
1495 ResourceBlock resourceBlock = fetchByC_G_N_P(companyId, groupId, name,
1496 permissionsHash);
1497
1498 if (resourceBlock == null) {
1499 StringBundler msg = new StringBundler(10);
1500
1501 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1502
1503 msg.append("companyId=");
1504 msg.append(companyId);
1505
1506 msg.append(", groupId=");
1507 msg.append(groupId);
1508
1509 msg.append(", name=");
1510 msg.append(name);
1511
1512 msg.append(", permissionsHash=");
1513 msg.append(permissionsHash);
1514
1515 msg.append(StringPool.CLOSE_CURLY_BRACE);
1516
1517 if (_log.isWarnEnabled()) {
1518 _log.warn(msg.toString());
1519 }
1520
1521 throw new NoSuchResourceBlockException(msg.toString());
1522 }
1523
1524 return resourceBlock;
1525 }
1526
1527
1537 public ResourceBlock fetchByC_G_N_P(long companyId, long groupId,
1538 String name, String permissionsHash) throws SystemException {
1539 return fetchByC_G_N_P(companyId, groupId, name, permissionsHash, true);
1540 }
1541
1542
1553 public ResourceBlock fetchByC_G_N_P(long companyId, long groupId,
1554 String name, String permissionsHash, boolean retrieveFromCache)
1555 throws SystemException {
1556 Object[] finderArgs = new Object[] {
1557 companyId, groupId, name, permissionsHash
1558 };
1559
1560 Object result = null;
1561
1562 if (retrieveFromCache) {
1563 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_G_N_P,
1564 finderArgs, this);
1565 }
1566
1567 if (result instanceof ResourceBlock) {
1568 ResourceBlock resourceBlock = (ResourceBlock)result;
1569
1570 if ((companyId != resourceBlock.getCompanyId()) ||
1571 (groupId != resourceBlock.getGroupId()) ||
1572 !Validator.equals(name, resourceBlock.getName()) ||
1573 !Validator.equals(permissionsHash,
1574 resourceBlock.getPermissionsHash())) {
1575 result = null;
1576 }
1577 }
1578
1579 if (result == null) {
1580 StringBundler query = new StringBundler(5);
1581
1582 query.append(_SQL_SELECT_RESOURCEBLOCK_WHERE);
1583
1584 query.append(_FINDER_COLUMN_C_G_N_P_COMPANYID_2);
1585
1586 query.append(_FINDER_COLUMN_C_G_N_P_GROUPID_2);
1587
1588 if (name == null) {
1589 query.append(_FINDER_COLUMN_C_G_N_P_NAME_1);
1590 }
1591 else {
1592 if (name.equals(StringPool.BLANK)) {
1593 query.append(_FINDER_COLUMN_C_G_N_P_NAME_3);
1594 }
1595 else {
1596 query.append(_FINDER_COLUMN_C_G_N_P_NAME_2);
1597 }
1598 }
1599
1600 if (permissionsHash == null) {
1601 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_1);
1602 }
1603 else {
1604 if (permissionsHash.equals(StringPool.BLANK)) {
1605 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_3);
1606 }
1607 else {
1608 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_2);
1609 }
1610 }
1611
1612 String sql = query.toString();
1613
1614 Session session = null;
1615
1616 try {
1617 session = openSession();
1618
1619 Query q = session.createQuery(sql);
1620
1621 QueryPos qPos = QueryPos.getInstance(q);
1622
1623 qPos.add(companyId);
1624
1625 qPos.add(groupId);
1626
1627 if (name != null) {
1628 qPos.add(name);
1629 }
1630
1631 if (permissionsHash != null) {
1632 qPos.add(permissionsHash);
1633 }
1634
1635 List<ResourceBlock> list = q.list();
1636
1637 result = list;
1638
1639 ResourceBlock resourceBlock = null;
1640
1641 if (list.isEmpty()) {
1642 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_G_N_P,
1643 finderArgs, list);
1644 }
1645 else {
1646 resourceBlock = list.get(0);
1647
1648 cacheResult(resourceBlock);
1649
1650 if ((resourceBlock.getCompanyId() != companyId) ||
1651 (resourceBlock.getGroupId() != groupId) ||
1652 (resourceBlock.getName() == null) ||
1653 !resourceBlock.getName().equals(name) ||
1654 (resourceBlock.getPermissionsHash() == null) ||
1655 !resourceBlock.getPermissionsHash()
1656 .equals(permissionsHash)) {
1657 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_G_N_P,
1658 finderArgs, resourceBlock);
1659 }
1660 }
1661
1662 return resourceBlock;
1663 }
1664 catch (Exception e) {
1665 throw processException(e);
1666 }
1667 finally {
1668 if (result == null) {
1669 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_G_N_P,
1670 finderArgs);
1671 }
1672
1673 closeSession(session);
1674 }
1675 }
1676 else {
1677 if (result instanceof List<?>) {
1678 return null;
1679 }
1680 else {
1681 return (ResourceBlock)result;
1682 }
1683 }
1684 }
1685
1686
1692 public List<ResourceBlock> findAll() throws SystemException {
1693 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1694 }
1695
1696
1708 public List<ResourceBlock> findAll(int start, int end)
1709 throws SystemException {
1710 return findAll(start, end, null);
1711 }
1712
1713
1726 public List<ResourceBlock> findAll(int start, int end,
1727 OrderByComparator orderByComparator) throws SystemException {
1728 FinderPath finderPath = null;
1729 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1730
1731 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1732 (orderByComparator == null)) {
1733 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1734 finderArgs = FINDER_ARGS_EMPTY;
1735 }
1736 else {
1737 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1738 finderArgs = new Object[] { start, end, orderByComparator };
1739 }
1740
1741 List<ResourceBlock> list = (List<ResourceBlock>)FinderCacheUtil.getResult(finderPath,
1742 finderArgs, this);
1743
1744 if (list == null) {
1745 StringBundler query = null;
1746 String sql = null;
1747
1748 if (orderByComparator != null) {
1749 query = new StringBundler(2 +
1750 (orderByComparator.getOrderByFields().length * 3));
1751
1752 query.append(_SQL_SELECT_RESOURCEBLOCK);
1753
1754 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1755 orderByComparator);
1756
1757 sql = query.toString();
1758 }
1759 else {
1760 sql = _SQL_SELECT_RESOURCEBLOCK;
1761 }
1762
1763 Session session = null;
1764
1765 try {
1766 session = openSession();
1767
1768 Query q = session.createQuery(sql);
1769
1770 if (orderByComparator == null) {
1771 list = (List<ResourceBlock>)QueryUtil.list(q, getDialect(),
1772 start, end, false);
1773
1774 Collections.sort(list);
1775 }
1776 else {
1777 list = (List<ResourceBlock>)QueryUtil.list(q, getDialect(),
1778 start, end);
1779 }
1780 }
1781 catch (Exception e) {
1782 throw processException(e);
1783 }
1784 finally {
1785 if (list == null) {
1786 FinderCacheUtil.removeResult(finderPath, finderArgs);
1787 }
1788 else {
1789 cacheResult(list);
1790
1791 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1792 }
1793
1794 closeSession(session);
1795 }
1796 }
1797
1798 return list;
1799 }
1800
1801
1808 public void removeByC_N(long companyId, String name)
1809 throws SystemException {
1810 for (ResourceBlock resourceBlock : findByC_N(companyId, name)) {
1811 remove(resourceBlock);
1812 }
1813 }
1814
1815
1823 public void removeByC_G_N(long companyId, long groupId, String name)
1824 throws SystemException {
1825 for (ResourceBlock resourceBlock : findByC_G_N(companyId, groupId, name)) {
1826 remove(resourceBlock);
1827 }
1828 }
1829
1830
1840 public ResourceBlock removeByC_G_N_P(long companyId, long groupId,
1841 String name, String permissionsHash)
1842 throws NoSuchResourceBlockException, SystemException {
1843 ResourceBlock resourceBlock = findByC_G_N_P(companyId, groupId, name,
1844 permissionsHash);
1845
1846 return remove(resourceBlock);
1847 }
1848
1849
1854 public void removeAll() throws SystemException {
1855 for (ResourceBlock resourceBlock : findAll()) {
1856 remove(resourceBlock);
1857 }
1858 }
1859
1860
1868 public int countByC_N(long companyId, String name)
1869 throws SystemException {
1870 Object[] finderArgs = new Object[] { companyId, name };
1871
1872 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1873 finderArgs, this);
1874
1875 if (count == null) {
1876 StringBundler query = new StringBundler(3);
1877
1878 query.append(_SQL_COUNT_RESOURCEBLOCK_WHERE);
1879
1880 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1881
1882 if (name == null) {
1883 query.append(_FINDER_COLUMN_C_N_NAME_1);
1884 }
1885 else {
1886 if (name.equals(StringPool.BLANK)) {
1887 query.append(_FINDER_COLUMN_C_N_NAME_3);
1888 }
1889 else {
1890 query.append(_FINDER_COLUMN_C_N_NAME_2);
1891 }
1892 }
1893
1894 String sql = query.toString();
1895
1896 Session session = null;
1897
1898 try {
1899 session = openSession();
1900
1901 Query q = session.createQuery(sql);
1902
1903 QueryPos qPos = QueryPos.getInstance(q);
1904
1905 qPos.add(companyId);
1906
1907 if (name != null) {
1908 qPos.add(name);
1909 }
1910
1911 count = (Long)q.uniqueResult();
1912 }
1913 catch (Exception e) {
1914 throw processException(e);
1915 }
1916 finally {
1917 if (count == null) {
1918 count = Long.valueOf(0);
1919 }
1920
1921 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
1922 count);
1923
1924 closeSession(session);
1925 }
1926 }
1927
1928 return count.intValue();
1929 }
1930
1931
1940 public int countByC_G_N(long companyId, long groupId, String name)
1941 throws SystemException {
1942 Object[] finderArgs = new Object[] { companyId, groupId, name };
1943
1944 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_G_N,
1945 finderArgs, this);
1946
1947 if (count == null) {
1948 StringBundler query = new StringBundler(4);
1949
1950 query.append(_SQL_COUNT_RESOURCEBLOCK_WHERE);
1951
1952 query.append(_FINDER_COLUMN_C_G_N_COMPANYID_2);
1953
1954 query.append(_FINDER_COLUMN_C_G_N_GROUPID_2);
1955
1956 if (name == null) {
1957 query.append(_FINDER_COLUMN_C_G_N_NAME_1);
1958 }
1959 else {
1960 if (name.equals(StringPool.BLANK)) {
1961 query.append(_FINDER_COLUMN_C_G_N_NAME_3);
1962 }
1963 else {
1964 query.append(_FINDER_COLUMN_C_G_N_NAME_2);
1965 }
1966 }
1967
1968 String sql = query.toString();
1969
1970 Session session = null;
1971
1972 try {
1973 session = openSession();
1974
1975 Query q = session.createQuery(sql);
1976
1977 QueryPos qPos = QueryPos.getInstance(q);
1978
1979 qPos.add(companyId);
1980
1981 qPos.add(groupId);
1982
1983 if (name != null) {
1984 qPos.add(name);
1985 }
1986
1987 count = (Long)q.uniqueResult();
1988 }
1989 catch (Exception e) {
1990 throw processException(e);
1991 }
1992 finally {
1993 if (count == null) {
1994 count = Long.valueOf(0);
1995 }
1996
1997 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_G_N,
1998 finderArgs, count);
1999
2000 closeSession(session);
2001 }
2002 }
2003
2004 return count.intValue();
2005 }
2006
2007
2017 public int countByC_G_N_P(long companyId, long groupId, String name,
2018 String permissionsHash) throws SystemException {
2019 Object[] finderArgs = new Object[] {
2020 companyId, groupId, name, permissionsHash
2021 };
2022
2023 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_G_N_P,
2024 finderArgs, this);
2025
2026 if (count == null) {
2027 StringBundler query = new StringBundler(5);
2028
2029 query.append(_SQL_COUNT_RESOURCEBLOCK_WHERE);
2030
2031 query.append(_FINDER_COLUMN_C_G_N_P_COMPANYID_2);
2032
2033 query.append(_FINDER_COLUMN_C_G_N_P_GROUPID_2);
2034
2035 if (name == null) {
2036 query.append(_FINDER_COLUMN_C_G_N_P_NAME_1);
2037 }
2038 else {
2039 if (name.equals(StringPool.BLANK)) {
2040 query.append(_FINDER_COLUMN_C_G_N_P_NAME_3);
2041 }
2042 else {
2043 query.append(_FINDER_COLUMN_C_G_N_P_NAME_2);
2044 }
2045 }
2046
2047 if (permissionsHash == null) {
2048 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_1);
2049 }
2050 else {
2051 if (permissionsHash.equals(StringPool.BLANK)) {
2052 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_3);
2053 }
2054 else {
2055 query.append(_FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_2);
2056 }
2057 }
2058
2059 String sql = query.toString();
2060
2061 Session session = null;
2062
2063 try {
2064 session = openSession();
2065
2066 Query q = session.createQuery(sql);
2067
2068 QueryPos qPos = QueryPos.getInstance(q);
2069
2070 qPos.add(companyId);
2071
2072 qPos.add(groupId);
2073
2074 if (name != null) {
2075 qPos.add(name);
2076 }
2077
2078 if (permissionsHash != null) {
2079 qPos.add(permissionsHash);
2080 }
2081
2082 count = (Long)q.uniqueResult();
2083 }
2084 catch (Exception e) {
2085 throw processException(e);
2086 }
2087 finally {
2088 if (count == null) {
2089 count = Long.valueOf(0);
2090 }
2091
2092 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_G_N_P,
2093 finderArgs, count);
2094
2095 closeSession(session);
2096 }
2097 }
2098
2099 return count.intValue();
2100 }
2101
2102
2108 public int countAll() throws SystemException {
2109 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2110 FINDER_ARGS_EMPTY, this);
2111
2112 if (count == null) {
2113 Session session = null;
2114
2115 try {
2116 session = openSession();
2117
2118 Query q = session.createQuery(_SQL_COUNT_RESOURCEBLOCK);
2119
2120 count = (Long)q.uniqueResult();
2121 }
2122 catch (Exception e) {
2123 throw processException(e);
2124 }
2125 finally {
2126 if (count == null) {
2127 count = Long.valueOf(0);
2128 }
2129
2130 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2131 FINDER_ARGS_EMPTY, count);
2132
2133 closeSession(session);
2134 }
2135 }
2136
2137 return count.intValue();
2138 }
2139
2140
2143 public void afterPropertiesSet() {
2144 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2145 com.liferay.portal.util.PropsUtil.get(
2146 "value.object.listener.com.liferay.portal.model.ResourceBlock")));
2147
2148 if (listenerClassNames.length > 0) {
2149 try {
2150 List<ModelListener<ResourceBlock>> listenersList = new ArrayList<ModelListener<ResourceBlock>>();
2151
2152 for (String listenerClassName : listenerClassNames) {
2153 listenersList.add((ModelListener<ResourceBlock>)InstanceFactory.newInstance(
2154 listenerClassName));
2155 }
2156
2157 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2158 }
2159 catch (Exception e) {
2160 _log.error(e);
2161 }
2162 }
2163 }
2164
2165 public void destroy() {
2166 EntityCacheUtil.removeCache(ResourceBlockImpl.class.getName());
2167 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2168 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2169 }
2170
2171 @BeanReference(type = AccountPersistence.class)
2172 protected AccountPersistence accountPersistence;
2173 @BeanReference(type = AddressPersistence.class)
2174 protected AddressPersistence addressPersistence;
2175 @BeanReference(type = BrowserTrackerPersistence.class)
2176 protected BrowserTrackerPersistence browserTrackerPersistence;
2177 @BeanReference(type = ClassNamePersistence.class)
2178 protected ClassNamePersistence classNamePersistence;
2179 @BeanReference(type = ClusterGroupPersistence.class)
2180 protected ClusterGroupPersistence clusterGroupPersistence;
2181 @BeanReference(type = CompanyPersistence.class)
2182 protected CompanyPersistence companyPersistence;
2183 @BeanReference(type = ContactPersistence.class)
2184 protected ContactPersistence contactPersistence;
2185 @BeanReference(type = CountryPersistence.class)
2186 protected CountryPersistence countryPersistence;
2187 @BeanReference(type = EmailAddressPersistence.class)
2188 protected EmailAddressPersistence emailAddressPersistence;
2189 @BeanReference(type = GroupPersistence.class)
2190 protected GroupPersistence groupPersistence;
2191 @BeanReference(type = ImagePersistence.class)
2192 protected ImagePersistence imagePersistence;
2193 @BeanReference(type = LayoutPersistence.class)
2194 protected LayoutPersistence layoutPersistence;
2195 @BeanReference(type = LayoutBranchPersistence.class)
2196 protected LayoutBranchPersistence layoutBranchPersistence;
2197 @BeanReference(type = LayoutPrototypePersistence.class)
2198 protected LayoutPrototypePersistence layoutPrototypePersistence;
2199 @BeanReference(type = LayoutRevisionPersistence.class)
2200 protected LayoutRevisionPersistence layoutRevisionPersistence;
2201 @BeanReference(type = LayoutSetPersistence.class)
2202 protected LayoutSetPersistence layoutSetPersistence;
2203 @BeanReference(type = LayoutSetBranchPersistence.class)
2204 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2205 @BeanReference(type = LayoutSetPrototypePersistence.class)
2206 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2207 @BeanReference(type = ListTypePersistence.class)
2208 protected ListTypePersistence listTypePersistence;
2209 @BeanReference(type = LockPersistence.class)
2210 protected LockPersistence lockPersistence;
2211 @BeanReference(type = MembershipRequestPersistence.class)
2212 protected MembershipRequestPersistence membershipRequestPersistence;
2213 @BeanReference(type = OrganizationPersistence.class)
2214 protected OrganizationPersistence organizationPersistence;
2215 @BeanReference(type = OrgGroupPermissionPersistence.class)
2216 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2217 @BeanReference(type = OrgGroupRolePersistence.class)
2218 protected OrgGroupRolePersistence orgGroupRolePersistence;
2219 @BeanReference(type = OrgLaborPersistence.class)
2220 protected OrgLaborPersistence orgLaborPersistence;
2221 @BeanReference(type = PasswordPolicyPersistence.class)
2222 protected PasswordPolicyPersistence passwordPolicyPersistence;
2223 @BeanReference(type = PasswordPolicyRelPersistence.class)
2224 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2225 @BeanReference(type = PasswordTrackerPersistence.class)
2226 protected PasswordTrackerPersistence passwordTrackerPersistence;
2227 @BeanReference(type = PermissionPersistence.class)
2228 protected PermissionPersistence permissionPersistence;
2229 @BeanReference(type = PhonePersistence.class)
2230 protected PhonePersistence phonePersistence;
2231 @BeanReference(type = PluginSettingPersistence.class)
2232 protected PluginSettingPersistence pluginSettingPersistence;
2233 @BeanReference(type = PortalPreferencesPersistence.class)
2234 protected PortalPreferencesPersistence portalPreferencesPersistence;
2235 @BeanReference(type = PortletPersistence.class)
2236 protected PortletPersistence portletPersistence;
2237 @BeanReference(type = PortletItemPersistence.class)
2238 protected PortletItemPersistence portletItemPersistence;
2239 @BeanReference(type = PortletPreferencesPersistence.class)
2240 protected PortletPreferencesPersistence portletPreferencesPersistence;
2241 @BeanReference(type = RegionPersistence.class)
2242 protected RegionPersistence regionPersistence;
2243 @BeanReference(type = ReleasePersistence.class)
2244 protected ReleasePersistence releasePersistence;
2245 @BeanReference(type = RepositoryPersistence.class)
2246 protected RepositoryPersistence repositoryPersistence;
2247 @BeanReference(type = RepositoryEntryPersistence.class)
2248 protected RepositoryEntryPersistence repositoryEntryPersistence;
2249 @BeanReference(type = ResourcePersistence.class)
2250 protected ResourcePersistence resourcePersistence;
2251 @BeanReference(type = ResourceActionPersistence.class)
2252 protected ResourceActionPersistence resourceActionPersistence;
2253 @BeanReference(type = ResourceBlockPersistence.class)
2254 protected ResourceBlockPersistence resourceBlockPersistence;
2255 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2256 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2257 @BeanReference(type = ResourceCodePersistence.class)
2258 protected ResourceCodePersistence resourceCodePersistence;
2259 @BeanReference(type = ResourcePermissionPersistence.class)
2260 protected ResourcePermissionPersistence resourcePermissionPersistence;
2261 @BeanReference(type = ResourceTypePermissionPersistence.class)
2262 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2263 @BeanReference(type = RolePersistence.class)
2264 protected RolePersistence rolePersistence;
2265 @BeanReference(type = ServiceComponentPersistence.class)
2266 protected ServiceComponentPersistence serviceComponentPersistence;
2267 @BeanReference(type = ShardPersistence.class)
2268 protected ShardPersistence shardPersistence;
2269 @BeanReference(type = SubscriptionPersistence.class)
2270 protected SubscriptionPersistence subscriptionPersistence;
2271 @BeanReference(type = TeamPersistence.class)
2272 protected TeamPersistence teamPersistence;
2273 @BeanReference(type = TicketPersistence.class)
2274 protected TicketPersistence ticketPersistence;
2275 @BeanReference(type = UserPersistence.class)
2276 protected UserPersistence userPersistence;
2277 @BeanReference(type = UserGroupPersistence.class)
2278 protected UserGroupPersistence userGroupPersistence;
2279 @BeanReference(type = UserGroupGroupRolePersistence.class)
2280 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2281 @BeanReference(type = UserGroupRolePersistence.class)
2282 protected UserGroupRolePersistence userGroupRolePersistence;
2283 @BeanReference(type = UserIdMapperPersistence.class)
2284 protected UserIdMapperPersistence userIdMapperPersistence;
2285 @BeanReference(type = UserNotificationEventPersistence.class)
2286 protected UserNotificationEventPersistence userNotificationEventPersistence;
2287 @BeanReference(type = UserTrackerPersistence.class)
2288 protected UserTrackerPersistence userTrackerPersistence;
2289 @BeanReference(type = UserTrackerPathPersistence.class)
2290 protected UserTrackerPathPersistence userTrackerPathPersistence;
2291 @BeanReference(type = VirtualHostPersistence.class)
2292 protected VirtualHostPersistence virtualHostPersistence;
2293 @BeanReference(type = WebDAVPropsPersistence.class)
2294 protected WebDAVPropsPersistence webDAVPropsPersistence;
2295 @BeanReference(type = WebsitePersistence.class)
2296 protected WebsitePersistence websitePersistence;
2297 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2298 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2299 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2300 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2301 private static final String _SQL_SELECT_RESOURCEBLOCK = "SELECT resourceBlock FROM ResourceBlock resourceBlock";
2302 private static final String _SQL_SELECT_RESOURCEBLOCK_WHERE = "SELECT resourceBlock FROM ResourceBlock resourceBlock WHERE ";
2303 private static final String _SQL_COUNT_RESOURCEBLOCK = "SELECT COUNT(resourceBlock) FROM ResourceBlock resourceBlock";
2304 private static final String _SQL_COUNT_RESOURCEBLOCK_WHERE = "SELECT COUNT(resourceBlock) FROM ResourceBlock resourceBlock WHERE ";
2305 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "resourceBlock.companyId = ? AND ";
2306 private static final String _FINDER_COLUMN_C_N_NAME_1 = "resourceBlock.name IS NULL";
2307 private static final String _FINDER_COLUMN_C_N_NAME_2 = "resourceBlock.name = ?";
2308 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(resourceBlock.name IS NULL OR resourceBlock.name = ?)";
2309 private static final String _FINDER_COLUMN_C_G_N_COMPANYID_2 = "resourceBlock.companyId = ? AND ";
2310 private static final String _FINDER_COLUMN_C_G_N_GROUPID_2 = "resourceBlock.groupId = ? AND ";
2311 private static final String _FINDER_COLUMN_C_G_N_NAME_1 = "resourceBlock.name IS NULL";
2312 private static final String _FINDER_COLUMN_C_G_N_NAME_2 = "resourceBlock.name = ?";
2313 private static final String _FINDER_COLUMN_C_G_N_NAME_3 = "(resourceBlock.name IS NULL OR resourceBlock.name = ?)";
2314 private static final String _FINDER_COLUMN_C_G_N_P_COMPANYID_2 = "resourceBlock.companyId = ? AND ";
2315 private static final String _FINDER_COLUMN_C_G_N_P_GROUPID_2 = "resourceBlock.groupId = ? AND ";
2316 private static final String _FINDER_COLUMN_C_G_N_P_NAME_1 = "resourceBlock.name IS NULL AND ";
2317 private static final String _FINDER_COLUMN_C_G_N_P_NAME_2 = "resourceBlock.name = ? AND ";
2318 private static final String _FINDER_COLUMN_C_G_N_P_NAME_3 = "(resourceBlock.name IS NULL OR resourceBlock.name = ?) AND ";
2319 private static final String _FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_1 = "resourceBlock.permissionsHash IS NULL";
2320 private static final String _FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_2 = "resourceBlock.permissionsHash = ?";
2321 private static final String _FINDER_COLUMN_C_G_N_P_PERMISSIONSHASH_3 = "(resourceBlock.permissionsHash IS NULL OR resourceBlock.permissionsHash = ?)";
2322 private static final String _ORDER_BY_ENTITY_ALIAS = "resourceBlock.";
2323 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ResourceBlock exists with the primary key ";
2324 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ResourceBlock exists with the key {";
2325 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2326 private static Log _log = LogFactoryUtil.getLog(ResourceBlockPersistenceImpl.class);
2327 private static ResourceBlock _nullResourceBlock = new ResourceBlockImpl() {
2328 @Override
2329 public Object clone() {
2330 return this;
2331 }
2332
2333 @Override
2334 public CacheModel<ResourceBlock> toCacheModel() {
2335 return _nullResourceBlockCacheModel;
2336 }
2337 };
2338
2339 private static CacheModel<ResourceBlock> _nullResourceBlockCacheModel = new CacheModel<ResourceBlock>() {
2340 public ResourceBlock toEntityModel() {
2341 return _nullResourceBlock;
2342 }
2343 };
2344 }