001
014
015 package com.liferay.portlet.dynamicdatamapping.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.dynamicdatamapping.NoSuchStructureLinkException;
044 import com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink;
045 import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureLinkImpl;
046 import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureLinkModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class DDMStructureLinkPersistenceImpl extends BasePersistenceImpl<DDMStructureLink>
067 implements DDMStructureLinkPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = DDMStructureLinkImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
079 new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
080 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
081 DDMStructureLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082 "findByClassNameId",
083 new String[] {
084 Long.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
090 new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
091 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
092 DDMStructureLinkImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
094 new String[] { Long.class.getName() },
095 DDMStructureLinkModelImpl.CLASSNAMEID_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
097 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
099 new String[] { Long.class.getName() });
100 public static final FinderPath FINDER_PATH_FETCH_BY_CLASSPK = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
101 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
102 DDMStructureLinkImpl.class, FINDER_CLASS_NAME_ENTITY,
103 "fetchByClassPK", new String[] { Long.class.getName() },
104 DDMStructureLinkModelImpl.CLASSPK_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_CLASSPK = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
106 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassPK",
108 new String[] { Long.class.getName() });
109 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
110 new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
111 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
112 DDMStructureLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
113 "findByStructureId",
114 new String[] {
115 Long.class.getName(),
116
117 "java.lang.Integer", "java.lang.Integer",
118 "com.liferay.portal.kernel.util.OrderByComparator"
119 });
120 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
121 new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
122 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
123 DDMStructureLinkImpl.class,
124 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
125 new String[] { Long.class.getName() },
126 DDMStructureLinkModelImpl.STRUCTUREID_COLUMN_BITMASK);
127 public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
128 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
130 new String[] { Long.class.getName() });
131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
132 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
133 DDMStructureLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
134 "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
136 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED,
137 DDMStructureLinkImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
140 DDMStructureLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
142
143
148 public void cacheResult(DDMStructureLink ddmStructureLink) {
149 EntityCacheUtil.putResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
150 DDMStructureLinkImpl.class, ddmStructureLink.getPrimaryKey(),
151 ddmStructureLink);
152
153 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
154 new Object[] { Long.valueOf(ddmStructureLink.getClassPK()) },
155 ddmStructureLink);
156
157 ddmStructureLink.resetOriginalValues();
158 }
159
160
165 public void cacheResult(List<DDMStructureLink> ddmStructureLinks) {
166 for (DDMStructureLink ddmStructureLink : ddmStructureLinks) {
167 if (EntityCacheUtil.getResult(
168 DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
169 DDMStructureLinkImpl.class,
170 ddmStructureLink.getPrimaryKey()) == null) {
171 cacheResult(ddmStructureLink);
172 }
173 else {
174 ddmStructureLink.resetOriginalValues();
175 }
176 }
177 }
178
179
186 @Override
187 public void clearCache() {
188 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
189 CacheRegistryUtil.clear(DDMStructureLinkImpl.class.getName());
190 }
191
192 EntityCacheUtil.clearCache(DDMStructureLinkImpl.class.getName());
193
194 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
197 }
198
199
206 @Override
207 public void clearCache(DDMStructureLink ddmStructureLink) {
208 EntityCacheUtil.removeResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
209 DDMStructureLinkImpl.class, ddmStructureLink.getPrimaryKey());
210
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
213
214 clearUniqueFindersCache(ddmStructureLink);
215 }
216
217 @Override
218 public void clearCache(List<DDMStructureLink> ddmStructureLinks) {
219 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
221
222 for (DDMStructureLink ddmStructureLink : ddmStructureLinks) {
223 EntityCacheUtil.removeResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
224 DDMStructureLinkImpl.class, ddmStructureLink.getPrimaryKey());
225
226 clearUniqueFindersCache(ddmStructureLink);
227 }
228 }
229
230 protected void cacheUniqueFindersCache(DDMStructureLink ddmStructureLink) {
231 if (ddmStructureLink.isNew()) {
232 Object[] args = new Object[] {
233 Long.valueOf(ddmStructureLink.getClassPK())
234 };
235
236 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSPK, args,
237 Long.valueOf(1));
238 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK, args,
239 ddmStructureLink);
240 }
241 else {
242 DDMStructureLinkModelImpl ddmStructureLinkModelImpl = (DDMStructureLinkModelImpl)ddmStructureLink;
243
244 if ((ddmStructureLinkModelImpl.getColumnBitmask() &
245 FINDER_PATH_FETCH_BY_CLASSPK.getColumnBitmask()) != 0) {
246 Object[] args = new Object[] {
247 Long.valueOf(ddmStructureLink.getClassPK())
248 };
249
250 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSPK, args,
251 Long.valueOf(1));
252 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK, args,
253 ddmStructureLink);
254 }
255 }
256 }
257
258 protected void clearUniqueFindersCache(DDMStructureLink ddmStructureLink) {
259 DDMStructureLinkModelImpl ddmStructureLinkModelImpl = (DDMStructureLinkModelImpl)ddmStructureLink;
260
261 Object[] args = new Object[] { Long.valueOf(ddmStructureLink.getClassPK()) };
262
263 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSPK, args);
264 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK, args);
265
266 if ((ddmStructureLinkModelImpl.getColumnBitmask() &
267 FINDER_PATH_FETCH_BY_CLASSPK.getColumnBitmask()) != 0) {
268 args = new Object[] {
269 Long.valueOf(ddmStructureLinkModelImpl.getOriginalClassPK())
270 };
271
272 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSPK, args);
273 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK, args);
274 }
275 }
276
277
283 public DDMStructureLink create(long structureLinkId) {
284 DDMStructureLink ddmStructureLink = new DDMStructureLinkImpl();
285
286 ddmStructureLink.setNew(true);
287 ddmStructureLink.setPrimaryKey(structureLinkId);
288
289 return ddmStructureLink;
290 }
291
292
300 public DDMStructureLink remove(long structureLinkId)
301 throws NoSuchStructureLinkException, SystemException {
302 return remove(Long.valueOf(structureLinkId));
303 }
304
305
313 @Override
314 public DDMStructureLink remove(Serializable primaryKey)
315 throws NoSuchStructureLinkException, SystemException {
316 Session session = null;
317
318 try {
319 session = openSession();
320
321 DDMStructureLink ddmStructureLink = (DDMStructureLink)session.get(DDMStructureLinkImpl.class,
322 primaryKey);
323
324 if (ddmStructureLink == null) {
325 if (_log.isWarnEnabled()) {
326 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
327 }
328
329 throw new NoSuchStructureLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
330 primaryKey);
331 }
332
333 return remove(ddmStructureLink);
334 }
335 catch (NoSuchStructureLinkException nsee) {
336 throw nsee;
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 closeSession(session);
343 }
344 }
345
346 @Override
347 protected DDMStructureLink removeImpl(DDMStructureLink ddmStructureLink)
348 throws SystemException {
349 ddmStructureLink = toUnwrappedModel(ddmStructureLink);
350
351 Session session = null;
352
353 try {
354 session = openSession();
355
356 BatchSessionUtil.delete(session, ddmStructureLink);
357 }
358 catch (Exception e) {
359 throw processException(e);
360 }
361 finally {
362 closeSession(session);
363 }
364
365 clearCache(ddmStructureLink);
366
367 return ddmStructureLink;
368 }
369
370 @Override
371 public DDMStructureLink updateImpl(
372 com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink ddmStructureLink,
373 boolean merge) throws SystemException {
374 ddmStructureLink = toUnwrappedModel(ddmStructureLink);
375
376 boolean isNew = ddmStructureLink.isNew();
377
378 DDMStructureLinkModelImpl ddmStructureLinkModelImpl = (DDMStructureLinkModelImpl)ddmStructureLink;
379
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 BatchSessionUtil.update(session, ddmStructureLink, merge);
386
387 ddmStructureLink.setNew(false);
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 closeSession(session);
394 }
395
396 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
397
398 if (isNew || !DDMStructureLinkModelImpl.COLUMN_BITMASK_ENABLED) {
399 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
400 }
401
402 else {
403 if ((ddmStructureLinkModelImpl.getColumnBitmask() &
404 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
405 Object[] args = new Object[] {
406 Long.valueOf(ddmStructureLinkModelImpl.getOriginalClassNameId())
407 };
408
409 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
410 args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
412 args);
413
414 args = new Object[] {
415 Long.valueOf(ddmStructureLinkModelImpl.getClassNameId())
416 };
417
418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
419 args);
420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
421 args);
422 }
423
424 if ((ddmStructureLinkModelImpl.getColumnBitmask() &
425 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
426 Object[] args = new Object[] {
427 Long.valueOf(ddmStructureLinkModelImpl.getOriginalStructureId())
428 };
429
430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
431 args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
433 args);
434
435 args = new Object[] {
436 Long.valueOf(ddmStructureLinkModelImpl.getStructureId())
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
440 args);
441 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
442 args);
443 }
444 }
445
446 EntityCacheUtil.putResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
447 DDMStructureLinkImpl.class, ddmStructureLink.getPrimaryKey(),
448 ddmStructureLink);
449
450 clearUniqueFindersCache(ddmStructureLink);
451 cacheUniqueFindersCache(ddmStructureLink);
452
453 return ddmStructureLink;
454 }
455
456 protected DDMStructureLink toUnwrappedModel(
457 DDMStructureLink ddmStructureLink) {
458 if (ddmStructureLink instanceof DDMStructureLinkImpl) {
459 return ddmStructureLink;
460 }
461
462 DDMStructureLinkImpl ddmStructureLinkImpl = new DDMStructureLinkImpl();
463
464 ddmStructureLinkImpl.setNew(ddmStructureLink.isNew());
465 ddmStructureLinkImpl.setPrimaryKey(ddmStructureLink.getPrimaryKey());
466
467 ddmStructureLinkImpl.setStructureLinkId(ddmStructureLink.getStructureLinkId());
468 ddmStructureLinkImpl.setClassNameId(ddmStructureLink.getClassNameId());
469 ddmStructureLinkImpl.setClassPK(ddmStructureLink.getClassPK());
470 ddmStructureLinkImpl.setStructureId(ddmStructureLink.getStructureId());
471
472 return ddmStructureLinkImpl;
473 }
474
475
483 @Override
484 public DDMStructureLink findByPrimaryKey(Serializable primaryKey)
485 throws NoSuchModelException, SystemException {
486 return findByPrimaryKey(((Long)primaryKey).longValue());
487 }
488
489
497 public DDMStructureLink findByPrimaryKey(long structureLinkId)
498 throws NoSuchStructureLinkException, SystemException {
499 DDMStructureLink ddmStructureLink = fetchByPrimaryKey(structureLinkId);
500
501 if (ddmStructureLink == null) {
502 if (_log.isWarnEnabled()) {
503 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + structureLinkId);
504 }
505
506 throw new NoSuchStructureLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
507 structureLinkId);
508 }
509
510 return ddmStructureLink;
511 }
512
513
520 @Override
521 public DDMStructureLink fetchByPrimaryKey(Serializable primaryKey)
522 throws SystemException {
523 return fetchByPrimaryKey(((Long)primaryKey).longValue());
524 }
525
526
533 public DDMStructureLink fetchByPrimaryKey(long structureLinkId)
534 throws SystemException {
535 DDMStructureLink ddmStructureLink = (DDMStructureLink)EntityCacheUtil.getResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
536 DDMStructureLinkImpl.class, structureLinkId);
537
538 if (ddmStructureLink == _nullDDMStructureLink) {
539 return null;
540 }
541
542 if (ddmStructureLink == null) {
543 Session session = null;
544
545 boolean hasException = false;
546
547 try {
548 session = openSession();
549
550 ddmStructureLink = (DDMStructureLink)session.get(DDMStructureLinkImpl.class,
551 Long.valueOf(structureLinkId));
552 }
553 catch (Exception e) {
554 hasException = true;
555
556 throw processException(e);
557 }
558 finally {
559 if (ddmStructureLink != null) {
560 cacheResult(ddmStructureLink);
561 }
562 else if (!hasException) {
563 EntityCacheUtil.putResult(DDMStructureLinkModelImpl.ENTITY_CACHE_ENABLED,
564 DDMStructureLinkImpl.class, structureLinkId,
565 _nullDDMStructureLink);
566 }
567
568 closeSession(session);
569 }
570 }
571
572 return ddmStructureLink;
573 }
574
575
582 public List<DDMStructureLink> findByClassNameId(long classNameId)
583 throws SystemException {
584 return findByClassNameId(classNameId, QueryUtil.ALL_POS,
585 QueryUtil.ALL_POS, null);
586 }
587
588
601 public List<DDMStructureLink> findByClassNameId(long classNameId,
602 int start, int end) throws SystemException {
603 return findByClassNameId(classNameId, start, end, null);
604 }
605
606
620 public List<DDMStructureLink> findByClassNameId(long classNameId,
621 int start, int end, OrderByComparator orderByComparator)
622 throws SystemException {
623 FinderPath finderPath = null;
624 Object[] finderArgs = null;
625
626 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
627 (orderByComparator == null)) {
628 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
629 finderArgs = new Object[] { classNameId };
630 }
631 else {
632 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
633 finderArgs = new Object[] { classNameId, start, end, orderByComparator };
634 }
635
636 List<DDMStructureLink> list = (List<DDMStructureLink>)FinderCacheUtil.getResult(finderPath,
637 finderArgs, this);
638
639 if ((list != null) && !list.isEmpty()) {
640 for (DDMStructureLink ddmStructureLink : list) {
641 if ((classNameId != ddmStructureLink.getClassNameId())) {
642 list = null;
643
644 break;
645 }
646 }
647 }
648
649 if (list == null) {
650 StringBundler query = null;
651
652 if (orderByComparator != null) {
653 query = new StringBundler(3 +
654 (orderByComparator.getOrderByFields().length * 3));
655 }
656 else {
657 query = new StringBundler(2);
658 }
659
660 query.append(_SQL_SELECT_DDMSTRUCTURELINK_WHERE);
661
662 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
663
664 if (orderByComparator != null) {
665 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
666 orderByComparator);
667 }
668
669 String sql = query.toString();
670
671 Session session = null;
672
673 try {
674 session = openSession();
675
676 Query q = session.createQuery(sql);
677
678 QueryPos qPos = QueryPos.getInstance(q);
679
680 qPos.add(classNameId);
681
682 list = (List<DDMStructureLink>)QueryUtil.list(q, getDialect(),
683 start, end);
684 }
685 catch (Exception e) {
686 throw processException(e);
687 }
688 finally {
689 if (list == null) {
690 FinderCacheUtil.removeResult(finderPath, finderArgs);
691 }
692 else {
693 cacheResult(list);
694
695 FinderCacheUtil.putResult(finderPath, finderArgs, list);
696 }
697
698 closeSession(session);
699 }
700 }
701
702 return list;
703 }
704
705
714 public DDMStructureLink findByClassNameId_First(long classNameId,
715 OrderByComparator orderByComparator)
716 throws NoSuchStructureLinkException, SystemException {
717 DDMStructureLink ddmStructureLink = fetchByClassNameId_First(classNameId,
718 orderByComparator);
719
720 if (ddmStructureLink != null) {
721 return ddmStructureLink;
722 }
723
724 StringBundler msg = new StringBundler(4);
725
726 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
727
728 msg.append("classNameId=");
729 msg.append(classNameId);
730
731 msg.append(StringPool.CLOSE_CURLY_BRACE);
732
733 throw new NoSuchStructureLinkException(msg.toString());
734 }
735
736
744 public DDMStructureLink fetchByClassNameId_First(long classNameId,
745 OrderByComparator orderByComparator) throws SystemException {
746 List<DDMStructureLink> list = findByClassNameId(classNameId, 0, 1,
747 orderByComparator);
748
749 if (!list.isEmpty()) {
750 return list.get(0);
751 }
752
753 return null;
754 }
755
756
765 public DDMStructureLink findByClassNameId_Last(long classNameId,
766 OrderByComparator orderByComparator)
767 throws NoSuchStructureLinkException, SystemException {
768 DDMStructureLink ddmStructureLink = fetchByClassNameId_Last(classNameId,
769 orderByComparator);
770
771 if (ddmStructureLink != null) {
772 return ddmStructureLink;
773 }
774
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("classNameId=");
780 msg.append(classNameId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchStructureLinkException(msg.toString());
785 }
786
787
795 public DDMStructureLink fetchByClassNameId_Last(long classNameId,
796 OrderByComparator orderByComparator) throws SystemException {
797 int count = countByClassNameId(classNameId);
798
799 List<DDMStructureLink> list = findByClassNameId(classNameId, count - 1,
800 count, orderByComparator);
801
802 if (!list.isEmpty()) {
803 return list.get(0);
804 }
805
806 return null;
807 }
808
809
819 public DDMStructureLink[] findByClassNameId_PrevAndNext(
820 long structureLinkId, long classNameId,
821 OrderByComparator orderByComparator)
822 throws NoSuchStructureLinkException, SystemException {
823 DDMStructureLink ddmStructureLink = findByPrimaryKey(structureLinkId);
824
825 Session session = null;
826
827 try {
828 session = openSession();
829
830 DDMStructureLink[] array = new DDMStructureLinkImpl[3];
831
832 array[0] = getByClassNameId_PrevAndNext(session, ddmStructureLink,
833 classNameId, orderByComparator, true);
834
835 array[1] = ddmStructureLink;
836
837 array[2] = getByClassNameId_PrevAndNext(session, ddmStructureLink,
838 classNameId, orderByComparator, false);
839
840 return array;
841 }
842 catch (Exception e) {
843 throw processException(e);
844 }
845 finally {
846 closeSession(session);
847 }
848 }
849
850 protected DDMStructureLink getByClassNameId_PrevAndNext(Session session,
851 DDMStructureLink ddmStructureLink, long classNameId,
852 OrderByComparator orderByComparator, boolean previous) {
853 StringBundler query = null;
854
855 if (orderByComparator != null) {
856 query = new StringBundler(6 +
857 (orderByComparator.getOrderByFields().length * 6));
858 }
859 else {
860 query = new StringBundler(3);
861 }
862
863 query.append(_SQL_SELECT_DDMSTRUCTURELINK_WHERE);
864
865 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
866
867 if (orderByComparator != null) {
868 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
869
870 if (orderByConditionFields.length > 0) {
871 query.append(WHERE_AND);
872 }
873
874 for (int i = 0; i < orderByConditionFields.length; i++) {
875 query.append(_ORDER_BY_ENTITY_ALIAS);
876 query.append(orderByConditionFields[i]);
877
878 if ((i + 1) < orderByConditionFields.length) {
879 if (orderByComparator.isAscending() ^ previous) {
880 query.append(WHERE_GREATER_THAN_HAS_NEXT);
881 }
882 else {
883 query.append(WHERE_LESSER_THAN_HAS_NEXT);
884 }
885 }
886 else {
887 if (orderByComparator.isAscending() ^ previous) {
888 query.append(WHERE_GREATER_THAN);
889 }
890 else {
891 query.append(WHERE_LESSER_THAN);
892 }
893 }
894 }
895
896 query.append(ORDER_BY_CLAUSE);
897
898 String[] orderByFields = orderByComparator.getOrderByFields();
899
900 for (int i = 0; i < orderByFields.length; i++) {
901 query.append(_ORDER_BY_ENTITY_ALIAS);
902 query.append(orderByFields[i]);
903
904 if ((i + 1) < orderByFields.length) {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(ORDER_BY_ASC_HAS_NEXT);
907 }
908 else {
909 query.append(ORDER_BY_DESC_HAS_NEXT);
910 }
911 }
912 else {
913 if (orderByComparator.isAscending() ^ previous) {
914 query.append(ORDER_BY_ASC);
915 }
916 else {
917 query.append(ORDER_BY_DESC);
918 }
919 }
920 }
921 }
922
923 String sql = query.toString();
924
925 Query q = session.createQuery(sql);
926
927 q.setFirstResult(0);
928 q.setMaxResults(2);
929
930 QueryPos qPos = QueryPos.getInstance(q);
931
932 qPos.add(classNameId);
933
934 if (orderByComparator != null) {
935 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructureLink);
936
937 for (Object value : values) {
938 qPos.add(value);
939 }
940 }
941
942 List<DDMStructureLink> list = q.list();
943
944 if (list.size() == 2) {
945 return list.get(1);
946 }
947 else {
948 return null;
949 }
950 }
951
952
960 public DDMStructureLink findByClassPK(long classPK)
961 throws NoSuchStructureLinkException, SystemException {
962 DDMStructureLink ddmStructureLink = fetchByClassPK(classPK);
963
964 if (ddmStructureLink == null) {
965 StringBundler msg = new StringBundler(4);
966
967 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
968
969 msg.append("classPK=");
970 msg.append(classPK);
971
972 msg.append(StringPool.CLOSE_CURLY_BRACE);
973
974 if (_log.isWarnEnabled()) {
975 _log.warn(msg.toString());
976 }
977
978 throw new NoSuchStructureLinkException(msg.toString());
979 }
980
981 return ddmStructureLink;
982 }
983
984
991 public DDMStructureLink fetchByClassPK(long classPK)
992 throws SystemException {
993 return fetchByClassPK(classPK, true);
994 }
995
996
1004 public DDMStructureLink fetchByClassPK(long classPK,
1005 boolean retrieveFromCache) throws SystemException {
1006 Object[] finderArgs = new Object[] { classPK };
1007
1008 Object result = null;
1009
1010 if (retrieveFromCache) {
1011 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CLASSPK,
1012 finderArgs, this);
1013 }
1014
1015 if (result instanceof DDMStructureLink) {
1016 DDMStructureLink ddmStructureLink = (DDMStructureLink)result;
1017
1018 if ((classPK != ddmStructureLink.getClassPK())) {
1019 result = null;
1020 }
1021 }
1022
1023 if (result == null) {
1024 StringBundler query = new StringBundler(2);
1025
1026 query.append(_SQL_SELECT_DDMSTRUCTURELINK_WHERE);
1027
1028 query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1029
1030 String sql = query.toString();
1031
1032 Session session = null;
1033
1034 try {
1035 session = openSession();
1036
1037 Query q = session.createQuery(sql);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(classPK);
1042
1043 List<DDMStructureLink> list = q.list();
1044
1045 result = list;
1046
1047 DDMStructureLink ddmStructureLink = null;
1048
1049 if (list.isEmpty()) {
1050 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1051 finderArgs, list);
1052 }
1053 else {
1054 ddmStructureLink = list.get(0);
1055
1056 cacheResult(ddmStructureLink);
1057
1058 if ((ddmStructureLink.getClassPK() != classPK)) {
1059 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1060 finderArgs, ddmStructureLink);
1061 }
1062 }
1063
1064 return ddmStructureLink;
1065 }
1066 catch (Exception e) {
1067 throw processException(e);
1068 }
1069 finally {
1070 if (result == null) {
1071 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK,
1072 finderArgs);
1073 }
1074
1075 closeSession(session);
1076 }
1077 }
1078 else {
1079 if (result instanceof List<?>) {
1080 return null;
1081 }
1082 else {
1083 return (DDMStructureLink)result;
1084 }
1085 }
1086 }
1087
1088
1095 public List<DDMStructureLink> findByStructureId(long structureId)
1096 throws SystemException {
1097 return findByStructureId(structureId, QueryUtil.ALL_POS,
1098 QueryUtil.ALL_POS, null);
1099 }
1100
1101
1114 public List<DDMStructureLink> findByStructureId(long structureId,
1115 int start, int end) throws SystemException {
1116 return findByStructureId(structureId, start, end, null);
1117 }
1118
1119
1133 public List<DDMStructureLink> findByStructureId(long structureId,
1134 int start, int end, OrderByComparator orderByComparator)
1135 throws SystemException {
1136 FinderPath finderPath = null;
1137 Object[] finderArgs = null;
1138
1139 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1140 (orderByComparator == null)) {
1141 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
1142 finderArgs = new Object[] { structureId };
1143 }
1144 else {
1145 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
1146 finderArgs = new Object[] { structureId, start, end, orderByComparator };
1147 }
1148
1149 List<DDMStructureLink> list = (List<DDMStructureLink>)FinderCacheUtil.getResult(finderPath,
1150 finderArgs, this);
1151
1152 if ((list != null) && !list.isEmpty()) {
1153 for (DDMStructureLink ddmStructureLink : list) {
1154 if ((structureId != ddmStructureLink.getStructureId())) {
1155 list = null;
1156
1157 break;
1158 }
1159 }
1160 }
1161
1162 if (list == null) {
1163 StringBundler query = null;
1164
1165 if (orderByComparator != null) {
1166 query = new StringBundler(3 +
1167 (orderByComparator.getOrderByFields().length * 3));
1168 }
1169 else {
1170 query = new StringBundler(2);
1171 }
1172
1173 query.append(_SQL_SELECT_DDMSTRUCTURELINK_WHERE);
1174
1175 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1176
1177 if (orderByComparator != null) {
1178 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1179 orderByComparator);
1180 }
1181
1182 String sql = query.toString();
1183
1184 Session session = null;
1185
1186 try {
1187 session = openSession();
1188
1189 Query q = session.createQuery(sql);
1190
1191 QueryPos qPos = QueryPos.getInstance(q);
1192
1193 qPos.add(structureId);
1194
1195 list = (List<DDMStructureLink>)QueryUtil.list(q, getDialect(),
1196 start, end);
1197 }
1198 catch (Exception e) {
1199 throw processException(e);
1200 }
1201 finally {
1202 if (list == null) {
1203 FinderCacheUtil.removeResult(finderPath, finderArgs);
1204 }
1205 else {
1206 cacheResult(list);
1207
1208 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1209 }
1210
1211 closeSession(session);
1212 }
1213 }
1214
1215 return list;
1216 }
1217
1218
1227 public DDMStructureLink findByStructureId_First(long structureId,
1228 OrderByComparator orderByComparator)
1229 throws NoSuchStructureLinkException, SystemException {
1230 DDMStructureLink ddmStructureLink = fetchByStructureId_First(structureId,
1231 orderByComparator);
1232
1233 if (ddmStructureLink != null) {
1234 return ddmStructureLink;
1235 }
1236
1237 StringBundler msg = new StringBundler(4);
1238
1239 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240
1241 msg.append("structureId=");
1242 msg.append(structureId);
1243
1244 msg.append(StringPool.CLOSE_CURLY_BRACE);
1245
1246 throw new NoSuchStructureLinkException(msg.toString());
1247 }
1248
1249
1257 public DDMStructureLink fetchByStructureId_First(long structureId,
1258 OrderByComparator orderByComparator) throws SystemException {
1259 List<DDMStructureLink> list = findByStructureId(structureId, 0, 1,
1260 orderByComparator);
1261
1262 if (!list.isEmpty()) {
1263 return list.get(0);
1264 }
1265
1266 return null;
1267 }
1268
1269
1278 public DDMStructureLink findByStructureId_Last(long structureId,
1279 OrderByComparator orderByComparator)
1280 throws NoSuchStructureLinkException, SystemException {
1281 DDMStructureLink ddmStructureLink = fetchByStructureId_Last(structureId,
1282 orderByComparator);
1283
1284 if (ddmStructureLink != null) {
1285 return ddmStructureLink;
1286 }
1287
1288 StringBundler msg = new StringBundler(4);
1289
1290 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1291
1292 msg.append("structureId=");
1293 msg.append(structureId);
1294
1295 msg.append(StringPool.CLOSE_CURLY_BRACE);
1296
1297 throw new NoSuchStructureLinkException(msg.toString());
1298 }
1299
1300
1308 public DDMStructureLink fetchByStructureId_Last(long structureId,
1309 OrderByComparator orderByComparator) throws SystemException {
1310 int count = countByStructureId(structureId);
1311
1312 List<DDMStructureLink> list = findByStructureId(structureId, count - 1,
1313 count, orderByComparator);
1314
1315 if (!list.isEmpty()) {
1316 return list.get(0);
1317 }
1318
1319 return null;
1320 }
1321
1322
1332 public DDMStructureLink[] findByStructureId_PrevAndNext(
1333 long structureLinkId, long structureId,
1334 OrderByComparator orderByComparator)
1335 throws NoSuchStructureLinkException, SystemException {
1336 DDMStructureLink ddmStructureLink = findByPrimaryKey(structureLinkId);
1337
1338 Session session = null;
1339
1340 try {
1341 session = openSession();
1342
1343 DDMStructureLink[] array = new DDMStructureLinkImpl[3];
1344
1345 array[0] = getByStructureId_PrevAndNext(session, ddmStructureLink,
1346 structureId, orderByComparator, true);
1347
1348 array[1] = ddmStructureLink;
1349
1350 array[2] = getByStructureId_PrevAndNext(session, ddmStructureLink,
1351 structureId, orderByComparator, false);
1352
1353 return array;
1354 }
1355 catch (Exception e) {
1356 throw processException(e);
1357 }
1358 finally {
1359 closeSession(session);
1360 }
1361 }
1362
1363 protected DDMStructureLink getByStructureId_PrevAndNext(Session session,
1364 DDMStructureLink ddmStructureLink, long structureId,
1365 OrderByComparator orderByComparator, boolean previous) {
1366 StringBundler query = null;
1367
1368 if (orderByComparator != null) {
1369 query = new StringBundler(6 +
1370 (orderByComparator.getOrderByFields().length * 6));
1371 }
1372 else {
1373 query = new StringBundler(3);
1374 }
1375
1376 query.append(_SQL_SELECT_DDMSTRUCTURELINK_WHERE);
1377
1378 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1379
1380 if (orderByComparator != null) {
1381 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1382
1383 if (orderByConditionFields.length > 0) {
1384 query.append(WHERE_AND);
1385 }
1386
1387 for (int i = 0; i < orderByConditionFields.length; i++) {
1388 query.append(_ORDER_BY_ENTITY_ALIAS);
1389 query.append(orderByConditionFields[i]);
1390
1391 if ((i + 1) < orderByConditionFields.length) {
1392 if (orderByComparator.isAscending() ^ previous) {
1393 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1394 }
1395 else {
1396 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1397 }
1398 }
1399 else {
1400 if (orderByComparator.isAscending() ^ previous) {
1401 query.append(WHERE_GREATER_THAN);
1402 }
1403 else {
1404 query.append(WHERE_LESSER_THAN);
1405 }
1406 }
1407 }
1408
1409 query.append(ORDER_BY_CLAUSE);
1410
1411 String[] orderByFields = orderByComparator.getOrderByFields();
1412
1413 for (int i = 0; i < orderByFields.length; i++) {
1414 query.append(_ORDER_BY_ENTITY_ALIAS);
1415 query.append(orderByFields[i]);
1416
1417 if ((i + 1) < orderByFields.length) {
1418 if (orderByComparator.isAscending() ^ previous) {
1419 query.append(ORDER_BY_ASC_HAS_NEXT);
1420 }
1421 else {
1422 query.append(ORDER_BY_DESC_HAS_NEXT);
1423 }
1424 }
1425 else {
1426 if (orderByComparator.isAscending() ^ previous) {
1427 query.append(ORDER_BY_ASC);
1428 }
1429 else {
1430 query.append(ORDER_BY_DESC);
1431 }
1432 }
1433 }
1434 }
1435
1436 String sql = query.toString();
1437
1438 Query q = session.createQuery(sql);
1439
1440 q.setFirstResult(0);
1441 q.setMaxResults(2);
1442
1443 QueryPos qPos = QueryPos.getInstance(q);
1444
1445 qPos.add(structureId);
1446
1447 if (orderByComparator != null) {
1448 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructureLink);
1449
1450 for (Object value : values) {
1451 qPos.add(value);
1452 }
1453 }
1454
1455 List<DDMStructureLink> list = q.list();
1456
1457 if (list.size() == 2) {
1458 return list.get(1);
1459 }
1460 else {
1461 return null;
1462 }
1463 }
1464
1465
1471 public List<DDMStructureLink> findAll() throws SystemException {
1472 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1473 }
1474
1475
1487 public List<DDMStructureLink> findAll(int start, int end)
1488 throws SystemException {
1489 return findAll(start, end, null);
1490 }
1491
1492
1505 public List<DDMStructureLink> findAll(int start, int end,
1506 OrderByComparator orderByComparator) throws SystemException {
1507 FinderPath finderPath = null;
1508 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1509
1510 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1511 (orderByComparator == null)) {
1512 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1513 finderArgs = FINDER_ARGS_EMPTY;
1514 }
1515 else {
1516 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1517 finderArgs = new Object[] { start, end, orderByComparator };
1518 }
1519
1520 List<DDMStructureLink> list = (List<DDMStructureLink>)FinderCacheUtil.getResult(finderPath,
1521 finderArgs, this);
1522
1523 if (list == null) {
1524 StringBundler query = null;
1525 String sql = null;
1526
1527 if (orderByComparator != null) {
1528 query = new StringBundler(2 +
1529 (orderByComparator.getOrderByFields().length * 3));
1530
1531 query.append(_SQL_SELECT_DDMSTRUCTURELINK);
1532
1533 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1534 orderByComparator);
1535
1536 sql = query.toString();
1537 }
1538 else {
1539 sql = _SQL_SELECT_DDMSTRUCTURELINK;
1540 }
1541
1542 Session session = null;
1543
1544 try {
1545 session = openSession();
1546
1547 Query q = session.createQuery(sql);
1548
1549 if (orderByComparator == null) {
1550 list = (List<DDMStructureLink>)QueryUtil.list(q,
1551 getDialect(), start, end, false);
1552
1553 Collections.sort(list);
1554 }
1555 else {
1556 list = (List<DDMStructureLink>)QueryUtil.list(q,
1557 getDialect(), start, end);
1558 }
1559 }
1560 catch (Exception e) {
1561 throw processException(e);
1562 }
1563 finally {
1564 if (list == null) {
1565 FinderCacheUtil.removeResult(finderPath, finderArgs);
1566 }
1567 else {
1568 cacheResult(list);
1569
1570 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1571 }
1572
1573 closeSession(session);
1574 }
1575 }
1576
1577 return list;
1578 }
1579
1580
1586 public void removeByClassNameId(long classNameId) throws SystemException {
1587 for (DDMStructureLink ddmStructureLink : findByClassNameId(classNameId)) {
1588 remove(ddmStructureLink);
1589 }
1590 }
1591
1592
1599 public DDMStructureLink removeByClassPK(long classPK)
1600 throws NoSuchStructureLinkException, SystemException {
1601 DDMStructureLink ddmStructureLink = findByClassPK(classPK);
1602
1603 return remove(ddmStructureLink);
1604 }
1605
1606
1612 public void removeByStructureId(long structureId) throws SystemException {
1613 for (DDMStructureLink ddmStructureLink : findByStructureId(structureId)) {
1614 remove(ddmStructureLink);
1615 }
1616 }
1617
1618
1623 public void removeAll() throws SystemException {
1624 for (DDMStructureLink ddmStructureLink : findAll()) {
1625 remove(ddmStructureLink);
1626 }
1627 }
1628
1629
1636 public int countByClassNameId(long classNameId) throws SystemException {
1637 Object[] finderArgs = new Object[] { classNameId };
1638
1639 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
1640 finderArgs, this);
1641
1642 if (count == null) {
1643 StringBundler query = new StringBundler(2);
1644
1645 query.append(_SQL_COUNT_DDMSTRUCTURELINK_WHERE);
1646
1647 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1648
1649 String sql = query.toString();
1650
1651 Session session = null;
1652
1653 try {
1654 session = openSession();
1655
1656 Query q = session.createQuery(sql);
1657
1658 QueryPos qPos = QueryPos.getInstance(q);
1659
1660 qPos.add(classNameId);
1661
1662 count = (Long)q.uniqueResult();
1663 }
1664 catch (Exception e) {
1665 throw processException(e);
1666 }
1667 finally {
1668 if (count == null) {
1669 count = Long.valueOf(0);
1670 }
1671
1672 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
1673 finderArgs, count);
1674
1675 closeSession(session);
1676 }
1677 }
1678
1679 return count.intValue();
1680 }
1681
1682
1689 public int countByClassPK(long classPK) throws SystemException {
1690 Object[] finderArgs = new Object[] { classPK };
1691
1692 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSPK,
1693 finderArgs, this);
1694
1695 if (count == null) {
1696 StringBundler query = new StringBundler(2);
1697
1698 query.append(_SQL_COUNT_DDMSTRUCTURELINK_WHERE);
1699
1700 query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1701
1702 String sql = query.toString();
1703
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 Query q = session.createQuery(sql);
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(classPK);
1714
1715 count = (Long)q.uniqueResult();
1716 }
1717 catch (Exception e) {
1718 throw processException(e);
1719 }
1720 finally {
1721 if (count == null) {
1722 count = Long.valueOf(0);
1723 }
1724
1725 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSPK,
1726 finderArgs, count);
1727
1728 closeSession(session);
1729 }
1730 }
1731
1732 return count.intValue();
1733 }
1734
1735
1742 public int countByStructureId(long structureId) throws SystemException {
1743 Object[] finderArgs = new Object[] { structureId };
1744
1745 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1746 finderArgs, this);
1747
1748 if (count == null) {
1749 StringBundler query = new StringBundler(2);
1750
1751 query.append(_SQL_COUNT_DDMSTRUCTURELINK_WHERE);
1752
1753 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1754
1755 String sql = query.toString();
1756
1757 Session session = null;
1758
1759 try {
1760 session = openSession();
1761
1762 Query q = session.createQuery(sql);
1763
1764 QueryPos qPos = QueryPos.getInstance(q);
1765
1766 qPos.add(structureId);
1767
1768 count = (Long)q.uniqueResult();
1769 }
1770 catch (Exception e) {
1771 throw processException(e);
1772 }
1773 finally {
1774 if (count == null) {
1775 count = Long.valueOf(0);
1776 }
1777
1778 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1779 finderArgs, count);
1780
1781 closeSession(session);
1782 }
1783 }
1784
1785 return count.intValue();
1786 }
1787
1788
1794 public int countAll() throws SystemException {
1795 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1796 FINDER_ARGS_EMPTY, this);
1797
1798 if (count == null) {
1799 Session session = null;
1800
1801 try {
1802 session = openSession();
1803
1804 Query q = session.createQuery(_SQL_COUNT_DDMSTRUCTURELINK);
1805
1806 count = (Long)q.uniqueResult();
1807 }
1808 catch (Exception e) {
1809 throw processException(e);
1810 }
1811 finally {
1812 if (count == null) {
1813 count = Long.valueOf(0);
1814 }
1815
1816 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1817 FINDER_ARGS_EMPTY, count);
1818
1819 closeSession(session);
1820 }
1821 }
1822
1823 return count.intValue();
1824 }
1825
1826
1829 public void afterPropertiesSet() {
1830 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1831 com.liferay.portal.util.PropsUtil.get(
1832 "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink")));
1833
1834 if (listenerClassNames.length > 0) {
1835 try {
1836 List<ModelListener<DDMStructureLink>> listenersList = new ArrayList<ModelListener<DDMStructureLink>>();
1837
1838 for (String listenerClassName : listenerClassNames) {
1839 Class<?> clazz = getClass();
1840
1841 listenersList.add((ModelListener<DDMStructureLink>)InstanceFactory.newInstance(
1842 clazz.getClassLoader(), listenerClassName));
1843 }
1844
1845 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1846 }
1847 catch (Exception e) {
1848 _log.error(e);
1849 }
1850 }
1851 }
1852
1853 public void destroy() {
1854 EntityCacheUtil.removeCache(DDMStructureLinkImpl.class.getName());
1855 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1856 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1857 }
1858
1859 @BeanReference(type = DDMContentPersistence.class)
1860 protected DDMContentPersistence ddmContentPersistence;
1861 @BeanReference(type = DDMStorageLinkPersistence.class)
1862 protected DDMStorageLinkPersistence ddmStorageLinkPersistence;
1863 @BeanReference(type = DDMStructurePersistence.class)
1864 protected DDMStructurePersistence ddmStructurePersistence;
1865 @BeanReference(type = DDMStructureLinkPersistence.class)
1866 protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
1867 @BeanReference(type = DDMTemplatePersistence.class)
1868 protected DDMTemplatePersistence ddmTemplatePersistence;
1869 @BeanReference(type = ResourcePersistence.class)
1870 protected ResourcePersistence resourcePersistence;
1871 @BeanReference(type = UserPersistence.class)
1872 protected UserPersistence userPersistence;
1873 private static final String _SQL_SELECT_DDMSTRUCTURELINK = "SELECT ddmStructureLink FROM DDMStructureLink ddmStructureLink";
1874 private static final String _SQL_SELECT_DDMSTRUCTURELINK_WHERE = "SELECT ddmStructureLink FROM DDMStructureLink ddmStructureLink WHERE ";
1875 private static final String _SQL_COUNT_DDMSTRUCTURELINK = "SELECT COUNT(ddmStructureLink) FROM DDMStructureLink ddmStructureLink";
1876 private static final String _SQL_COUNT_DDMSTRUCTURELINK_WHERE = "SELECT COUNT(ddmStructureLink) FROM DDMStructureLink ddmStructureLink WHERE ";
1877 private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "ddmStructureLink.classNameId = ?";
1878 private static final String _FINDER_COLUMN_CLASSPK_CLASSPK_2 = "ddmStructureLink.classPK = ?";
1879 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "ddmStructureLink.structureId = ?";
1880 private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStructureLink.";
1881 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStructureLink exists with the primary key ";
1882 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStructureLink exists with the key {";
1883 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1884 private static Log _log = LogFactoryUtil.getLog(DDMStructureLinkPersistenceImpl.class);
1885 private static DDMStructureLink _nullDDMStructureLink = new DDMStructureLinkImpl() {
1886 @Override
1887 public Object clone() {
1888 return this;
1889 }
1890
1891 @Override
1892 public CacheModel<DDMStructureLink> toCacheModel() {
1893 return _nullDDMStructureLinkCacheModel;
1894 }
1895 };
1896
1897 private static CacheModel<DDMStructureLink> _nullDDMStructureLinkCacheModel = new CacheModel<DDMStructureLink>() {
1898 public DDMStructureLink toEntityModel() {
1899 return _nullDDMStructureLink;
1900 }
1901 };
1902 }