1
14
15 package com.liferay.portlet.asset.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.Session;
27 import com.liferay.portal.kernel.exception.SystemException;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.InstanceFactory;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.kernel.util.Validator;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.ResourcePersistence;
40 import com.liferay.portal.service.persistence.UserPersistence;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
44 import com.liferay.portlet.asset.model.AssetCategoryProperty;
45 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
46 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
47
48 import java.io.Serializable;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
67 public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
68 implements AssetCategoryPropertyPersistence {
69 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
70 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
71 ".List";
72 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
73 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
74 FINDER_CLASS_NAME_LIST, "findByCompanyId",
75 new String[] {
76 Long.class.getName(),
77
78 "java.lang.Integer", "java.lang.Integer",
79 "com.liferay.portal.kernel.util.OrderByComparator"
80 });
81 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
82 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "countByCompanyId",
84 new String[] { Long.class.getName() });
85 public static final FinderPath FINDER_PATH_FIND_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
86 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_LIST, "findByCategoryId",
88 new String[] {
89 Long.class.getName(),
90
91 "java.lang.Integer", "java.lang.Integer",
92 "com.liferay.portal.kernel.util.OrderByComparator"
93 });
94 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
95 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "countByCategoryId",
97 new String[] { Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
99 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_LIST, "findByC_K",
101 new String[] {
102 Long.class.getName(), 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_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
108 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_LIST, "countByC_K",
110 new String[] { Long.class.getName(), String.class.getName() });
111 public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
112 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_ENTITY, "fetchByCA_K",
114 new String[] { Long.class.getName(), String.class.getName() });
115 public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
116 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "countByCA_K",
118 new String[] { Long.class.getName(), String.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
120 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
121 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
122 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
123 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
124 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
125
126 public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
127 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
128 AssetCategoryPropertyImpl.class,
129 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
130
131 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
132 new Object[] {
133 new Long(assetCategoryProperty.getCategoryId()),
134
135 assetCategoryProperty.getKey()
136 }, assetCategoryProperty);
137 }
138
139 public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
140 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
141 if (EntityCacheUtil.getResult(
142 AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
143 AssetCategoryPropertyImpl.class,
144 assetCategoryProperty.getPrimaryKey(), this) == null) {
145 cacheResult(assetCategoryProperty);
146 }
147 }
148 }
149
150 public void clearCache() {
151 CacheRegistry.clear(AssetCategoryPropertyImpl.class.getName());
152 EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
153 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
154 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
155 }
156
157 public void clearCache(AssetCategoryProperty assetCategoryProperty) {
158 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
159 AssetCategoryPropertyImpl.class,
160 assetCategoryProperty.getPrimaryKey());
161
162 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
163 new Object[] {
164 new Long(assetCategoryProperty.getCategoryId()),
165
166 assetCategoryProperty.getKey()
167 });
168 }
169
170 public AssetCategoryProperty create(long categoryPropertyId) {
171 AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
172
173 assetCategoryProperty.setNew(true);
174 assetCategoryProperty.setPrimaryKey(categoryPropertyId);
175
176 return assetCategoryProperty;
177 }
178
179 public AssetCategoryProperty remove(Serializable primaryKey)
180 throws NoSuchModelException, SystemException {
181 return remove(((Long)primaryKey).longValue());
182 }
183
184 public AssetCategoryProperty remove(long categoryPropertyId)
185 throws NoSuchCategoryPropertyException, SystemException {
186 Session session = null;
187
188 try {
189 session = openSession();
190
191 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
192 new Long(categoryPropertyId));
193
194 if (assetCategoryProperty == null) {
195 if (_log.isWarnEnabled()) {
196 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
197 categoryPropertyId);
198 }
199
200 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
201 categoryPropertyId);
202 }
203
204 return remove(assetCategoryProperty);
205 }
206 catch (NoSuchCategoryPropertyException nsee) {
207 throw nsee;
208 }
209 catch (Exception e) {
210 throw processException(e);
211 }
212 finally {
213 closeSession(session);
214 }
215 }
216
217 public AssetCategoryProperty remove(
218 AssetCategoryProperty assetCategoryProperty) throws SystemException {
219 for (ModelListener<AssetCategoryProperty> listener : listeners) {
220 listener.onBeforeRemove(assetCategoryProperty);
221 }
222
223 assetCategoryProperty = removeImpl(assetCategoryProperty);
224
225 for (ModelListener<AssetCategoryProperty> listener : listeners) {
226 listener.onAfterRemove(assetCategoryProperty);
227 }
228
229 return assetCategoryProperty;
230 }
231
232 protected AssetCategoryProperty removeImpl(
233 AssetCategoryProperty assetCategoryProperty) throws SystemException {
234 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
235
236 Session session = null;
237
238 try {
239 session = openSession();
240
241 if (assetCategoryProperty.isCachedModel() ||
242 BatchSessionUtil.isEnabled()) {
243 Object staleObject = session.get(AssetCategoryPropertyImpl.class,
244 assetCategoryProperty.getPrimaryKeyObj());
245
246 if (staleObject != null) {
247 session.evict(staleObject);
248 }
249 }
250
251 session.delete(assetCategoryProperty);
252
253 session.flush();
254 }
255 catch (Exception e) {
256 throw processException(e);
257 }
258 finally {
259 closeSession(session);
260 }
261
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
263
264 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
265
266 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
267 new Object[] {
268 new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
269
270 assetCategoryPropertyModelImpl.getOriginalKey()
271 });
272
273 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
274 AssetCategoryPropertyImpl.class,
275 assetCategoryProperty.getPrimaryKey());
276
277 return assetCategoryProperty;
278 }
279
280 public AssetCategoryProperty updateImpl(
281 com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty,
282 boolean merge) throws SystemException {
283 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
284
285 boolean isNew = assetCategoryProperty.isNew();
286
287 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
288
289 Session session = null;
290
291 try {
292 session = openSession();
293
294 BatchSessionUtil.update(session, assetCategoryProperty, merge);
295
296 assetCategoryProperty.setNew(false);
297 }
298 catch (Exception e) {
299 throw processException(e);
300 }
301 finally {
302 closeSession(session);
303 }
304
305 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
306
307 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
308 AssetCategoryPropertyImpl.class,
309 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
310
311 if (!isNew &&
312 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
313 !Validator.equals(assetCategoryProperty.getKey(),
314 assetCategoryPropertyModelImpl.getOriginalKey()))) {
315 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
316 new Object[] {
317 new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
318
319 assetCategoryPropertyModelImpl.getOriginalKey()
320 });
321 }
322
323 if (isNew ||
324 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
325 !Validator.equals(assetCategoryProperty.getKey(),
326 assetCategoryPropertyModelImpl.getOriginalKey()))) {
327 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
328 new Object[] {
329 new Long(assetCategoryProperty.getCategoryId()),
330
331 assetCategoryProperty.getKey()
332 }, assetCategoryProperty);
333 }
334
335 return assetCategoryProperty;
336 }
337
338 protected AssetCategoryProperty toUnwrappedModel(
339 AssetCategoryProperty assetCategoryProperty) {
340 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
341 return assetCategoryProperty;
342 }
343
344 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
345
346 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
347 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
348
349 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
350 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
351 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
352 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
353 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
354 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
355 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
356 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
357 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
358
359 return assetCategoryPropertyImpl;
360 }
361
362 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
363 throws NoSuchModelException, SystemException {
364 return findByPrimaryKey(((Long)primaryKey).longValue());
365 }
366
367 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
368 throws NoSuchCategoryPropertyException, SystemException {
369 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(categoryPropertyId);
370
371 if (assetCategoryProperty == null) {
372 if (_log.isWarnEnabled()) {
373 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
374 categoryPropertyId);
375 }
376
377 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
378 categoryPropertyId);
379 }
380
381 return assetCategoryProperty;
382 }
383
384 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
385 throws SystemException {
386 return fetchByPrimaryKey(((Long)primaryKey).longValue());
387 }
388
389 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
390 throws SystemException {
391 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
392 AssetCategoryPropertyImpl.class, categoryPropertyId, this);
393
394 if (assetCategoryProperty == null) {
395 Session session = null;
396
397 try {
398 session = openSession();
399
400 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
401 new Long(categoryPropertyId));
402 }
403 catch (Exception e) {
404 throw processException(e);
405 }
406 finally {
407 if (assetCategoryProperty != null) {
408 cacheResult(assetCategoryProperty);
409 }
410
411 closeSession(session);
412 }
413 }
414
415 return assetCategoryProperty;
416 }
417
418 public List<AssetCategoryProperty> findByCompanyId(long companyId)
419 throws SystemException {
420 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
421 null);
422 }
423
424 public List<AssetCategoryProperty> findByCompanyId(long companyId,
425 int start, int end) throws SystemException {
426 return findByCompanyId(companyId, start, end, null);
427 }
428
429 public List<AssetCategoryProperty> findByCompanyId(long companyId,
430 int start, int end, OrderByComparator orderByComparator)
431 throws SystemException {
432 Object[] finderArgs = new Object[] {
433 new Long(companyId),
434
435 String.valueOf(start), String.valueOf(end),
436 String.valueOf(orderByComparator)
437 };
438
439 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
440 finderArgs, this);
441
442 if (list == null) {
443 Session session = null;
444
445 try {
446 session = openSession();
447
448 StringBundler query = null;
449
450 if (orderByComparator != null) {
451 query = new StringBundler(3 +
452 (orderByComparator.getOrderByFields().length * 3));
453 }
454 else {
455 query = new StringBundler(3);
456 }
457
458 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
459
460 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
461
462 if (orderByComparator != null) {
463 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
464 orderByComparator);
465 }
466
467 else {
468 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
469 }
470
471 String sql = query.toString();
472
473 Query q = session.createQuery(sql);
474
475 QueryPos qPos = QueryPos.getInstance(q);
476
477 qPos.add(companyId);
478
479 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
480 getDialect(), start, end);
481 }
482 catch (Exception e) {
483 throw processException(e);
484 }
485 finally {
486 if (list == null) {
487 list = new ArrayList<AssetCategoryProperty>();
488 }
489
490 cacheResult(list);
491
492 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
493 finderArgs, list);
494
495 closeSession(session);
496 }
497 }
498
499 return list;
500 }
501
502 public AssetCategoryProperty findByCompanyId_First(long companyId,
503 OrderByComparator orderByComparator)
504 throws NoSuchCategoryPropertyException, SystemException {
505 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
506 orderByComparator);
507
508 if (list.isEmpty()) {
509 StringBundler msg = new StringBundler(4);
510
511 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
512
513 msg.append("companyId=");
514 msg.append(companyId);
515
516 msg.append(StringPool.CLOSE_CURLY_BRACE);
517
518 throw new NoSuchCategoryPropertyException(msg.toString());
519 }
520 else {
521 return list.get(0);
522 }
523 }
524
525 public AssetCategoryProperty findByCompanyId_Last(long companyId,
526 OrderByComparator orderByComparator)
527 throws NoSuchCategoryPropertyException, SystemException {
528 int count = countByCompanyId(companyId);
529
530 List<AssetCategoryProperty> list = findByCompanyId(companyId,
531 count - 1, count, orderByComparator);
532
533 if (list.isEmpty()) {
534 StringBundler msg = new StringBundler(4);
535
536 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
537
538 msg.append("companyId=");
539 msg.append(companyId);
540
541 msg.append(StringPool.CLOSE_CURLY_BRACE);
542
543 throw new NoSuchCategoryPropertyException(msg.toString());
544 }
545 else {
546 return list.get(0);
547 }
548 }
549
550 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
551 long categoryPropertyId, long companyId,
552 OrderByComparator orderByComparator)
553 throws NoSuchCategoryPropertyException, SystemException {
554 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
555
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
562
563 array[0] = getByCompanyId_PrevAndNext(session,
564 assetCategoryProperty, companyId, orderByComparator, true);
565
566 array[1] = assetCategoryProperty;
567
568 array[2] = getByCompanyId_PrevAndNext(session,
569 assetCategoryProperty, companyId, orderByComparator, false);
570
571 return array;
572 }
573 catch (Exception e) {
574 throw processException(e);
575 }
576 finally {
577 closeSession(session);
578 }
579 }
580
581 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
582 Session session, AssetCategoryProperty assetCategoryProperty,
583 long companyId, OrderByComparator orderByComparator, boolean previous) {
584 StringBundler query = null;
585
586 if (orderByComparator != null) {
587 query = new StringBundler(6 +
588 (orderByComparator.getOrderByFields().length * 6));
589 }
590 else {
591 query = new StringBundler(3);
592 }
593
594 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
595
596 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
597
598 if (orderByComparator != null) {
599 String[] orderByFields = orderByComparator.getOrderByFields();
600
601 if (orderByFields.length > 0) {
602 query.append(WHERE_AND);
603 }
604
605 for (int i = 0; i < orderByFields.length; i++) {
606 query.append(_ORDER_BY_ENTITY_ALIAS);
607 query.append(orderByFields[i]);
608
609 if ((i + 1) < orderByFields.length) {
610 if (orderByComparator.isAscending() ^ previous) {
611 query.append(WHERE_GREATER_THAN_HAS_NEXT);
612 }
613 else {
614 query.append(WHERE_LESSER_THAN_HAS_NEXT);
615 }
616 }
617 else {
618 if (orderByComparator.isAscending() ^ previous) {
619 query.append(WHERE_GREATER_THAN);
620 }
621 else {
622 query.append(WHERE_LESSER_THAN);
623 }
624 }
625 }
626
627 query.append(ORDER_BY_CLAUSE);
628
629 for (int i = 0; i < orderByFields.length; i++) {
630 query.append(_ORDER_BY_ENTITY_ALIAS);
631 query.append(orderByFields[i]);
632
633 if ((i + 1) < orderByFields.length) {
634 if (orderByComparator.isAscending() ^ previous) {
635 query.append(ORDER_BY_ASC_HAS_NEXT);
636 }
637 else {
638 query.append(ORDER_BY_DESC_HAS_NEXT);
639 }
640 }
641 else {
642 if (orderByComparator.isAscending() ^ previous) {
643 query.append(ORDER_BY_ASC);
644 }
645 else {
646 query.append(ORDER_BY_DESC);
647 }
648 }
649 }
650 }
651
652 else {
653 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
654 }
655
656 String sql = query.toString();
657
658 Query q = session.createQuery(sql);
659
660 q.setFirstResult(0);
661 q.setMaxResults(2);
662
663 QueryPos qPos = QueryPos.getInstance(q);
664
665 qPos.add(companyId);
666
667 if (orderByComparator != null) {
668 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
669
670 for (Object value : values) {
671 qPos.add(value);
672 }
673 }
674
675 List<AssetCategoryProperty> list = q.list();
676
677 if (list.size() == 2) {
678 return list.get(1);
679 }
680 else {
681 return null;
682 }
683 }
684
685 public List<AssetCategoryProperty> findByCategoryId(long categoryId)
686 throws SystemException {
687 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
688 QueryUtil.ALL_POS, null);
689 }
690
691 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
692 int start, int end) throws SystemException {
693 return findByCategoryId(categoryId, start, end, null);
694 }
695
696 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
697 int start, int end, OrderByComparator orderByComparator)
698 throws SystemException {
699 Object[] finderArgs = new Object[] {
700 new Long(categoryId),
701
702 String.valueOf(start), String.valueOf(end),
703 String.valueOf(orderByComparator)
704 };
705
706 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
707 finderArgs, this);
708
709 if (list == null) {
710 Session session = null;
711
712 try {
713 session = openSession();
714
715 StringBundler query = null;
716
717 if (orderByComparator != null) {
718 query = new StringBundler(3 +
719 (orderByComparator.getOrderByFields().length * 3));
720 }
721 else {
722 query = new StringBundler(3);
723 }
724
725 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
726
727 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
728
729 if (orderByComparator != null) {
730 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
731 orderByComparator);
732 }
733
734 else {
735 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
736 }
737
738 String sql = query.toString();
739
740 Query q = session.createQuery(sql);
741
742 QueryPos qPos = QueryPos.getInstance(q);
743
744 qPos.add(categoryId);
745
746 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
747 getDialect(), start, end);
748 }
749 catch (Exception e) {
750 throw processException(e);
751 }
752 finally {
753 if (list == null) {
754 list = new ArrayList<AssetCategoryProperty>();
755 }
756
757 cacheResult(list);
758
759 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
760 finderArgs, list);
761
762 closeSession(session);
763 }
764 }
765
766 return list;
767 }
768
769 public AssetCategoryProperty findByCategoryId_First(long categoryId,
770 OrderByComparator orderByComparator)
771 throws NoSuchCategoryPropertyException, SystemException {
772 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
773 orderByComparator);
774
775 if (list.isEmpty()) {
776 StringBundler msg = new StringBundler(4);
777
778 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
779
780 msg.append("categoryId=");
781 msg.append(categoryId);
782
783 msg.append(StringPool.CLOSE_CURLY_BRACE);
784
785 throw new NoSuchCategoryPropertyException(msg.toString());
786 }
787 else {
788 return list.get(0);
789 }
790 }
791
792 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
793 OrderByComparator orderByComparator)
794 throws NoSuchCategoryPropertyException, SystemException {
795 int count = countByCategoryId(categoryId);
796
797 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
798 count - 1, count, orderByComparator);
799
800 if (list.isEmpty()) {
801 StringBundler msg = new StringBundler(4);
802
803 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
804
805 msg.append("categoryId=");
806 msg.append(categoryId);
807
808 msg.append(StringPool.CLOSE_CURLY_BRACE);
809
810 throw new NoSuchCategoryPropertyException(msg.toString());
811 }
812 else {
813 return list.get(0);
814 }
815 }
816
817 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
818 long categoryPropertyId, long categoryId,
819 OrderByComparator orderByComparator)
820 throws NoSuchCategoryPropertyException, SystemException {
821 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
822
823 Session session = null;
824
825 try {
826 session = openSession();
827
828 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
829
830 array[0] = getByCategoryId_PrevAndNext(session,
831 assetCategoryProperty, categoryId, orderByComparator, true);
832
833 array[1] = assetCategoryProperty;
834
835 array[2] = getByCategoryId_PrevAndNext(session,
836 assetCategoryProperty, categoryId, orderByComparator, false);
837
838 return array;
839 }
840 catch (Exception e) {
841 throw processException(e);
842 }
843 finally {
844 closeSession(session);
845 }
846 }
847
848 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
849 Session session, AssetCategoryProperty assetCategoryProperty,
850 long categoryId, OrderByComparator orderByComparator, boolean previous) {
851 StringBundler query = null;
852
853 if (orderByComparator != null) {
854 query = new StringBundler(6 +
855 (orderByComparator.getOrderByFields().length * 6));
856 }
857 else {
858 query = new StringBundler(3);
859 }
860
861 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
862
863 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
864
865 if (orderByComparator != null) {
866 String[] orderByFields = orderByComparator.getOrderByFields();
867
868 if (orderByFields.length > 0) {
869 query.append(WHERE_AND);
870 }
871
872 for (int i = 0; i < orderByFields.length; i++) {
873 query.append(_ORDER_BY_ENTITY_ALIAS);
874 query.append(orderByFields[i]);
875
876 if ((i + 1) < orderByFields.length) {
877 if (orderByComparator.isAscending() ^ previous) {
878 query.append(WHERE_GREATER_THAN_HAS_NEXT);
879 }
880 else {
881 query.append(WHERE_LESSER_THAN_HAS_NEXT);
882 }
883 }
884 else {
885 if (orderByComparator.isAscending() ^ previous) {
886 query.append(WHERE_GREATER_THAN);
887 }
888 else {
889 query.append(WHERE_LESSER_THAN);
890 }
891 }
892 }
893
894 query.append(ORDER_BY_CLAUSE);
895
896 for (int i = 0; i < orderByFields.length; i++) {
897 query.append(_ORDER_BY_ENTITY_ALIAS);
898 query.append(orderByFields[i]);
899
900 if ((i + 1) < orderByFields.length) {
901 if (orderByComparator.isAscending() ^ previous) {
902 query.append(ORDER_BY_ASC_HAS_NEXT);
903 }
904 else {
905 query.append(ORDER_BY_DESC_HAS_NEXT);
906 }
907 }
908 else {
909 if (orderByComparator.isAscending() ^ previous) {
910 query.append(ORDER_BY_ASC);
911 }
912 else {
913 query.append(ORDER_BY_DESC);
914 }
915 }
916 }
917 }
918
919 else {
920 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
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(categoryId);
933
934 if (orderByComparator != null) {
935 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
936
937 for (Object value : values) {
938 qPos.add(value);
939 }
940 }
941
942 List<AssetCategoryProperty> list = q.list();
943
944 if (list.size() == 2) {
945 return list.get(1);
946 }
947 else {
948 return null;
949 }
950 }
951
952 public List<AssetCategoryProperty> findByC_K(long companyId, String key)
953 throws SystemException {
954 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
955 null);
956 }
957
958 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
959 int start, int end) throws SystemException {
960 return findByC_K(companyId, key, start, end, null);
961 }
962
963 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
964 int start, int end, OrderByComparator orderByComparator)
965 throws SystemException {
966 Object[] finderArgs = new Object[] {
967 new Long(companyId),
968
969 key,
970
971 String.valueOf(start), String.valueOf(end),
972 String.valueOf(orderByComparator)
973 };
974
975 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
976 finderArgs, this);
977
978 if (list == null) {
979 Session session = null;
980
981 try {
982 session = openSession();
983
984 StringBundler query = null;
985
986 if (orderByComparator != null) {
987 query = new StringBundler(4 +
988 (orderByComparator.getOrderByFields().length * 3));
989 }
990 else {
991 query = new StringBundler(4);
992 }
993
994 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
995
996 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
997
998 if (key == null) {
999 query.append(_FINDER_COLUMN_C_K_KEY_1);
1000 }
1001 else {
1002 if (key.equals(StringPool.BLANK)) {
1003 query.append(_FINDER_COLUMN_C_K_KEY_3);
1004 }
1005 else {
1006 query.append(_FINDER_COLUMN_C_K_KEY_2);
1007 }
1008 }
1009
1010 if (orderByComparator != null) {
1011 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1012 orderByComparator);
1013 }
1014
1015 else {
1016 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1017 }
1018
1019 String sql = query.toString();
1020
1021 Query q = session.createQuery(sql);
1022
1023 QueryPos qPos = QueryPos.getInstance(q);
1024
1025 qPos.add(companyId);
1026
1027 if (key != null) {
1028 qPos.add(key);
1029 }
1030
1031 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1032 getDialect(), start, end);
1033 }
1034 catch (Exception e) {
1035 throw processException(e);
1036 }
1037 finally {
1038 if (list == null) {
1039 list = new ArrayList<AssetCategoryProperty>();
1040 }
1041
1042 cacheResult(list);
1043
1044 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K, finderArgs,
1045 list);
1046
1047 closeSession(session);
1048 }
1049 }
1050
1051 return list;
1052 }
1053
1054 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1055 OrderByComparator orderByComparator)
1056 throws NoSuchCategoryPropertyException, SystemException {
1057 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1058 orderByComparator);
1059
1060 if (list.isEmpty()) {
1061 StringBundler msg = new StringBundler(6);
1062
1063 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1064
1065 msg.append("companyId=");
1066 msg.append(companyId);
1067
1068 msg.append(", key=");
1069 msg.append(key);
1070
1071 msg.append(StringPool.CLOSE_CURLY_BRACE);
1072
1073 throw new NoSuchCategoryPropertyException(msg.toString());
1074 }
1075 else {
1076 return list.get(0);
1077 }
1078 }
1079
1080 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1081 OrderByComparator orderByComparator)
1082 throws NoSuchCategoryPropertyException, SystemException {
1083 int count = countByC_K(companyId, key);
1084
1085 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1086 count, orderByComparator);
1087
1088 if (list.isEmpty()) {
1089 StringBundler msg = new StringBundler(6);
1090
1091 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1092
1093 msg.append("companyId=");
1094 msg.append(companyId);
1095
1096 msg.append(", key=");
1097 msg.append(key);
1098
1099 msg.append(StringPool.CLOSE_CURLY_BRACE);
1100
1101 throw new NoSuchCategoryPropertyException(msg.toString());
1102 }
1103 else {
1104 return list.get(0);
1105 }
1106 }
1107
1108 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1109 long categoryPropertyId, long companyId, String key,
1110 OrderByComparator orderByComparator)
1111 throws NoSuchCategoryPropertyException, SystemException {
1112 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1113
1114 Session session = null;
1115
1116 try {
1117 session = openSession();
1118
1119 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1120
1121 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1122 companyId, key, orderByComparator, true);
1123
1124 array[1] = assetCategoryProperty;
1125
1126 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1127 companyId, key, orderByComparator, false);
1128
1129 return array;
1130 }
1131 catch (Exception e) {
1132 throw processException(e);
1133 }
1134 finally {
1135 closeSession(session);
1136 }
1137 }
1138
1139 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1140 AssetCategoryProperty assetCategoryProperty, long companyId,
1141 String key, OrderByComparator orderByComparator, boolean previous) {
1142 StringBundler query = null;
1143
1144 if (orderByComparator != null) {
1145 query = new StringBundler(6 +
1146 (orderByComparator.getOrderByFields().length * 6));
1147 }
1148 else {
1149 query = new StringBundler(3);
1150 }
1151
1152 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1153
1154 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1155
1156 if (key == null) {
1157 query.append(_FINDER_COLUMN_C_K_KEY_1);
1158 }
1159 else {
1160 if (key.equals(StringPool.BLANK)) {
1161 query.append(_FINDER_COLUMN_C_K_KEY_3);
1162 }
1163 else {
1164 query.append(_FINDER_COLUMN_C_K_KEY_2);
1165 }
1166 }
1167
1168 if (orderByComparator != null) {
1169 String[] orderByFields = orderByComparator.getOrderByFields();
1170
1171 if (orderByFields.length > 0) {
1172 query.append(WHERE_AND);
1173 }
1174
1175 for (int i = 0; i < orderByFields.length; i++) {
1176 query.append(_ORDER_BY_ENTITY_ALIAS);
1177 query.append(orderByFields[i]);
1178
1179 if ((i + 1) < orderByFields.length) {
1180 if (orderByComparator.isAscending() ^ previous) {
1181 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1182 }
1183 else {
1184 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1185 }
1186 }
1187 else {
1188 if (orderByComparator.isAscending() ^ previous) {
1189 query.append(WHERE_GREATER_THAN);
1190 }
1191 else {
1192 query.append(WHERE_LESSER_THAN);
1193 }
1194 }
1195 }
1196
1197 query.append(ORDER_BY_CLAUSE);
1198
1199 for (int i = 0; i < orderByFields.length; i++) {
1200 query.append(_ORDER_BY_ENTITY_ALIAS);
1201 query.append(orderByFields[i]);
1202
1203 if ((i + 1) < orderByFields.length) {
1204 if (orderByComparator.isAscending() ^ previous) {
1205 query.append(ORDER_BY_ASC_HAS_NEXT);
1206 }
1207 else {
1208 query.append(ORDER_BY_DESC_HAS_NEXT);
1209 }
1210 }
1211 else {
1212 if (orderByComparator.isAscending() ^ previous) {
1213 query.append(ORDER_BY_ASC);
1214 }
1215 else {
1216 query.append(ORDER_BY_DESC);
1217 }
1218 }
1219 }
1220 }
1221
1222 else {
1223 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1224 }
1225
1226 String sql = query.toString();
1227
1228 Query q = session.createQuery(sql);
1229
1230 q.setFirstResult(0);
1231 q.setMaxResults(2);
1232
1233 QueryPos qPos = QueryPos.getInstance(q);
1234
1235 qPos.add(companyId);
1236
1237 if (key != null) {
1238 qPos.add(key);
1239 }
1240
1241 if (orderByComparator != null) {
1242 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1243
1244 for (Object value : values) {
1245 qPos.add(value);
1246 }
1247 }
1248
1249 List<AssetCategoryProperty> list = q.list();
1250
1251 if (list.size() == 2) {
1252 return list.get(1);
1253 }
1254 else {
1255 return null;
1256 }
1257 }
1258
1259 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1260 throws NoSuchCategoryPropertyException, SystemException {
1261 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1262 key);
1263
1264 if (assetCategoryProperty == null) {
1265 StringBundler msg = new StringBundler(6);
1266
1267 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1268
1269 msg.append("categoryId=");
1270 msg.append(categoryId);
1271
1272 msg.append(", key=");
1273 msg.append(key);
1274
1275 msg.append(StringPool.CLOSE_CURLY_BRACE);
1276
1277 if (_log.isWarnEnabled()) {
1278 _log.warn(msg.toString());
1279 }
1280
1281 throw new NoSuchCategoryPropertyException(msg.toString());
1282 }
1283
1284 return assetCategoryProperty;
1285 }
1286
1287 public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1288 throws SystemException {
1289 return fetchByCA_K(categoryId, key, true);
1290 }
1291
1292 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1293 boolean retrieveFromCache) throws SystemException {
1294 Object[] finderArgs = new Object[] { new Long(categoryId), key };
1295
1296 Object result = null;
1297
1298 if (retrieveFromCache) {
1299 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1300 finderArgs, this);
1301 }
1302
1303 if (result == null) {
1304 Session session = null;
1305
1306 try {
1307 session = openSession();
1308
1309 StringBundler query = new StringBundler(4);
1310
1311 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1312
1313 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1314
1315 if (key == null) {
1316 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1317 }
1318 else {
1319 if (key.equals(StringPool.BLANK)) {
1320 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1321 }
1322 else {
1323 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1324 }
1325 }
1326
1327 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1328
1329 String sql = query.toString();
1330
1331 Query q = session.createQuery(sql);
1332
1333 QueryPos qPos = QueryPos.getInstance(q);
1334
1335 qPos.add(categoryId);
1336
1337 if (key != null) {
1338 qPos.add(key);
1339 }
1340
1341 List<AssetCategoryProperty> list = q.list();
1342
1343 result = list;
1344
1345 AssetCategoryProperty assetCategoryProperty = null;
1346
1347 if (list.isEmpty()) {
1348 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1349 finderArgs, list);
1350 }
1351 else {
1352 assetCategoryProperty = list.get(0);
1353
1354 cacheResult(assetCategoryProperty);
1355
1356 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1357 (assetCategoryProperty.getKey() == null) ||
1358 !assetCategoryProperty.getKey().equals(key)) {
1359 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1360 finderArgs, assetCategoryProperty);
1361 }
1362 }
1363
1364 return assetCategoryProperty;
1365 }
1366 catch (Exception e) {
1367 throw processException(e);
1368 }
1369 finally {
1370 if (result == null) {
1371 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1372 finderArgs, new ArrayList<AssetCategoryProperty>());
1373 }
1374
1375 closeSession(session);
1376 }
1377 }
1378 else {
1379 if (result instanceof List<?>) {
1380 return null;
1381 }
1382 else {
1383 return (AssetCategoryProperty)result;
1384 }
1385 }
1386 }
1387
1388 public List<AssetCategoryProperty> findAll() throws SystemException {
1389 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1390 }
1391
1392 public List<AssetCategoryProperty> findAll(int start, int end)
1393 throws SystemException {
1394 return findAll(start, end, null);
1395 }
1396
1397 public List<AssetCategoryProperty> findAll(int start, int end,
1398 OrderByComparator orderByComparator) throws SystemException {
1399 Object[] finderArgs = new Object[] {
1400 String.valueOf(start), String.valueOf(end),
1401 String.valueOf(orderByComparator)
1402 };
1403
1404 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1405 finderArgs, this);
1406
1407 if (list == null) {
1408 Session session = null;
1409
1410 try {
1411 session = openSession();
1412
1413 StringBundler query = null;
1414 String sql = null;
1415
1416 if (orderByComparator != null) {
1417 query = new StringBundler(2 +
1418 (orderByComparator.getOrderByFields().length * 3));
1419
1420 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
1421
1422 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1423 orderByComparator);
1424
1425 sql = query.toString();
1426 }
1427
1428 else {
1429 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1430 }
1431
1432 Query q = session.createQuery(sql);
1433
1434 if (orderByComparator == null) {
1435 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1436 getDialect(), start, end, false);
1437
1438 Collections.sort(list);
1439 }
1440 else {
1441 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1442 getDialect(), start, end);
1443 }
1444 }
1445 catch (Exception e) {
1446 throw processException(e);
1447 }
1448 finally {
1449 if (list == null) {
1450 list = new ArrayList<AssetCategoryProperty>();
1451 }
1452
1453 cacheResult(list);
1454
1455 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1456
1457 closeSession(session);
1458 }
1459 }
1460
1461 return list;
1462 }
1463
1464 public void removeByCompanyId(long companyId) throws SystemException {
1465 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
1466 companyId)) {
1467 remove(assetCategoryProperty);
1468 }
1469 }
1470
1471 public void removeByCategoryId(long categoryId) throws SystemException {
1472 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1473 categoryId)) {
1474 remove(assetCategoryProperty);
1475 }
1476 }
1477
1478 public void removeByC_K(long companyId, String key)
1479 throws SystemException {
1480 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1481 companyId, key)) {
1482 remove(assetCategoryProperty);
1483 }
1484 }
1485
1486 public void removeByCA_K(long categoryId, String key)
1487 throws NoSuchCategoryPropertyException, SystemException {
1488 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1489
1490 remove(assetCategoryProperty);
1491 }
1492
1493 public void removeAll() throws SystemException {
1494 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
1495 remove(assetCategoryProperty);
1496 }
1497 }
1498
1499 public int countByCompanyId(long companyId) throws SystemException {
1500 Object[] finderArgs = new Object[] { new Long(companyId) };
1501
1502 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1503 finderArgs, this);
1504
1505 if (count == null) {
1506 Session session = null;
1507
1508 try {
1509 session = openSession();
1510
1511 StringBundler query = new StringBundler(2);
1512
1513 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1514
1515 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1516
1517 String sql = query.toString();
1518
1519 Query q = session.createQuery(sql);
1520
1521 QueryPos qPos = QueryPos.getInstance(q);
1522
1523 qPos.add(companyId);
1524
1525 count = (Long)q.uniqueResult();
1526 }
1527 catch (Exception e) {
1528 throw processException(e);
1529 }
1530 finally {
1531 if (count == null) {
1532 count = Long.valueOf(0);
1533 }
1534
1535 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1536 finderArgs, count);
1537
1538 closeSession(session);
1539 }
1540 }
1541
1542 return count.intValue();
1543 }
1544
1545 public int countByCategoryId(long categoryId) throws SystemException {
1546 Object[] finderArgs = new Object[] { new Long(categoryId) };
1547
1548 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1549 finderArgs, this);
1550
1551 if (count == null) {
1552 Session session = null;
1553
1554 try {
1555 session = openSession();
1556
1557 StringBundler query = new StringBundler(2);
1558
1559 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1560
1561 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1562
1563 String sql = query.toString();
1564
1565 Query q = session.createQuery(sql);
1566
1567 QueryPos qPos = QueryPos.getInstance(q);
1568
1569 qPos.add(categoryId);
1570
1571 count = (Long)q.uniqueResult();
1572 }
1573 catch (Exception e) {
1574 throw processException(e);
1575 }
1576 finally {
1577 if (count == null) {
1578 count = Long.valueOf(0);
1579 }
1580
1581 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1582 finderArgs, count);
1583
1584 closeSession(session);
1585 }
1586 }
1587
1588 return count.intValue();
1589 }
1590
1591 public int countByC_K(long companyId, String key) throws SystemException {
1592 Object[] finderArgs = new Object[] { new Long(companyId), key };
1593
1594 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1595 finderArgs, this);
1596
1597 if (count == null) {
1598 Session session = null;
1599
1600 try {
1601 session = openSession();
1602
1603 StringBundler query = new StringBundler(3);
1604
1605 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1606
1607 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1608
1609 if (key == null) {
1610 query.append(_FINDER_COLUMN_C_K_KEY_1);
1611 }
1612 else {
1613 if (key.equals(StringPool.BLANK)) {
1614 query.append(_FINDER_COLUMN_C_K_KEY_3);
1615 }
1616 else {
1617 query.append(_FINDER_COLUMN_C_K_KEY_2);
1618 }
1619 }
1620
1621 String sql = query.toString();
1622
1623 Query q = session.createQuery(sql);
1624
1625 QueryPos qPos = QueryPos.getInstance(q);
1626
1627 qPos.add(companyId);
1628
1629 if (key != null) {
1630 qPos.add(key);
1631 }
1632
1633 count = (Long)q.uniqueResult();
1634 }
1635 catch (Exception e) {
1636 throw processException(e);
1637 }
1638 finally {
1639 if (count == null) {
1640 count = Long.valueOf(0);
1641 }
1642
1643 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
1644 count);
1645
1646 closeSession(session);
1647 }
1648 }
1649
1650 return count.intValue();
1651 }
1652
1653 public int countByCA_K(long categoryId, String key)
1654 throws SystemException {
1655 Object[] finderArgs = new Object[] { new Long(categoryId), key };
1656
1657 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CA_K,
1658 finderArgs, this);
1659
1660 if (count == null) {
1661 Session session = null;
1662
1663 try {
1664 session = openSession();
1665
1666 StringBundler query = new StringBundler(3);
1667
1668 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1669
1670 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1671
1672 if (key == null) {
1673 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1674 }
1675 else {
1676 if (key.equals(StringPool.BLANK)) {
1677 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1678 }
1679 else {
1680 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1681 }
1682 }
1683
1684 String sql = query.toString();
1685
1686 Query q = session.createQuery(sql);
1687
1688 QueryPos qPos = QueryPos.getInstance(q);
1689
1690 qPos.add(categoryId);
1691
1692 if (key != null) {
1693 qPos.add(key);
1694 }
1695
1696 count = (Long)q.uniqueResult();
1697 }
1698 catch (Exception e) {
1699 throw processException(e);
1700 }
1701 finally {
1702 if (count == null) {
1703 count = Long.valueOf(0);
1704 }
1705
1706 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K,
1707 finderArgs, count);
1708
1709 closeSession(session);
1710 }
1711 }
1712
1713 return count.intValue();
1714 }
1715
1716 public int countAll() throws SystemException {
1717 Object[] finderArgs = new Object[0];
1718
1719 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1720 finderArgs, this);
1721
1722 if (count == null) {
1723 Session session = null;
1724
1725 try {
1726 session = openSession();
1727
1728 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
1729
1730 count = (Long)q.uniqueResult();
1731 }
1732 catch (Exception e) {
1733 throw processException(e);
1734 }
1735 finally {
1736 if (count == null) {
1737 count = Long.valueOf(0);
1738 }
1739
1740 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1741 count);
1742
1743 closeSession(session);
1744 }
1745 }
1746
1747 return count.intValue();
1748 }
1749
1750 public void afterPropertiesSet() {
1751 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1752 com.liferay.portal.util.PropsUtil.get(
1753 "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
1754
1755 if (listenerClassNames.length > 0) {
1756 try {
1757 List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
1758
1759 for (String listenerClassName : listenerClassNames) {
1760 listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
1761 listenerClassName));
1762 }
1763
1764 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1765 }
1766 catch (Exception e) {
1767 _log.error(e);
1768 }
1769 }
1770 }
1771
1772 @BeanReference(type = AssetCategoryPersistence.class)
1773 protected AssetCategoryPersistence assetCategoryPersistence;
1774 @BeanReference(type = AssetCategoryPropertyPersistence.class)
1775 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1776 @BeanReference(type = AssetEntryPersistence.class)
1777 protected AssetEntryPersistence assetEntryPersistence;
1778 @BeanReference(type = AssetLinkPersistence.class)
1779 protected AssetLinkPersistence assetLinkPersistence;
1780 @BeanReference(type = AssetTagPersistence.class)
1781 protected AssetTagPersistence assetTagPersistence;
1782 @BeanReference(type = AssetTagPropertyPersistence.class)
1783 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1784 @BeanReference(type = AssetTagStatsPersistence.class)
1785 protected AssetTagStatsPersistence assetTagStatsPersistence;
1786 @BeanReference(type = AssetVocabularyPersistence.class)
1787 protected AssetVocabularyPersistence assetVocabularyPersistence;
1788 @BeanReference(type = ResourcePersistence.class)
1789 protected ResourcePersistence resourcePersistence;
1790 @BeanReference(type = UserPersistence.class)
1791 protected UserPersistence userPersistence;
1792 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
1793 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
1794 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
1795 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
1796 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
1797 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
1798 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
1799 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1800 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
1801 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
1802 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
1803 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1804 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
1805 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
1806 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
1807 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
1808 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
1809 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
1810}