001
014
015 package com.liferay.portlet.expando.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.SQLQuery;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.ArrayUtil;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.SetUtil;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.CompanyProvider;
042 import com.liferay.portal.service.persistence.CompanyProviderWrapper;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.expando.exception.NoSuchColumnException;
046 import com.liferay.portlet.expando.model.ExpandoColumn;
047 import com.liferay.portlet.expando.model.impl.ExpandoColumnImpl;
048 import com.liferay.portlet.expando.model.impl.ExpandoColumnModelImpl;
049 import com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Arrays;
055 import java.util.Collections;
056 import java.util.HashMap;
057 import java.util.HashSet;
058 import java.util.Iterator;
059 import java.util.List;
060 import java.util.Map;
061 import java.util.Set;
062
063
075 @ProviderType
076 public class ExpandoColumnPersistenceImpl extends BasePersistenceImpl<ExpandoColumn>
077 implements ExpandoColumnPersistence {
078
083 public static final String FINDER_CLASS_NAME_ENTITY = ExpandoColumnImpl.class.getName();
084 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085 ".List1";
086 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087 ".List2";
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
089 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
090 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091 "findAll", new String[0]);
092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
093 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
094 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
095 "findAll", new String[0]);
096 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
097 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
099 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TABLEID = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
100 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
101 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
102 "findByTableId",
103 new String[] {
104 Long.class.getName(),
105
106 Integer.class.getName(), Integer.class.getName(),
107 OrderByComparator.class.getName()
108 });
109 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID =
110 new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
111 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
112 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
113 "findByTableId", new String[] { Long.class.getName() },
114 ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
115 ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
116 public static final FinderPath FINDER_PATH_COUNT_BY_TABLEID = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
117 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTableId",
119 new String[] { Long.class.getName() });
120
121
127 @Override
128 public List<ExpandoColumn> findByTableId(long tableId) {
129 return findByTableId(tableId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
130 }
131
132
144 @Override
145 public List<ExpandoColumn> findByTableId(long tableId, int start, int end) {
146 return findByTableId(tableId, start, end, null);
147 }
148
149
162 @Override
163 public List<ExpandoColumn> findByTableId(long tableId, int start, int end,
164 OrderByComparator<ExpandoColumn> orderByComparator) {
165 return findByTableId(tableId, start, end, orderByComparator, true);
166 }
167
168
182 @Override
183 public List<ExpandoColumn> findByTableId(long tableId, int start, int end,
184 OrderByComparator<ExpandoColumn> orderByComparator,
185 boolean retrieveFromCache) {
186 boolean pagination = true;
187 FinderPath finderPath = null;
188 Object[] finderArgs = null;
189
190 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
191 (orderByComparator == null)) {
192 pagination = false;
193 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID;
194 finderArgs = new Object[] { tableId };
195 }
196 else {
197 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TABLEID;
198 finderArgs = new Object[] { tableId, start, end, orderByComparator };
199 }
200
201 List<ExpandoColumn> list = null;
202
203 if (retrieveFromCache) {
204 list = (List<ExpandoColumn>)finderCache.getResult(finderPath,
205 finderArgs, this);
206
207 if ((list != null) && !list.isEmpty()) {
208 for (ExpandoColumn expandoColumn : list) {
209 if ((tableId != expandoColumn.getTableId())) {
210 list = null;
211
212 break;
213 }
214 }
215 }
216 }
217
218 if (list == null) {
219 StringBundler query = null;
220
221 if (orderByComparator != null) {
222 query = new StringBundler(3 +
223 (orderByComparator.getOrderByFields().length * 3));
224 }
225 else {
226 query = new StringBundler(3);
227 }
228
229 query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
230
231 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
232
233 if (orderByComparator != null) {
234 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
235 orderByComparator);
236 }
237 else
238 if (pagination) {
239 query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
240 }
241
242 String sql = query.toString();
243
244 Session session = null;
245
246 try {
247 session = openSession();
248
249 Query q = session.createQuery(sql);
250
251 QueryPos qPos = QueryPos.getInstance(q);
252
253 qPos.add(tableId);
254
255 if (!pagination) {
256 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
257 start, end, false);
258
259 Collections.sort(list);
260
261 list = Collections.unmodifiableList(list);
262 }
263 else {
264 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
265 start, end);
266 }
267
268 cacheResult(list);
269
270 finderCache.putResult(finderPath, finderArgs, list);
271 }
272 catch (Exception e) {
273 finderCache.removeResult(finderPath, finderArgs);
274
275 throw processException(e);
276 }
277 finally {
278 closeSession(session);
279 }
280 }
281
282 return list;
283 }
284
285
293 @Override
294 public ExpandoColumn findByTableId_First(long tableId,
295 OrderByComparator<ExpandoColumn> orderByComparator)
296 throws NoSuchColumnException {
297 ExpandoColumn expandoColumn = fetchByTableId_First(tableId,
298 orderByComparator);
299
300 if (expandoColumn != null) {
301 return expandoColumn;
302 }
303
304 StringBundler msg = new StringBundler(4);
305
306 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
307
308 msg.append("tableId=");
309 msg.append(tableId);
310
311 msg.append(StringPool.CLOSE_CURLY_BRACE);
312
313 throw new NoSuchColumnException(msg.toString());
314 }
315
316
323 @Override
324 public ExpandoColumn fetchByTableId_First(long tableId,
325 OrderByComparator<ExpandoColumn> orderByComparator) {
326 List<ExpandoColumn> list = findByTableId(tableId, 0, 1,
327 orderByComparator);
328
329 if (!list.isEmpty()) {
330 return list.get(0);
331 }
332
333 return null;
334 }
335
336
344 @Override
345 public ExpandoColumn findByTableId_Last(long tableId,
346 OrderByComparator<ExpandoColumn> orderByComparator)
347 throws NoSuchColumnException {
348 ExpandoColumn expandoColumn = fetchByTableId_Last(tableId,
349 orderByComparator);
350
351 if (expandoColumn != null) {
352 return expandoColumn;
353 }
354
355 StringBundler msg = new StringBundler(4);
356
357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
358
359 msg.append("tableId=");
360 msg.append(tableId);
361
362 msg.append(StringPool.CLOSE_CURLY_BRACE);
363
364 throw new NoSuchColumnException(msg.toString());
365 }
366
367
374 @Override
375 public ExpandoColumn fetchByTableId_Last(long tableId,
376 OrderByComparator<ExpandoColumn> orderByComparator) {
377 int count = countByTableId(tableId);
378
379 if (count == 0) {
380 return null;
381 }
382
383 List<ExpandoColumn> list = findByTableId(tableId, count - 1, count,
384 orderByComparator);
385
386 if (!list.isEmpty()) {
387 return list.get(0);
388 }
389
390 return null;
391 }
392
393
402 @Override
403 public ExpandoColumn[] findByTableId_PrevAndNext(long columnId,
404 long tableId, OrderByComparator<ExpandoColumn> orderByComparator)
405 throws NoSuchColumnException {
406 ExpandoColumn expandoColumn = findByPrimaryKey(columnId);
407
408 Session session = null;
409
410 try {
411 session = openSession();
412
413 ExpandoColumn[] array = new ExpandoColumnImpl[3];
414
415 array[0] = getByTableId_PrevAndNext(session, expandoColumn,
416 tableId, orderByComparator, true);
417
418 array[1] = expandoColumn;
419
420 array[2] = getByTableId_PrevAndNext(session, expandoColumn,
421 tableId, orderByComparator, false);
422
423 return array;
424 }
425 catch (Exception e) {
426 throw processException(e);
427 }
428 finally {
429 closeSession(session);
430 }
431 }
432
433 protected ExpandoColumn getByTableId_PrevAndNext(Session session,
434 ExpandoColumn expandoColumn, long tableId,
435 OrderByComparator<ExpandoColumn> orderByComparator, boolean previous) {
436 StringBundler query = null;
437
438 if (orderByComparator != null) {
439 query = new StringBundler(6 +
440 (orderByComparator.getOrderByFields().length * 6));
441 }
442 else {
443 query = new StringBundler(3);
444 }
445
446 query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
447
448 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
449
450 if (orderByComparator != null) {
451 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
452
453 if (orderByConditionFields.length > 0) {
454 query.append(WHERE_AND);
455 }
456
457 for (int i = 0; i < orderByConditionFields.length; i++) {
458 query.append(_ORDER_BY_ENTITY_ALIAS);
459 query.append(orderByConditionFields[i]);
460
461 if ((i + 1) < orderByConditionFields.length) {
462 if (orderByComparator.isAscending() ^ previous) {
463 query.append(WHERE_GREATER_THAN_HAS_NEXT);
464 }
465 else {
466 query.append(WHERE_LESSER_THAN_HAS_NEXT);
467 }
468 }
469 else {
470 if (orderByComparator.isAscending() ^ previous) {
471 query.append(WHERE_GREATER_THAN);
472 }
473 else {
474 query.append(WHERE_LESSER_THAN);
475 }
476 }
477 }
478
479 query.append(ORDER_BY_CLAUSE);
480
481 String[] orderByFields = orderByComparator.getOrderByFields();
482
483 for (int i = 0; i < orderByFields.length; i++) {
484 query.append(_ORDER_BY_ENTITY_ALIAS);
485 query.append(orderByFields[i]);
486
487 if ((i + 1) < orderByFields.length) {
488 if (orderByComparator.isAscending() ^ previous) {
489 query.append(ORDER_BY_ASC_HAS_NEXT);
490 }
491 else {
492 query.append(ORDER_BY_DESC_HAS_NEXT);
493 }
494 }
495 else {
496 if (orderByComparator.isAscending() ^ previous) {
497 query.append(ORDER_BY_ASC);
498 }
499 else {
500 query.append(ORDER_BY_DESC);
501 }
502 }
503 }
504 }
505 else {
506 query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
507 }
508
509 String sql = query.toString();
510
511 Query q = session.createQuery(sql);
512
513 q.setFirstResult(0);
514 q.setMaxResults(2);
515
516 QueryPos qPos = QueryPos.getInstance(q);
517
518 qPos.add(tableId);
519
520 if (orderByComparator != null) {
521 Object[] values = orderByComparator.getOrderByConditionValues(expandoColumn);
522
523 for (Object value : values) {
524 qPos.add(value);
525 }
526 }
527
528 List<ExpandoColumn> list = q.list();
529
530 if (list.size() == 2) {
531 return list.get(1);
532 }
533 else {
534 return null;
535 }
536 }
537
538
544 @Override
545 public List<ExpandoColumn> filterFindByTableId(long tableId) {
546 return filterFindByTableId(tableId, QueryUtil.ALL_POS,
547 QueryUtil.ALL_POS, null);
548 }
549
550
562 @Override
563 public List<ExpandoColumn> filterFindByTableId(long tableId, int start,
564 int end) {
565 return filterFindByTableId(tableId, start, end, null);
566 }
567
568
581 @Override
582 public List<ExpandoColumn> filterFindByTableId(long tableId, int start,
583 int end, OrderByComparator<ExpandoColumn> orderByComparator) {
584 if (!InlineSQLHelperUtil.isEnabled()) {
585 return findByTableId(tableId, start, end, orderByComparator);
586 }
587
588 StringBundler query = null;
589
590 if (orderByComparator != null) {
591 query = new StringBundler(3 +
592 (orderByComparator.getOrderByFields().length * 3));
593 }
594 else {
595 query = new StringBundler(3);
596 }
597
598 if (getDB().isSupportsInlineDistinct()) {
599 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE);
600 }
601 else {
602 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1);
603 }
604
605 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
606
607 if (!getDB().isSupportsInlineDistinct()) {
608 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2);
609 }
610
611 if (orderByComparator != null) {
612 if (getDB().isSupportsInlineDistinct()) {
613 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
614 orderByComparator, true);
615 }
616 else {
617 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
618 orderByComparator, true);
619 }
620 }
621 else {
622 if (getDB().isSupportsInlineDistinct()) {
623 query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
624 }
625 else {
626 query.append(ExpandoColumnModelImpl.ORDER_BY_SQL);
627 }
628 }
629
630 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
631 ExpandoColumn.class.getName(),
632 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
633
634 Session session = null;
635
636 try {
637 session = openSession();
638
639 SQLQuery q = session.createSynchronizedSQLQuery(sql);
640
641 if (getDB().isSupportsInlineDistinct()) {
642 q.addEntity(_FILTER_ENTITY_ALIAS, ExpandoColumnImpl.class);
643 }
644 else {
645 q.addEntity(_FILTER_ENTITY_TABLE, ExpandoColumnImpl.class);
646 }
647
648 QueryPos qPos = QueryPos.getInstance(q);
649
650 qPos.add(tableId);
651
652 return (List<ExpandoColumn>)QueryUtil.list(q, getDialect(), start,
653 end);
654 }
655 catch (Exception e) {
656 throw processException(e);
657 }
658 finally {
659 closeSession(session);
660 }
661 }
662
663
672 @Override
673 public ExpandoColumn[] filterFindByTableId_PrevAndNext(long columnId,
674 long tableId, OrderByComparator<ExpandoColumn> orderByComparator)
675 throws NoSuchColumnException {
676 if (!InlineSQLHelperUtil.isEnabled()) {
677 return findByTableId_PrevAndNext(columnId, tableId,
678 orderByComparator);
679 }
680
681 ExpandoColumn expandoColumn = findByPrimaryKey(columnId);
682
683 Session session = null;
684
685 try {
686 session = openSession();
687
688 ExpandoColumn[] array = new ExpandoColumnImpl[3];
689
690 array[0] = filterGetByTableId_PrevAndNext(session, expandoColumn,
691 tableId, orderByComparator, true);
692
693 array[1] = expandoColumn;
694
695 array[2] = filterGetByTableId_PrevAndNext(session, expandoColumn,
696 tableId, orderByComparator, false);
697
698 return array;
699 }
700 catch (Exception e) {
701 throw processException(e);
702 }
703 finally {
704 closeSession(session);
705 }
706 }
707
708 protected ExpandoColumn filterGetByTableId_PrevAndNext(Session session,
709 ExpandoColumn expandoColumn, long tableId,
710 OrderByComparator<ExpandoColumn> orderByComparator, boolean previous) {
711 StringBundler query = null;
712
713 if (orderByComparator != null) {
714 query = new StringBundler(6 +
715 (orderByComparator.getOrderByFields().length * 6));
716 }
717 else {
718 query = new StringBundler(3);
719 }
720
721 if (getDB().isSupportsInlineDistinct()) {
722 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE);
723 }
724 else {
725 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1);
726 }
727
728 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
729
730 if (!getDB().isSupportsInlineDistinct()) {
731 query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2);
732 }
733
734 if (orderByComparator != null) {
735 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
736
737 if (orderByConditionFields.length > 0) {
738 query.append(WHERE_AND);
739 }
740
741 for (int i = 0; i < orderByConditionFields.length; i++) {
742 if (getDB().isSupportsInlineDistinct()) {
743 query.append(_ORDER_BY_ENTITY_ALIAS);
744 }
745 else {
746 query.append(_ORDER_BY_ENTITY_TABLE);
747 }
748
749 query.append(orderByConditionFields[i]);
750
751 if ((i + 1) < orderByConditionFields.length) {
752 if (orderByComparator.isAscending() ^ previous) {
753 query.append(WHERE_GREATER_THAN_HAS_NEXT);
754 }
755 else {
756 query.append(WHERE_LESSER_THAN_HAS_NEXT);
757 }
758 }
759 else {
760 if (orderByComparator.isAscending() ^ previous) {
761 query.append(WHERE_GREATER_THAN);
762 }
763 else {
764 query.append(WHERE_LESSER_THAN);
765 }
766 }
767 }
768
769 query.append(ORDER_BY_CLAUSE);
770
771 String[] orderByFields = orderByComparator.getOrderByFields();
772
773 for (int i = 0; i < orderByFields.length; i++) {
774 if (getDB().isSupportsInlineDistinct()) {
775 query.append(_ORDER_BY_ENTITY_ALIAS);
776 }
777 else {
778 query.append(_ORDER_BY_ENTITY_TABLE);
779 }
780
781 query.append(orderByFields[i]);
782
783 if ((i + 1) < orderByFields.length) {
784 if (orderByComparator.isAscending() ^ previous) {
785 query.append(ORDER_BY_ASC_HAS_NEXT);
786 }
787 else {
788 query.append(ORDER_BY_DESC_HAS_NEXT);
789 }
790 }
791 else {
792 if (orderByComparator.isAscending() ^ previous) {
793 query.append(ORDER_BY_ASC);
794 }
795 else {
796 query.append(ORDER_BY_DESC);
797 }
798 }
799 }
800 }
801 else {
802 if (getDB().isSupportsInlineDistinct()) {
803 query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
804 }
805 else {
806 query.append(ExpandoColumnModelImpl.ORDER_BY_SQL);
807 }
808 }
809
810 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
811 ExpandoColumn.class.getName(),
812 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
813
814 SQLQuery q = session.createSynchronizedSQLQuery(sql);
815
816 q.setFirstResult(0);
817 q.setMaxResults(2);
818
819 if (getDB().isSupportsInlineDistinct()) {
820 q.addEntity(_FILTER_ENTITY_ALIAS, ExpandoColumnImpl.class);
821 }
822 else {
823 q.addEntity(_FILTER_ENTITY_TABLE, ExpandoColumnImpl.class);
824 }
825
826 QueryPos qPos = QueryPos.getInstance(q);
827
828 qPos.add(tableId);
829
830 if (orderByComparator != null) {
831 Object[] values = orderByComparator.getOrderByConditionValues(expandoColumn);
832
833 for (Object value : values) {
834 qPos.add(value);
835 }
836 }
837
838 List<ExpandoColumn> list = q.list();
839
840 if (list.size() == 2) {
841 return list.get(1);
842 }
843 else {
844 return null;
845 }
846 }
847
848
853 @Override
854 public void removeByTableId(long tableId) {
855 for (ExpandoColumn expandoColumn : findByTableId(tableId,
856 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
857 remove(expandoColumn);
858 }
859 }
860
861
867 @Override
868 public int countByTableId(long tableId) {
869 FinderPath finderPath = FINDER_PATH_COUNT_BY_TABLEID;
870
871 Object[] finderArgs = new Object[] { tableId };
872
873 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
874
875 if (count == null) {
876 StringBundler query = new StringBundler(2);
877
878 query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
879
880 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
881
882 String sql = query.toString();
883
884 Session session = null;
885
886 try {
887 session = openSession();
888
889 Query q = session.createQuery(sql);
890
891 QueryPos qPos = QueryPos.getInstance(q);
892
893 qPos.add(tableId);
894
895 count = (Long)q.uniqueResult();
896
897 finderCache.putResult(finderPath, finderArgs, count);
898 }
899 catch (Exception e) {
900 finderCache.removeResult(finderPath, finderArgs);
901
902 throw processException(e);
903 }
904 finally {
905 closeSession(session);
906 }
907 }
908
909 return count.intValue();
910 }
911
912
918 @Override
919 public int filterCountByTableId(long tableId) {
920 if (!InlineSQLHelperUtil.isEnabled()) {
921 return countByTableId(tableId);
922 }
923
924 StringBundler query = new StringBundler(2);
925
926 query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
927
928 query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
929
930 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
931 ExpandoColumn.class.getName(),
932 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
933
934 Session session = null;
935
936 try {
937 session = openSession();
938
939 SQLQuery q = session.createSynchronizedSQLQuery(sql);
940
941 q.addScalar(COUNT_COLUMN_NAME,
942 com.liferay.portal.kernel.dao.orm.Type.LONG);
943
944 QueryPos qPos = QueryPos.getInstance(q);
945
946 qPos.add(tableId);
947
948 Long count = (Long)q.uniqueResult();
949
950 return count.intValue();
951 }
952 catch (Exception e) {
953 throw processException(e);
954 }
955 finally {
956 closeSession(session);
957 }
958 }
959
960 private static final String _FINDER_COLUMN_TABLEID_TABLEID_2 = "expandoColumn.tableId = ?";
961 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
962 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
963 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
964 "findByT_N",
965 new String[] {
966 Long.class.getName(), String.class.getName(),
967
968 Integer.class.getName(), Integer.class.getName(),
969 OrderByComparator.class.getName()
970 });
971 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
972 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
973 ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
974 "findByT_N",
975 new String[] { Long.class.getName(), String.class.getName() },
976 ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
977 ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
978 public static final FinderPath FINDER_PATH_FETCH_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
979 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
980 ExpandoColumnImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByT_N",
981 new String[] { Long.class.getName(), String.class.getName() },
982 ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
983 ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
984 public static final FinderPath FINDER_PATH_COUNT_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
985 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
986 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_N",
987 new String[] { Long.class.getName(), String.class.getName() });
988 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
989 ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
990 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByT_N",
991 new String[] { Long.class.getName(), String.class.getName() });
992
993
1004 @Override
1005 public List<ExpandoColumn> findByT_N(long tableId, String[] names) {
1006 return findByT_N(tableId, names, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1007 null);
1008 }
1009
1010
1023 @Override
1024 public List<ExpandoColumn> findByT_N(long tableId, String[] names,
1025 int start, int end) {
1026 return findByT_N(tableId, names, start, end, null);
1027 }
1028
1029
1043 @Override
1044 public List<ExpandoColumn> findByT_N(long tableId, String[] names,
1045 int start, int end, OrderByComparator<ExpandoColumn> orderByComparator) {
1046 return findByT_N(tableId, names, start, end, orderByComparator, true);
1047 }
1048
1049
1064 @Override
1065 public List<ExpandoColumn> findByT_N(long tableId, String[] names,
1066 int start, int end, OrderByComparator<ExpandoColumn> orderByComparator,
1067 boolean retrieveFromCache) {
1068 if (names == null) {
1069 names = new String[0];
1070 }
1071 else if (names.length > 1) {
1072 names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1073
1074 Arrays.sort(names, NULL_SAFE_STRING_COMPARATOR);
1075 }
1076
1077 if (names.length == 1) {
1078 ExpandoColumn expandoColumn = fetchByT_N(tableId, names[0]);
1079
1080 if (expandoColumn == null) {
1081 return Collections.emptyList();
1082 }
1083 else {
1084 List<ExpandoColumn> list = new ArrayList<ExpandoColumn>(1);
1085
1086 list.add(expandoColumn);
1087
1088 return list;
1089 }
1090 }
1091
1092 boolean pagination = true;
1093 Object[] finderArgs = null;
1094
1095 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1096 (orderByComparator == null)) {
1097 pagination = false;
1098 finderArgs = new Object[] { tableId, StringUtil.merge(names) };
1099 }
1100 else {
1101 finderArgs = new Object[] {
1102 tableId, StringUtil.merge(names),
1103
1104 start, end, orderByComparator
1105 };
1106 }
1107
1108 List<ExpandoColumn> list = null;
1109
1110 if (retrieveFromCache) {
1111 list = (List<ExpandoColumn>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1112 finderArgs, this);
1113
1114 if ((list != null) && !list.isEmpty()) {
1115 for (ExpandoColumn expandoColumn : list) {
1116 if ((tableId != expandoColumn.getTableId()) ||
1117 !ArrayUtil.contains(names, expandoColumn.getName())) {
1118 list = null;
1119
1120 break;
1121 }
1122 }
1123 }
1124 }
1125
1126 if (list == null) {
1127 StringBundler query = new StringBundler();
1128
1129 query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
1130
1131 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1132
1133 if (names.length > 0) {
1134 query.append(StringPool.OPEN_PARENTHESIS);
1135
1136 for (int i = 0; i < names.length; i++) {
1137 String name = names[i];
1138
1139 if (name == null) {
1140 query.append(_FINDER_COLUMN_T_N_NAME_1);
1141 }
1142 else if (name.equals(StringPool.BLANK)) {
1143 query.append(_FINDER_COLUMN_T_N_NAME_3);
1144 }
1145 else {
1146 query.append(_FINDER_COLUMN_T_N_NAME_2);
1147 }
1148
1149 if ((i + 1) < names.length) {
1150 query.append(WHERE_OR);
1151 }
1152 }
1153
1154 query.append(StringPool.CLOSE_PARENTHESIS);
1155 }
1156
1157 query.setStringAt(removeConjunction(query.stringAt(query.index() -
1158 1)), query.index() - 1);
1159
1160 if (orderByComparator != null) {
1161 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162 orderByComparator);
1163 }
1164 else
1165 if (pagination) {
1166 query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
1167 }
1168
1169 String sql = query.toString();
1170
1171 Session session = null;
1172
1173 try {
1174 session = openSession();
1175
1176 Query q = session.createQuery(sql);
1177
1178 QueryPos qPos = QueryPos.getInstance(q);
1179
1180 qPos.add(tableId);
1181
1182 for (String name : names) {
1183 if ((name != null) && !name.isEmpty()) {
1184 qPos.add(name);
1185 }
1186 }
1187
1188 if (!pagination) {
1189 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
1190 start, end, false);
1191
1192 Collections.sort(list);
1193
1194 list = Collections.unmodifiableList(list);
1195 }
1196 else {
1197 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
1198 start, end);
1199 }
1200
1201 cacheResult(list);
1202
1203 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1204 finderArgs, list);
1205 }
1206 catch (Exception e) {
1207 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1208 finderArgs);
1209
1210 throw processException(e);
1211 }
1212 finally {
1213 closeSession(session);
1214 }
1215 }
1216
1217 return list;
1218 }
1219
1220
1228 @Override
1229 public ExpandoColumn findByT_N(long tableId, String name)
1230 throws NoSuchColumnException {
1231 ExpandoColumn expandoColumn = fetchByT_N(tableId, name);
1232
1233 if (expandoColumn == null) {
1234 StringBundler msg = new StringBundler(6);
1235
1236 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1237
1238 msg.append("tableId=");
1239 msg.append(tableId);
1240
1241 msg.append(", name=");
1242 msg.append(name);
1243
1244 msg.append(StringPool.CLOSE_CURLY_BRACE);
1245
1246 if (_log.isWarnEnabled()) {
1247 _log.warn(msg.toString());
1248 }
1249
1250 throw new NoSuchColumnException(msg.toString());
1251 }
1252
1253 return expandoColumn;
1254 }
1255
1256
1263 @Override
1264 public ExpandoColumn fetchByT_N(long tableId, String name) {
1265 return fetchByT_N(tableId, name, true);
1266 }
1267
1268
1276 @Override
1277 public ExpandoColumn fetchByT_N(long tableId, String name,
1278 boolean retrieveFromCache) {
1279 Object[] finderArgs = new Object[] { tableId, name };
1280
1281 Object result = null;
1282
1283 if (retrieveFromCache) {
1284 result = finderCache.getResult(FINDER_PATH_FETCH_BY_T_N,
1285 finderArgs, this);
1286 }
1287
1288 if (result instanceof ExpandoColumn) {
1289 ExpandoColumn expandoColumn = (ExpandoColumn)result;
1290
1291 if ((tableId != expandoColumn.getTableId()) ||
1292 !Validator.equals(name, expandoColumn.getName())) {
1293 result = null;
1294 }
1295 }
1296
1297 if (result == null) {
1298 StringBundler query = new StringBundler(4);
1299
1300 query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
1301
1302 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1303
1304 boolean bindName = false;
1305
1306 if (name == null) {
1307 query.append(_FINDER_COLUMN_T_N_NAME_1);
1308 }
1309 else if (name.equals(StringPool.BLANK)) {
1310 query.append(_FINDER_COLUMN_T_N_NAME_3);
1311 }
1312 else {
1313 bindName = true;
1314
1315 query.append(_FINDER_COLUMN_T_N_NAME_2);
1316 }
1317
1318 String sql = query.toString();
1319
1320 Session session = null;
1321
1322 try {
1323 session = openSession();
1324
1325 Query q = session.createQuery(sql);
1326
1327 QueryPos qPos = QueryPos.getInstance(q);
1328
1329 qPos.add(tableId);
1330
1331 if (bindName) {
1332 qPos.add(name);
1333 }
1334
1335 List<ExpandoColumn> list = q.list();
1336
1337 if (list.isEmpty()) {
1338 finderCache.putResult(FINDER_PATH_FETCH_BY_T_N, finderArgs,
1339 list);
1340 }
1341 else {
1342 ExpandoColumn expandoColumn = list.get(0);
1343
1344 result = expandoColumn;
1345
1346 cacheResult(expandoColumn);
1347
1348 if ((expandoColumn.getTableId() != tableId) ||
1349 (expandoColumn.getName() == null) ||
1350 !expandoColumn.getName().equals(name)) {
1351 finderCache.putResult(FINDER_PATH_FETCH_BY_T_N,
1352 finderArgs, expandoColumn);
1353 }
1354 }
1355 }
1356 catch (Exception e) {
1357 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_N, finderArgs);
1358
1359 throw processException(e);
1360 }
1361 finally {
1362 closeSession(session);
1363 }
1364 }
1365
1366 if (result instanceof List<?>) {
1367 return null;
1368 }
1369 else {
1370 return (ExpandoColumn)result;
1371 }
1372 }
1373
1374
1381 @Override
1382 public ExpandoColumn removeByT_N(long tableId, String name)
1383 throws NoSuchColumnException {
1384 ExpandoColumn expandoColumn = findByT_N(tableId, name);
1385
1386 return remove(expandoColumn);
1387 }
1388
1389
1396 @Override
1397 public int countByT_N(long tableId, String name) {
1398 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_N;
1399
1400 Object[] finderArgs = new Object[] { tableId, name };
1401
1402 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1403
1404 if (count == null) {
1405 StringBundler query = new StringBundler(3);
1406
1407 query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1408
1409 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1410
1411 boolean bindName = false;
1412
1413 if (name == null) {
1414 query.append(_FINDER_COLUMN_T_N_NAME_1);
1415 }
1416 else if (name.equals(StringPool.BLANK)) {
1417 query.append(_FINDER_COLUMN_T_N_NAME_3);
1418 }
1419 else {
1420 bindName = true;
1421
1422 query.append(_FINDER_COLUMN_T_N_NAME_2);
1423 }
1424
1425 String sql = query.toString();
1426
1427 Session session = null;
1428
1429 try {
1430 session = openSession();
1431
1432 Query q = session.createQuery(sql);
1433
1434 QueryPos qPos = QueryPos.getInstance(q);
1435
1436 qPos.add(tableId);
1437
1438 if (bindName) {
1439 qPos.add(name);
1440 }
1441
1442 count = (Long)q.uniqueResult();
1443
1444 finderCache.putResult(finderPath, finderArgs, count);
1445 }
1446 catch (Exception e) {
1447 finderCache.removeResult(finderPath, finderArgs);
1448
1449 throw processException(e);
1450 }
1451 finally {
1452 closeSession(session);
1453 }
1454 }
1455
1456 return count.intValue();
1457 }
1458
1459
1466 @Override
1467 public int countByT_N(long tableId, String[] names) {
1468 if (names == null) {
1469 names = new String[0];
1470 }
1471 else if (names.length > 1) {
1472 names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1473
1474 Arrays.sort(names, NULL_SAFE_STRING_COMPARATOR);
1475 }
1476
1477 Object[] finderArgs = new Object[] { tableId, StringUtil.merge(names) };
1478
1479 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1480 finderArgs, this);
1481
1482 if (count == null) {
1483 StringBundler query = new StringBundler();
1484
1485 query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1486
1487 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1488
1489 if (names.length > 0) {
1490 query.append(StringPool.OPEN_PARENTHESIS);
1491
1492 for (int i = 0; i < names.length; i++) {
1493 String name = names[i];
1494
1495 if (name == null) {
1496 query.append(_FINDER_COLUMN_T_N_NAME_1);
1497 }
1498 else if (name.equals(StringPool.BLANK)) {
1499 query.append(_FINDER_COLUMN_T_N_NAME_3);
1500 }
1501 else {
1502 query.append(_FINDER_COLUMN_T_N_NAME_2);
1503 }
1504
1505 if ((i + 1) < names.length) {
1506 query.append(WHERE_OR);
1507 }
1508 }
1509
1510 query.append(StringPool.CLOSE_PARENTHESIS);
1511 }
1512
1513 query.setStringAt(removeConjunction(query.stringAt(query.index() -
1514 1)), query.index() - 1);
1515
1516 String sql = query.toString();
1517
1518 Session session = null;
1519
1520 try {
1521 session = openSession();
1522
1523 Query q = session.createQuery(sql);
1524
1525 QueryPos qPos = QueryPos.getInstance(q);
1526
1527 qPos.add(tableId);
1528
1529 for (String name : names) {
1530 if ((name != null) && !name.isEmpty()) {
1531 qPos.add(name);
1532 }
1533 }
1534
1535 count = (Long)q.uniqueResult();
1536
1537 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1538 finderArgs, count);
1539 }
1540 catch (Exception e) {
1541 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1542 finderArgs);
1543
1544 throw processException(e);
1545 }
1546 finally {
1547 closeSession(session);
1548 }
1549 }
1550
1551 return count.intValue();
1552 }
1553
1554
1561 @Override
1562 public int filterCountByT_N(long tableId, String name) {
1563 if (!InlineSQLHelperUtil.isEnabled()) {
1564 return countByT_N(tableId, name);
1565 }
1566
1567 StringBundler query = new StringBundler(3);
1568
1569 query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1570
1571 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1572
1573 boolean bindName = false;
1574
1575 if (name == null) {
1576 query.append(_FINDER_COLUMN_T_N_NAME_1);
1577 }
1578 else if (name.equals(StringPool.BLANK)) {
1579 query.append(_FINDER_COLUMN_T_N_NAME_3);
1580 }
1581 else {
1582 bindName = true;
1583
1584 query.append(_FINDER_COLUMN_T_N_NAME_2);
1585 }
1586
1587 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1588 ExpandoColumn.class.getName(),
1589 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1590
1591 Session session = null;
1592
1593 try {
1594 session = openSession();
1595
1596 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1597
1598 q.addScalar(COUNT_COLUMN_NAME,
1599 com.liferay.portal.kernel.dao.orm.Type.LONG);
1600
1601 QueryPos qPos = QueryPos.getInstance(q);
1602
1603 qPos.add(tableId);
1604
1605 if (bindName) {
1606 qPos.add(name);
1607 }
1608
1609 Long count = (Long)q.uniqueResult();
1610
1611 return count.intValue();
1612 }
1613 catch (Exception e) {
1614 throw processException(e);
1615 }
1616 finally {
1617 closeSession(session);
1618 }
1619 }
1620
1621
1628 @Override
1629 public int filterCountByT_N(long tableId, String[] names) {
1630 if (!InlineSQLHelperUtil.isEnabled()) {
1631 return countByT_N(tableId, names);
1632 }
1633
1634 if (names == null) {
1635 names = new String[0];
1636 }
1637 else if (names.length > 1) {
1638 names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1639
1640 Arrays.sort(names, NULL_SAFE_STRING_COMPARATOR);
1641 }
1642
1643 StringBundler query = new StringBundler();
1644
1645 query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1646
1647 query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1648
1649 if (names.length > 0) {
1650 query.append(StringPool.OPEN_PARENTHESIS);
1651
1652 for (int i = 0; i < names.length; i++) {
1653 String name = names[i];
1654
1655 if (name == null) {
1656 query.append(_FINDER_COLUMN_T_N_NAME_1);
1657 }
1658 else if (name.equals(StringPool.BLANK)) {
1659 query.append(_FINDER_COLUMN_T_N_NAME_3);
1660 }
1661 else {
1662 query.append(_FINDER_COLUMN_T_N_NAME_2);
1663 }
1664
1665 if ((i + 1) < names.length) {
1666 query.append(WHERE_OR);
1667 }
1668 }
1669
1670 query.append(StringPool.CLOSE_PARENTHESIS);
1671 }
1672
1673 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
1674 query.index() - 1);
1675
1676 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1677 ExpandoColumn.class.getName(),
1678 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1679
1680 Session session = null;
1681
1682 try {
1683 session = openSession();
1684
1685 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1686
1687 q.addScalar(COUNT_COLUMN_NAME,
1688 com.liferay.portal.kernel.dao.orm.Type.LONG);
1689
1690 QueryPos qPos = QueryPos.getInstance(q);
1691
1692 qPos.add(tableId);
1693
1694 for (String name : names) {
1695 if ((name != null) && !name.isEmpty()) {
1696 qPos.add(name);
1697 }
1698 }
1699
1700 Long count = (Long)q.uniqueResult();
1701
1702 return count.intValue();
1703 }
1704 catch (Exception e) {
1705 throw processException(e);
1706 }
1707 finally {
1708 closeSession(session);
1709 }
1710 }
1711
1712 private static final String _FINDER_COLUMN_T_N_TABLEID_2 = "expandoColumn.tableId = ? AND ";
1713 private static final String _FINDER_COLUMN_T_N_NAME_1 = "expandoColumn.name IS NULL";
1714 private static final String _FINDER_COLUMN_T_N_NAME_2 = "expandoColumn.name = ?";
1715 private static final String _FINDER_COLUMN_T_N_NAME_3 = "(expandoColumn.name IS NULL OR expandoColumn.name = '')";
1716
1717 public ExpandoColumnPersistenceImpl() {
1718 setModelClass(ExpandoColumn.class);
1719 }
1720
1721
1726 @Override
1727 public void cacheResult(ExpandoColumn expandoColumn) {
1728 entityCache.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1729 ExpandoColumnImpl.class, expandoColumn.getPrimaryKey(),
1730 expandoColumn);
1731
1732 finderCache.putResult(FINDER_PATH_FETCH_BY_T_N,
1733 new Object[] { expandoColumn.getTableId(), expandoColumn.getName() },
1734 expandoColumn);
1735
1736 expandoColumn.resetOriginalValues();
1737 }
1738
1739
1744 @Override
1745 public void cacheResult(List<ExpandoColumn> expandoColumns) {
1746 for (ExpandoColumn expandoColumn : expandoColumns) {
1747 if (entityCache.getResult(
1748 ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1749 ExpandoColumnImpl.class, expandoColumn.getPrimaryKey()) == null) {
1750 cacheResult(expandoColumn);
1751 }
1752 else {
1753 expandoColumn.resetOriginalValues();
1754 }
1755 }
1756 }
1757
1758
1765 @Override
1766 public void clearCache() {
1767 entityCache.clearCache(ExpandoColumnImpl.class);
1768
1769 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
1770 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1771 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1772 }
1773
1774
1781 @Override
1782 public void clearCache(ExpandoColumn expandoColumn) {
1783 entityCache.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1784 ExpandoColumnImpl.class, expandoColumn.getPrimaryKey());
1785
1786 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1787 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1788
1789 clearUniqueFindersCache((ExpandoColumnModelImpl)expandoColumn);
1790 }
1791
1792 @Override
1793 public void clearCache(List<ExpandoColumn> expandoColumns) {
1794 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1795 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1796
1797 for (ExpandoColumn expandoColumn : expandoColumns) {
1798 entityCache.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1799 ExpandoColumnImpl.class, expandoColumn.getPrimaryKey());
1800
1801 clearUniqueFindersCache((ExpandoColumnModelImpl)expandoColumn);
1802 }
1803 }
1804
1805 protected void cacheUniqueFindersCache(
1806 ExpandoColumnModelImpl expandoColumnModelImpl, boolean isNew) {
1807 if (isNew) {
1808 Object[] args = new Object[] {
1809 expandoColumnModelImpl.getTableId(),
1810 expandoColumnModelImpl.getName()
1811 };
1812
1813 finderCache.putResult(FINDER_PATH_COUNT_BY_T_N, args,
1814 Long.valueOf(1));
1815 finderCache.putResult(FINDER_PATH_FETCH_BY_T_N, args,
1816 expandoColumnModelImpl);
1817 }
1818 else {
1819 if ((expandoColumnModelImpl.getColumnBitmask() &
1820 FINDER_PATH_FETCH_BY_T_N.getColumnBitmask()) != 0) {
1821 Object[] args = new Object[] {
1822 expandoColumnModelImpl.getTableId(),
1823 expandoColumnModelImpl.getName()
1824 };
1825
1826 finderCache.putResult(FINDER_PATH_COUNT_BY_T_N, args,
1827 Long.valueOf(1));
1828 finderCache.putResult(FINDER_PATH_FETCH_BY_T_N, args,
1829 expandoColumnModelImpl);
1830 }
1831 }
1832 }
1833
1834 protected void clearUniqueFindersCache(
1835 ExpandoColumnModelImpl expandoColumnModelImpl) {
1836 Object[] args = new Object[] {
1837 expandoColumnModelImpl.getTableId(),
1838 expandoColumnModelImpl.getName()
1839 };
1840
1841 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1842 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_N, args);
1843
1844 if ((expandoColumnModelImpl.getColumnBitmask() &
1845 FINDER_PATH_FETCH_BY_T_N.getColumnBitmask()) != 0) {
1846 args = new Object[] {
1847 expandoColumnModelImpl.getOriginalTableId(),
1848 expandoColumnModelImpl.getOriginalName()
1849 };
1850
1851 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1852 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_N, args);
1853 }
1854 }
1855
1856
1862 @Override
1863 public ExpandoColumn create(long columnId) {
1864 ExpandoColumn expandoColumn = new ExpandoColumnImpl();
1865
1866 expandoColumn.setNew(true);
1867 expandoColumn.setPrimaryKey(columnId);
1868
1869 expandoColumn.setCompanyId(companyProvider.getCompanyId());
1870
1871 return expandoColumn;
1872 }
1873
1874
1881 @Override
1882 public ExpandoColumn remove(long columnId) throws NoSuchColumnException {
1883 return remove((Serializable)columnId);
1884 }
1885
1886
1893 @Override
1894 public ExpandoColumn remove(Serializable primaryKey)
1895 throws NoSuchColumnException {
1896 Session session = null;
1897
1898 try {
1899 session = openSession();
1900
1901 ExpandoColumn expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
1902 primaryKey);
1903
1904 if (expandoColumn == null) {
1905 if (_log.isWarnEnabled()) {
1906 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1907 }
1908
1909 throw new NoSuchColumnException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1910 primaryKey);
1911 }
1912
1913 return remove(expandoColumn);
1914 }
1915 catch (NoSuchColumnException nsee) {
1916 throw nsee;
1917 }
1918 catch (Exception e) {
1919 throw processException(e);
1920 }
1921 finally {
1922 closeSession(session);
1923 }
1924 }
1925
1926 @Override
1927 protected ExpandoColumn removeImpl(ExpandoColumn expandoColumn) {
1928 expandoColumn = toUnwrappedModel(expandoColumn);
1929
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 if (!session.contains(expandoColumn)) {
1936 expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
1937 expandoColumn.getPrimaryKeyObj());
1938 }
1939
1940 if (expandoColumn != null) {
1941 session.delete(expandoColumn);
1942 }
1943 }
1944 catch (Exception e) {
1945 throw processException(e);
1946 }
1947 finally {
1948 closeSession(session);
1949 }
1950
1951 if (expandoColumn != null) {
1952 clearCache(expandoColumn);
1953 }
1954
1955 return expandoColumn;
1956 }
1957
1958 @Override
1959 public ExpandoColumn updateImpl(ExpandoColumn expandoColumn) {
1960 expandoColumn = toUnwrappedModel(expandoColumn);
1961
1962 boolean isNew = expandoColumn.isNew();
1963
1964 ExpandoColumnModelImpl expandoColumnModelImpl = (ExpandoColumnModelImpl)expandoColumn;
1965
1966 Session session = null;
1967
1968 try {
1969 session = openSession();
1970
1971 if (expandoColumn.isNew()) {
1972 session.save(expandoColumn);
1973
1974 expandoColumn.setNew(false);
1975 }
1976 else {
1977 expandoColumn = (ExpandoColumn)session.merge(expandoColumn);
1978 }
1979 }
1980 catch (Exception e) {
1981 throw processException(e);
1982 }
1983 finally {
1984 closeSession(session);
1985 }
1986
1987 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1988
1989 if (isNew || !ExpandoColumnModelImpl.COLUMN_BITMASK_ENABLED) {
1990 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1991 }
1992
1993 else {
1994 if ((expandoColumnModelImpl.getColumnBitmask() &
1995 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID.getColumnBitmask()) != 0) {
1996 Object[] args = new Object[] {
1997 expandoColumnModelImpl.getOriginalTableId()
1998 };
1999
2000 finderCache.removeResult(FINDER_PATH_COUNT_BY_TABLEID, args);
2001 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID,
2002 args);
2003
2004 args = new Object[] { expandoColumnModelImpl.getTableId() };
2005
2006 finderCache.removeResult(FINDER_PATH_COUNT_BY_TABLEID, args);
2007 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID,
2008 args);
2009 }
2010
2011 if ((expandoColumnModelImpl.getColumnBitmask() &
2012 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N.getColumnBitmask()) != 0) {
2013 Object[] args = new Object[] {
2014 expandoColumnModelImpl.getOriginalTableId(),
2015 expandoColumnModelImpl.getOriginalName()
2016 };
2017
2018 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
2019 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N,
2020 args);
2021
2022 args = new Object[] {
2023 expandoColumnModelImpl.getTableId(),
2024 expandoColumnModelImpl.getName()
2025 };
2026
2027 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
2028 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N,
2029 args);
2030 }
2031 }
2032
2033 entityCache.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2034 ExpandoColumnImpl.class, expandoColumn.getPrimaryKey(),
2035 expandoColumn, false);
2036
2037 clearUniqueFindersCache(expandoColumnModelImpl);
2038 cacheUniqueFindersCache(expandoColumnModelImpl, isNew);
2039
2040 expandoColumn.resetOriginalValues();
2041
2042 return expandoColumn;
2043 }
2044
2045 protected ExpandoColumn toUnwrappedModel(ExpandoColumn expandoColumn) {
2046 if (expandoColumn instanceof ExpandoColumnImpl) {
2047 return expandoColumn;
2048 }
2049
2050 ExpandoColumnImpl expandoColumnImpl = new ExpandoColumnImpl();
2051
2052 expandoColumnImpl.setNew(expandoColumn.isNew());
2053 expandoColumnImpl.setPrimaryKey(expandoColumn.getPrimaryKey());
2054
2055 expandoColumnImpl.setColumnId(expandoColumn.getColumnId());
2056 expandoColumnImpl.setCompanyId(expandoColumn.getCompanyId());
2057 expandoColumnImpl.setTableId(expandoColumn.getTableId());
2058 expandoColumnImpl.setName(expandoColumn.getName());
2059 expandoColumnImpl.setType(expandoColumn.getType());
2060 expandoColumnImpl.setDefaultData(expandoColumn.getDefaultData());
2061 expandoColumnImpl.setTypeSettings(expandoColumn.getTypeSettings());
2062
2063 return expandoColumnImpl;
2064 }
2065
2066
2073 @Override
2074 public ExpandoColumn findByPrimaryKey(Serializable primaryKey)
2075 throws NoSuchColumnException {
2076 ExpandoColumn expandoColumn = fetchByPrimaryKey(primaryKey);
2077
2078 if (expandoColumn == null) {
2079 if (_log.isWarnEnabled()) {
2080 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2081 }
2082
2083 throw new NoSuchColumnException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2084 primaryKey);
2085 }
2086
2087 return expandoColumn;
2088 }
2089
2090
2097 @Override
2098 public ExpandoColumn findByPrimaryKey(long columnId)
2099 throws NoSuchColumnException {
2100 return findByPrimaryKey((Serializable)columnId);
2101 }
2102
2103
2109 @Override
2110 public ExpandoColumn fetchByPrimaryKey(Serializable primaryKey) {
2111 ExpandoColumn expandoColumn = (ExpandoColumn)entityCache.getResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2112 ExpandoColumnImpl.class, primaryKey);
2113
2114 if (expandoColumn == _nullExpandoColumn) {
2115 return null;
2116 }
2117
2118 if (expandoColumn == null) {
2119 Session session = null;
2120
2121 try {
2122 session = openSession();
2123
2124 expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
2125 primaryKey);
2126
2127 if (expandoColumn != null) {
2128 cacheResult(expandoColumn);
2129 }
2130 else {
2131 entityCache.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2132 ExpandoColumnImpl.class, primaryKey, _nullExpandoColumn);
2133 }
2134 }
2135 catch (Exception e) {
2136 entityCache.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2137 ExpandoColumnImpl.class, primaryKey);
2138
2139 throw processException(e);
2140 }
2141 finally {
2142 closeSession(session);
2143 }
2144 }
2145
2146 return expandoColumn;
2147 }
2148
2149
2155 @Override
2156 public ExpandoColumn fetchByPrimaryKey(long columnId) {
2157 return fetchByPrimaryKey((Serializable)columnId);
2158 }
2159
2160 @Override
2161 public Map<Serializable, ExpandoColumn> fetchByPrimaryKeys(
2162 Set<Serializable> primaryKeys) {
2163 if (primaryKeys.isEmpty()) {
2164 return Collections.emptyMap();
2165 }
2166
2167 Map<Serializable, ExpandoColumn> map = new HashMap<Serializable, ExpandoColumn>();
2168
2169 if (primaryKeys.size() == 1) {
2170 Iterator<Serializable> iterator = primaryKeys.iterator();
2171
2172 Serializable primaryKey = iterator.next();
2173
2174 ExpandoColumn expandoColumn = fetchByPrimaryKey(primaryKey);
2175
2176 if (expandoColumn != null) {
2177 map.put(primaryKey, expandoColumn);
2178 }
2179
2180 return map;
2181 }
2182
2183 Set<Serializable> uncachedPrimaryKeys = null;
2184
2185 for (Serializable primaryKey : primaryKeys) {
2186 ExpandoColumn expandoColumn = (ExpandoColumn)entityCache.getResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2187 ExpandoColumnImpl.class, primaryKey);
2188
2189 if (expandoColumn == null) {
2190 if (uncachedPrimaryKeys == null) {
2191 uncachedPrimaryKeys = new HashSet<Serializable>();
2192 }
2193
2194 uncachedPrimaryKeys.add(primaryKey);
2195 }
2196 else {
2197 map.put(primaryKey, expandoColumn);
2198 }
2199 }
2200
2201 if (uncachedPrimaryKeys == null) {
2202 return map;
2203 }
2204
2205 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2206 1);
2207
2208 query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE_PKS_IN);
2209
2210 for (Serializable primaryKey : uncachedPrimaryKeys) {
2211 query.append(String.valueOf(primaryKey));
2212
2213 query.append(StringPool.COMMA);
2214 }
2215
2216 query.setIndex(query.index() - 1);
2217
2218 query.append(StringPool.CLOSE_PARENTHESIS);
2219
2220 String sql = query.toString();
2221
2222 Session session = null;
2223
2224 try {
2225 session = openSession();
2226
2227 Query q = session.createQuery(sql);
2228
2229 for (ExpandoColumn expandoColumn : (List<ExpandoColumn>)q.list()) {
2230 map.put(expandoColumn.getPrimaryKeyObj(), expandoColumn);
2231
2232 cacheResult(expandoColumn);
2233
2234 uncachedPrimaryKeys.remove(expandoColumn.getPrimaryKeyObj());
2235 }
2236
2237 for (Serializable primaryKey : uncachedPrimaryKeys) {
2238 entityCache.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2239 ExpandoColumnImpl.class, primaryKey, _nullExpandoColumn);
2240 }
2241 }
2242 catch (Exception e) {
2243 throw processException(e);
2244 }
2245 finally {
2246 closeSession(session);
2247 }
2248
2249 return map;
2250 }
2251
2252
2257 @Override
2258 public List<ExpandoColumn> findAll() {
2259 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2260 }
2261
2262
2273 @Override
2274 public List<ExpandoColumn> findAll(int start, int end) {
2275 return findAll(start, end, null);
2276 }
2277
2278
2290 @Override
2291 public List<ExpandoColumn> findAll(int start, int end,
2292 OrderByComparator<ExpandoColumn> orderByComparator) {
2293 return findAll(start, end, orderByComparator, true);
2294 }
2295
2296
2309 @Override
2310 public List<ExpandoColumn> findAll(int start, int end,
2311 OrderByComparator<ExpandoColumn> orderByComparator,
2312 boolean retrieveFromCache) {
2313 boolean pagination = true;
2314 FinderPath finderPath = null;
2315 Object[] finderArgs = null;
2316
2317 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2318 (orderByComparator == null)) {
2319 pagination = false;
2320 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2321 finderArgs = FINDER_ARGS_EMPTY;
2322 }
2323 else {
2324 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2325 finderArgs = new Object[] { start, end, orderByComparator };
2326 }
2327
2328 List<ExpandoColumn> list = null;
2329
2330 if (retrieveFromCache) {
2331 list = (List<ExpandoColumn>)finderCache.getResult(finderPath,
2332 finderArgs, this);
2333 }
2334
2335 if (list == null) {
2336 StringBundler query = null;
2337 String sql = null;
2338
2339 if (orderByComparator != null) {
2340 query = new StringBundler(2 +
2341 (orderByComparator.getOrderByFields().length * 3));
2342
2343 query.append(_SQL_SELECT_EXPANDOCOLUMN);
2344
2345 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2346 orderByComparator);
2347
2348 sql = query.toString();
2349 }
2350 else {
2351 sql = _SQL_SELECT_EXPANDOCOLUMN;
2352
2353 if (pagination) {
2354 sql = sql.concat(ExpandoColumnModelImpl.ORDER_BY_JPQL);
2355 }
2356 }
2357
2358 Session session = null;
2359
2360 try {
2361 session = openSession();
2362
2363 Query q = session.createQuery(sql);
2364
2365 if (!pagination) {
2366 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
2367 start, end, false);
2368
2369 Collections.sort(list);
2370
2371 list = Collections.unmodifiableList(list);
2372 }
2373 else {
2374 list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
2375 start, end);
2376 }
2377
2378 cacheResult(list);
2379
2380 finderCache.putResult(finderPath, finderArgs, list);
2381 }
2382 catch (Exception e) {
2383 finderCache.removeResult(finderPath, finderArgs);
2384
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391
2392 return list;
2393 }
2394
2395
2399 @Override
2400 public void removeAll() {
2401 for (ExpandoColumn expandoColumn : findAll()) {
2402 remove(expandoColumn);
2403 }
2404 }
2405
2406
2411 @Override
2412 public int countAll() {
2413 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2414 FINDER_ARGS_EMPTY, this);
2415
2416 if (count == null) {
2417 Session session = null;
2418
2419 try {
2420 session = openSession();
2421
2422 Query q = session.createQuery(_SQL_COUNT_EXPANDOCOLUMN);
2423
2424 count = (Long)q.uniqueResult();
2425
2426 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2427 count);
2428 }
2429 catch (Exception e) {
2430 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2431 FINDER_ARGS_EMPTY);
2432
2433 throw processException(e);
2434 }
2435 finally {
2436 closeSession(session);
2437 }
2438 }
2439
2440 return count.intValue();
2441 }
2442
2443 @Override
2444 public Set<String> getBadColumnNames() {
2445 return _badColumnNames;
2446 }
2447
2448 @Override
2449 protected Map<String, Integer> getTableColumnsMap() {
2450 return ExpandoColumnModelImpl.TABLE_COLUMNS_MAP;
2451 }
2452
2453
2456 public void afterPropertiesSet() {
2457 }
2458
2459 public void destroy() {
2460 entityCache.removeCache(ExpandoColumnImpl.class.getName());
2461 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2462 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2463 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2464 }
2465
2466 @BeanReference(type = CompanyProviderWrapper.class)
2467 protected CompanyProvider companyProvider;
2468 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2469 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2470 private static final String _SQL_SELECT_EXPANDOCOLUMN = "SELECT expandoColumn FROM ExpandoColumn expandoColumn";
2471 private static final String _SQL_SELECT_EXPANDOCOLUMN_WHERE_PKS_IN = "SELECT expandoColumn FROM ExpandoColumn expandoColumn WHERE columnId IN (";
2472 private static final String _SQL_SELECT_EXPANDOCOLUMN_WHERE = "SELECT expandoColumn FROM ExpandoColumn expandoColumn WHERE ";
2473 private static final String _SQL_COUNT_EXPANDOCOLUMN = "SELECT COUNT(expandoColumn) FROM ExpandoColumn expandoColumn";
2474 private static final String _SQL_COUNT_EXPANDOCOLUMN_WHERE = "SELECT COUNT(expandoColumn) FROM ExpandoColumn expandoColumn WHERE ";
2475 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "expandoColumn.columnId";
2476 private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE = "SELECT DISTINCT {expandoColumn.*} FROM ExpandoColumn expandoColumn WHERE ";
2477 private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1 =
2478 "SELECT {ExpandoColumn.*} FROM (SELECT DISTINCT expandoColumn.columnId FROM ExpandoColumn expandoColumn WHERE ";
2479 private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2 =
2480 ") TEMP_TABLE INNER JOIN ExpandoColumn ON TEMP_TABLE.columnId = ExpandoColumn.columnId";
2481 private static final String _FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE = "SELECT COUNT(DISTINCT expandoColumn.columnId) AS COUNT_VALUE FROM ExpandoColumn expandoColumn WHERE ";
2482 private static final String _FILTER_ENTITY_ALIAS = "expandoColumn";
2483 private static final String _FILTER_ENTITY_TABLE = "ExpandoColumn";
2484 private static final String _ORDER_BY_ENTITY_ALIAS = "expandoColumn.";
2485 private static final String _ORDER_BY_ENTITY_TABLE = "ExpandoColumn.";
2486 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ExpandoColumn exists with the primary key ";
2487 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ExpandoColumn exists with the key {";
2488 private static final Log _log = LogFactoryUtil.getLog(ExpandoColumnPersistenceImpl.class);
2489 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2490 "type"
2491 });
2492 private static final ExpandoColumn _nullExpandoColumn = new ExpandoColumnImpl() {
2493 @Override
2494 public Object clone() {
2495 return this;
2496 }
2497
2498 @Override
2499 public CacheModel<ExpandoColumn> toCacheModel() {
2500 return _nullExpandoColumnCacheModel;
2501 }
2502 };
2503
2504 private static final CacheModel<ExpandoColumn> _nullExpandoColumnCacheModel = new CacheModel<ExpandoColumn>() {
2505 @Override
2506 public ExpandoColumn toEntityModel() {
2507 return _nullExpandoColumn;
2508 }
2509 };
2510 }