001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
038    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039    
040    import com.liferay.portlet.expando.NoSuchColumnException;
041    import com.liferay.portlet.expando.model.ExpandoColumn;
042    import com.liferay.portlet.expando.model.impl.ExpandoColumnImpl;
043    import com.liferay.portlet.expando.model.impl.ExpandoColumnModelImpl;
044    import com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence;
045    
046    import java.io.Serializable;
047    
048    import java.util.ArrayList;
049    import java.util.Collections;
050    import java.util.HashMap;
051    import java.util.HashSet;
052    import java.util.Iterator;
053    import java.util.List;
054    import java.util.Map;
055    import java.util.Set;
056    
057    /**
058     * The persistence implementation for the expando column service.
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see ExpandoColumnPersistence
066     * @see com.liferay.portlet.expando.service.persistence.ExpandoColumnUtil
067     * @generated
068     */
069    @ProviderType
070    public class ExpandoColumnPersistenceImpl extends BasePersistenceImpl<ExpandoColumn>
071            implements ExpandoColumnPersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link ExpandoColumnUtil} to access the expando column persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = ExpandoColumnImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
083                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
084                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
085                            "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
087                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
088                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
089                            "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
091                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TABLEID = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
094                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
095                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
096                            "findByTableId",
097                            new String[] {
098                                    Long.class.getName(),
099                                    
100                            Integer.class.getName(), Integer.class.getName(),
101                                    OrderByComparator.class.getName()
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID =
104                    new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
105                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
106                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
107                            "findByTableId", new String[] { Long.class.getName() },
108                            ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
109                            ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_TABLEID = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
111                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTableId",
113                            new String[] { Long.class.getName() });
114    
115            /**
116             * Returns all the expando columns where tableId = &#63;.
117             *
118             * @param tableId the table ID
119             * @return the matching expando columns
120             */
121            @Override
122            public List<ExpandoColumn> findByTableId(long tableId) {
123                    return findByTableId(tableId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124            }
125    
126            /**
127             * Returns a range of all the expando columns where tableId = &#63;.
128             *
129             * <p>
130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
131             * </p>
132             *
133             * @param tableId the table ID
134             * @param start the lower bound of the range of expando columns
135             * @param end the upper bound of the range of expando columns (not inclusive)
136             * @return the range of matching expando columns
137             */
138            @Override
139            public List<ExpandoColumn> findByTableId(long tableId, int start, int end) {
140                    return findByTableId(tableId, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the expando columns where tableId = &#63;.
145             *
146             * <p>
147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
148             * </p>
149             *
150             * @param tableId the table ID
151             * @param start the lower bound of the range of expando columns
152             * @param end the upper bound of the range of expando columns (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching expando columns
155             */
156            @Override
157            public List<ExpandoColumn> findByTableId(long tableId, int start, int end,
158                    OrderByComparator<ExpandoColumn> orderByComparator) {
159                    boolean pagination = true;
160                    FinderPath finderPath = null;
161                    Object[] finderArgs = null;
162    
163                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164                                    (orderByComparator == null)) {
165                            pagination = false;
166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID;
167                            finderArgs = new Object[] { tableId };
168                    }
169                    else {
170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TABLEID;
171                            finderArgs = new Object[] { tableId, start, end, orderByComparator };
172                    }
173    
174                    List<ExpandoColumn> list = (List<ExpandoColumn>)FinderCacheUtil.getResult(finderPath,
175                                    finderArgs, this);
176    
177                    if ((list != null) && !list.isEmpty()) {
178                            for (ExpandoColumn expandoColumn : list) {
179                                    if ((tableId != expandoColumn.getTableId())) {
180                                            list = null;
181    
182                                            break;
183                                    }
184                            }
185                    }
186    
187                    if (list == null) {
188                            StringBundler query = null;
189    
190                            if (orderByComparator != null) {
191                                    query = new StringBundler(3 +
192                                                    (orderByComparator.getOrderByFields().length * 3));
193                            }
194                            else {
195                                    query = new StringBundler(3);
196                            }
197    
198                            query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
199    
200                            query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
201    
202                            if (orderByComparator != null) {
203                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
204                                            orderByComparator);
205                            }
206                            else
207                             if (pagination) {
208                                    query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
209                            }
210    
211                            String sql = query.toString();
212    
213                            Session session = null;
214    
215                            try {
216                                    session = openSession();
217    
218                                    Query q = session.createQuery(sql);
219    
220                                    QueryPos qPos = QueryPos.getInstance(q);
221    
222                                    qPos.add(tableId);
223    
224                                    if (!pagination) {
225                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
226                                                            start, end, false);
227    
228                                            Collections.sort(list);
229    
230                                            list = Collections.unmodifiableList(list);
231                                    }
232                                    else {
233                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
234                                                            start, end);
235                                    }
236    
237                                    cacheResult(list);
238    
239                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
240                            }
241                            catch (Exception e) {
242                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
243    
244                                    throw processException(e);
245                            }
246                            finally {
247                                    closeSession(session);
248                            }
249                    }
250    
251                    return list;
252            }
253    
254            /**
255             * Returns the first expando column in the ordered set where tableId = &#63;.
256             *
257             * @param tableId the table ID
258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
259             * @return the first matching expando column
260             * @throws NoSuchColumnException if a matching expando column could not be found
261             */
262            @Override
263            public ExpandoColumn findByTableId_First(long tableId,
264                    OrderByComparator<ExpandoColumn> orderByComparator)
265                    throws NoSuchColumnException {
266                    ExpandoColumn expandoColumn = fetchByTableId_First(tableId,
267                                    orderByComparator);
268    
269                    if (expandoColumn != null) {
270                            return expandoColumn;
271                    }
272    
273                    StringBundler msg = new StringBundler(4);
274    
275                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
276    
277                    msg.append("tableId=");
278                    msg.append(tableId);
279    
280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
281    
282                    throw new NoSuchColumnException(msg.toString());
283            }
284    
285            /**
286             * Returns the first expando column in the ordered set where tableId = &#63;.
287             *
288             * @param tableId the table ID
289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
290             * @return the first matching expando column, or <code>null</code> if a matching expando column could not be found
291             */
292            @Override
293            public ExpandoColumn fetchByTableId_First(long tableId,
294                    OrderByComparator<ExpandoColumn> orderByComparator) {
295                    List<ExpandoColumn> list = findByTableId(tableId, 0, 1,
296                                    orderByComparator);
297    
298                    if (!list.isEmpty()) {
299                            return list.get(0);
300                    }
301    
302                    return null;
303            }
304    
305            /**
306             * Returns the last expando column in the ordered set where tableId = &#63;.
307             *
308             * @param tableId the table ID
309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
310             * @return the last matching expando column
311             * @throws NoSuchColumnException if a matching expando column could not be found
312             */
313            @Override
314            public ExpandoColumn findByTableId_Last(long tableId,
315                    OrderByComparator<ExpandoColumn> orderByComparator)
316                    throws NoSuchColumnException {
317                    ExpandoColumn expandoColumn = fetchByTableId_Last(tableId,
318                                    orderByComparator);
319    
320                    if (expandoColumn != null) {
321                            return expandoColumn;
322                    }
323    
324                    StringBundler msg = new StringBundler(4);
325    
326                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
327    
328                    msg.append("tableId=");
329                    msg.append(tableId);
330    
331                    msg.append(StringPool.CLOSE_CURLY_BRACE);
332    
333                    throw new NoSuchColumnException(msg.toString());
334            }
335    
336            /**
337             * Returns the last expando column in the ordered set where tableId = &#63;.
338             *
339             * @param tableId the table ID
340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
341             * @return the last matching expando column, or <code>null</code> if a matching expando column could not be found
342             */
343            @Override
344            public ExpandoColumn fetchByTableId_Last(long tableId,
345                    OrderByComparator<ExpandoColumn> orderByComparator) {
346                    int count = countByTableId(tableId);
347    
348                    if (count == 0) {
349                            return null;
350                    }
351    
352                    List<ExpandoColumn> list = findByTableId(tableId, count - 1, count,
353                                    orderByComparator);
354    
355                    if (!list.isEmpty()) {
356                            return list.get(0);
357                    }
358    
359                    return null;
360            }
361    
362            /**
363             * Returns the expando columns before and after the current expando column in the ordered set where tableId = &#63;.
364             *
365             * @param columnId the primary key of the current expando column
366             * @param tableId the table ID
367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
368             * @return the previous, current, and next expando column
369             * @throws NoSuchColumnException if a expando column with the primary key could not be found
370             */
371            @Override
372            public ExpandoColumn[] findByTableId_PrevAndNext(long columnId,
373                    long tableId, OrderByComparator<ExpandoColumn> orderByComparator)
374                    throws NoSuchColumnException {
375                    ExpandoColumn expandoColumn = findByPrimaryKey(columnId);
376    
377                    Session session = null;
378    
379                    try {
380                            session = openSession();
381    
382                            ExpandoColumn[] array = new ExpandoColumnImpl[3];
383    
384                            array[0] = getByTableId_PrevAndNext(session, expandoColumn,
385                                            tableId, orderByComparator, true);
386    
387                            array[1] = expandoColumn;
388    
389                            array[2] = getByTableId_PrevAndNext(session, expandoColumn,
390                                            tableId, orderByComparator, false);
391    
392                            return array;
393                    }
394                    catch (Exception e) {
395                            throw processException(e);
396                    }
397                    finally {
398                            closeSession(session);
399                    }
400            }
401    
402            protected ExpandoColumn getByTableId_PrevAndNext(Session session,
403                    ExpandoColumn expandoColumn, long tableId,
404                    OrderByComparator<ExpandoColumn> orderByComparator, boolean previous) {
405                    StringBundler query = null;
406    
407                    if (orderByComparator != null) {
408                            query = new StringBundler(6 +
409                                            (orderByComparator.getOrderByFields().length * 6));
410                    }
411                    else {
412                            query = new StringBundler(3);
413                    }
414    
415                    query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
416    
417                    query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
418    
419                    if (orderByComparator != null) {
420                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
421    
422                            if (orderByConditionFields.length > 0) {
423                                    query.append(WHERE_AND);
424                            }
425    
426                            for (int i = 0; i < orderByConditionFields.length; i++) {
427                                    query.append(_ORDER_BY_ENTITY_ALIAS);
428                                    query.append(orderByConditionFields[i]);
429    
430                                    if ((i + 1) < orderByConditionFields.length) {
431                                            if (orderByComparator.isAscending() ^ previous) {
432                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
433                                            }
434                                            else {
435                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
436                                            }
437                                    }
438                                    else {
439                                            if (orderByComparator.isAscending() ^ previous) {
440                                                    query.append(WHERE_GREATER_THAN);
441                                            }
442                                            else {
443                                                    query.append(WHERE_LESSER_THAN);
444                                            }
445                                    }
446                            }
447    
448                            query.append(ORDER_BY_CLAUSE);
449    
450                            String[] orderByFields = orderByComparator.getOrderByFields();
451    
452                            for (int i = 0; i < orderByFields.length; i++) {
453                                    query.append(_ORDER_BY_ENTITY_ALIAS);
454                                    query.append(orderByFields[i]);
455    
456                                    if ((i + 1) < orderByFields.length) {
457                                            if (orderByComparator.isAscending() ^ previous) {
458                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
459                                            }
460                                            else {
461                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
462                                            }
463                                    }
464                                    else {
465                                            if (orderByComparator.isAscending() ^ previous) {
466                                                    query.append(ORDER_BY_ASC);
467                                            }
468                                            else {
469                                                    query.append(ORDER_BY_DESC);
470                                            }
471                                    }
472                            }
473                    }
474                    else {
475                            query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
476                    }
477    
478                    String sql = query.toString();
479    
480                    Query q = session.createQuery(sql);
481    
482                    q.setFirstResult(0);
483                    q.setMaxResults(2);
484    
485                    QueryPos qPos = QueryPos.getInstance(q);
486    
487                    qPos.add(tableId);
488    
489                    if (orderByComparator != null) {
490                            Object[] values = orderByComparator.getOrderByConditionValues(expandoColumn);
491    
492                            for (Object value : values) {
493                                    qPos.add(value);
494                            }
495                    }
496    
497                    List<ExpandoColumn> list = q.list();
498    
499                    if (list.size() == 2) {
500                            return list.get(1);
501                    }
502                    else {
503                            return null;
504                    }
505            }
506    
507            /**
508             * Returns all the expando columns that the user has permission to view where tableId = &#63;.
509             *
510             * @param tableId the table ID
511             * @return the matching expando columns that the user has permission to view
512             */
513            @Override
514            public List<ExpandoColumn> filterFindByTableId(long tableId) {
515                    return filterFindByTableId(tableId, QueryUtil.ALL_POS,
516                            QueryUtil.ALL_POS, null);
517            }
518    
519            /**
520             * Returns a range of all the expando columns that the user has permission to view where tableId = &#63;.
521             *
522             * <p>
523             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
524             * </p>
525             *
526             * @param tableId the table ID
527             * @param start the lower bound of the range of expando columns
528             * @param end the upper bound of the range of expando columns (not inclusive)
529             * @return the range of matching expando columns that the user has permission to view
530             */
531            @Override
532            public List<ExpandoColumn> filterFindByTableId(long tableId, int start,
533                    int end) {
534                    return filterFindByTableId(tableId, start, end, null);
535            }
536    
537            /**
538             * Returns an ordered range of all the expando columns that the user has permissions to view where tableId = &#63;.
539             *
540             * <p>
541             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
542             * </p>
543             *
544             * @param tableId the table ID
545             * @param start the lower bound of the range of expando columns
546             * @param end the upper bound of the range of expando columns (not inclusive)
547             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
548             * @return the ordered range of matching expando columns that the user has permission to view
549             */
550            @Override
551            public List<ExpandoColumn> filterFindByTableId(long tableId, int start,
552                    int end, OrderByComparator<ExpandoColumn> orderByComparator) {
553                    if (!InlineSQLHelperUtil.isEnabled()) {
554                            return findByTableId(tableId, start, end, orderByComparator);
555                    }
556    
557                    StringBundler query = null;
558    
559                    if (orderByComparator != null) {
560                            query = new StringBundler(3 +
561                                            (orderByComparator.getOrderByFields().length * 3));
562                    }
563                    else {
564                            query = new StringBundler(3);
565                    }
566    
567                    if (getDB().isSupportsInlineDistinct()) {
568                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE);
569                    }
570                    else {
571                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1);
572                    }
573    
574                    query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
575    
576                    if (!getDB().isSupportsInlineDistinct()) {
577                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2);
578                    }
579    
580                    if (orderByComparator != null) {
581                            if (getDB().isSupportsInlineDistinct()) {
582                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
583                                            orderByComparator, true);
584                            }
585                            else {
586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
587                                            orderByComparator, true);
588                            }
589                    }
590                    else {
591                            if (getDB().isSupportsInlineDistinct()) {
592                                    query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
593                            }
594                            else {
595                                    query.append(ExpandoColumnModelImpl.ORDER_BY_SQL);
596                            }
597                    }
598    
599                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
600                                    ExpandoColumn.class.getName(),
601                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
602    
603                    Session session = null;
604    
605                    try {
606                            session = openSession();
607    
608                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
609    
610                            if (getDB().isSupportsInlineDistinct()) {
611                                    q.addEntity(_FILTER_ENTITY_ALIAS, ExpandoColumnImpl.class);
612                            }
613                            else {
614                                    q.addEntity(_FILTER_ENTITY_TABLE, ExpandoColumnImpl.class);
615                            }
616    
617                            QueryPos qPos = QueryPos.getInstance(q);
618    
619                            qPos.add(tableId);
620    
621                            return (List<ExpandoColumn>)QueryUtil.list(q, getDialect(), start,
622                                    end);
623                    }
624                    catch (Exception e) {
625                            throw processException(e);
626                    }
627                    finally {
628                            closeSession(session);
629                    }
630            }
631    
632            /**
633             * Returns the expando columns before and after the current expando column in the ordered set of expando columns that the user has permission to view where tableId = &#63;.
634             *
635             * @param columnId the primary key of the current expando column
636             * @param tableId the table ID
637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
638             * @return the previous, current, and next expando column
639             * @throws NoSuchColumnException if a expando column with the primary key could not be found
640             */
641            @Override
642            public ExpandoColumn[] filterFindByTableId_PrevAndNext(long columnId,
643                    long tableId, OrderByComparator<ExpandoColumn> orderByComparator)
644                    throws NoSuchColumnException {
645                    if (!InlineSQLHelperUtil.isEnabled()) {
646                            return findByTableId_PrevAndNext(columnId, tableId,
647                                    orderByComparator);
648                    }
649    
650                    ExpandoColumn expandoColumn = findByPrimaryKey(columnId);
651    
652                    Session session = null;
653    
654                    try {
655                            session = openSession();
656    
657                            ExpandoColumn[] array = new ExpandoColumnImpl[3];
658    
659                            array[0] = filterGetByTableId_PrevAndNext(session, expandoColumn,
660                                            tableId, orderByComparator, true);
661    
662                            array[1] = expandoColumn;
663    
664                            array[2] = filterGetByTableId_PrevAndNext(session, expandoColumn,
665                                            tableId, orderByComparator, false);
666    
667                            return array;
668                    }
669                    catch (Exception e) {
670                            throw processException(e);
671                    }
672                    finally {
673                            closeSession(session);
674                    }
675            }
676    
677            protected ExpandoColumn filterGetByTableId_PrevAndNext(Session session,
678                    ExpandoColumn expandoColumn, long tableId,
679                    OrderByComparator<ExpandoColumn> orderByComparator, boolean previous) {
680                    StringBundler query = null;
681    
682                    if (orderByComparator != null) {
683                            query = new StringBundler(6 +
684                                            (orderByComparator.getOrderByFields().length * 6));
685                    }
686                    else {
687                            query = new StringBundler(3);
688                    }
689    
690                    if (getDB().isSupportsInlineDistinct()) {
691                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE);
692                    }
693                    else {
694                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1);
695                    }
696    
697                    query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
698    
699                    if (!getDB().isSupportsInlineDistinct()) {
700                            query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2);
701                    }
702    
703                    if (orderByComparator != null) {
704                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
705    
706                            if (orderByConditionFields.length > 0) {
707                                    query.append(WHERE_AND);
708                            }
709    
710                            for (int i = 0; i < orderByConditionFields.length; i++) {
711                                    if (getDB().isSupportsInlineDistinct()) {
712                                            query.append(_ORDER_BY_ENTITY_ALIAS);
713                                    }
714                                    else {
715                                            query.append(_ORDER_BY_ENTITY_TABLE);
716                                    }
717    
718                                    query.append(orderByConditionFields[i]);
719    
720                                    if ((i + 1) < orderByConditionFields.length) {
721                                            if (orderByComparator.isAscending() ^ previous) {
722                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
723                                            }
724                                            else {
725                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
726                                            }
727                                    }
728                                    else {
729                                            if (orderByComparator.isAscending() ^ previous) {
730                                                    query.append(WHERE_GREATER_THAN);
731                                            }
732                                            else {
733                                                    query.append(WHERE_LESSER_THAN);
734                                            }
735                                    }
736                            }
737    
738                            query.append(ORDER_BY_CLAUSE);
739    
740                            String[] orderByFields = orderByComparator.getOrderByFields();
741    
742                            for (int i = 0; i < orderByFields.length; i++) {
743                                    if (getDB().isSupportsInlineDistinct()) {
744                                            query.append(_ORDER_BY_ENTITY_ALIAS);
745                                    }
746                                    else {
747                                            query.append(_ORDER_BY_ENTITY_TABLE);
748                                    }
749    
750                                    query.append(orderByFields[i]);
751    
752                                    if ((i + 1) < orderByFields.length) {
753                                            if (orderByComparator.isAscending() ^ previous) {
754                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
755                                            }
756                                            else {
757                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
758                                            }
759                                    }
760                                    else {
761                                            if (orderByComparator.isAscending() ^ previous) {
762                                                    query.append(ORDER_BY_ASC);
763                                            }
764                                            else {
765                                                    query.append(ORDER_BY_DESC);
766                                            }
767                                    }
768                            }
769                    }
770                    else {
771                            if (getDB().isSupportsInlineDistinct()) {
772                                    query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
773                            }
774                            else {
775                                    query.append(ExpandoColumnModelImpl.ORDER_BY_SQL);
776                            }
777                    }
778    
779                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
780                                    ExpandoColumn.class.getName(),
781                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
782    
783                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
784    
785                    q.setFirstResult(0);
786                    q.setMaxResults(2);
787    
788                    if (getDB().isSupportsInlineDistinct()) {
789                            q.addEntity(_FILTER_ENTITY_ALIAS, ExpandoColumnImpl.class);
790                    }
791                    else {
792                            q.addEntity(_FILTER_ENTITY_TABLE, ExpandoColumnImpl.class);
793                    }
794    
795                    QueryPos qPos = QueryPos.getInstance(q);
796    
797                    qPos.add(tableId);
798    
799                    if (orderByComparator != null) {
800                            Object[] values = orderByComparator.getOrderByConditionValues(expandoColumn);
801    
802                            for (Object value : values) {
803                                    qPos.add(value);
804                            }
805                    }
806    
807                    List<ExpandoColumn> list = q.list();
808    
809                    if (list.size() == 2) {
810                            return list.get(1);
811                    }
812                    else {
813                            return null;
814                    }
815            }
816    
817            /**
818             * Removes all the expando columns where tableId = &#63; from the database.
819             *
820             * @param tableId the table ID
821             */
822            @Override
823            public void removeByTableId(long tableId) {
824                    for (ExpandoColumn expandoColumn : findByTableId(tableId,
825                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
826                            remove(expandoColumn);
827                    }
828            }
829    
830            /**
831             * Returns the number of expando columns where tableId = &#63;.
832             *
833             * @param tableId the table ID
834             * @return the number of matching expando columns
835             */
836            @Override
837            public int countByTableId(long tableId) {
838                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TABLEID;
839    
840                    Object[] finderArgs = new Object[] { tableId };
841    
842                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
843                                    this);
844    
845                    if (count == null) {
846                            StringBundler query = new StringBundler(2);
847    
848                            query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
849    
850                            query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
851    
852                            String sql = query.toString();
853    
854                            Session session = null;
855    
856                            try {
857                                    session = openSession();
858    
859                                    Query q = session.createQuery(sql);
860    
861                                    QueryPos qPos = QueryPos.getInstance(q);
862    
863                                    qPos.add(tableId);
864    
865                                    count = (Long)q.uniqueResult();
866    
867                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
868                            }
869                            catch (Exception e) {
870                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
871    
872                                    throw processException(e);
873                            }
874                            finally {
875                                    closeSession(session);
876                            }
877                    }
878    
879                    return count.intValue();
880            }
881    
882            /**
883             * Returns the number of expando columns that the user has permission to view where tableId = &#63;.
884             *
885             * @param tableId the table ID
886             * @return the number of matching expando columns that the user has permission to view
887             */
888            @Override
889            public int filterCountByTableId(long tableId) {
890                    if (!InlineSQLHelperUtil.isEnabled()) {
891                            return countByTableId(tableId);
892                    }
893    
894                    StringBundler query = new StringBundler(2);
895    
896                    query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
897    
898                    query.append(_FINDER_COLUMN_TABLEID_TABLEID_2);
899    
900                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
901                                    ExpandoColumn.class.getName(),
902                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
903    
904                    Session session = null;
905    
906                    try {
907                            session = openSession();
908    
909                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
910    
911                            q.addScalar(COUNT_COLUMN_NAME,
912                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
913    
914                            QueryPos qPos = QueryPos.getInstance(q);
915    
916                            qPos.add(tableId);
917    
918                            Long count = (Long)q.uniqueResult();
919    
920                            return count.intValue();
921                    }
922                    catch (Exception e) {
923                            throw processException(e);
924                    }
925                    finally {
926                            closeSession(session);
927                    }
928            }
929    
930            private static final String _FINDER_COLUMN_TABLEID_TABLEID_2 = "expandoColumn.tableId = ?";
931            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
932                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
933                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
934                            "findByT_N",
935                            new String[] {
936                                    Long.class.getName(), String.class.getName(),
937                                    
938                            Integer.class.getName(), Integer.class.getName(),
939                                    OrderByComparator.class.getName()
940                            });
941            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
942                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
943                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
944                            "findByT_N",
945                            new String[] { Long.class.getName(), String.class.getName() },
946                            ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
947                            ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
948            public static final FinderPath FINDER_PATH_FETCH_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
949                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED,
950                            ExpandoColumnImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByT_N",
951                            new String[] { Long.class.getName(), String.class.getName() },
952                            ExpandoColumnModelImpl.TABLEID_COLUMN_BITMASK |
953                            ExpandoColumnModelImpl.NAME_COLUMN_BITMASK);
954            public static final FinderPath FINDER_PATH_COUNT_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
955                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
956                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_N",
957                            new String[] { Long.class.getName(), String.class.getName() });
958            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N = new FinderPath(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
959                            ExpandoColumnModelImpl.FINDER_CACHE_ENABLED, Long.class,
960                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByT_N",
961                            new String[] { Long.class.getName(), String.class.getName() });
962    
963            /**
964             * Returns all the expando columns where tableId = &#63; and name = any &#63;.
965             *
966             * <p>
967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
968             * </p>
969             *
970             * @param tableId the table ID
971             * @param names the names
972             * @return the matching expando columns
973             */
974            @Override
975            public List<ExpandoColumn> findByT_N(long tableId, String[] names) {
976                    return findByT_N(tableId, names, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
977                            null);
978            }
979    
980            /**
981             * Returns a range of all the expando columns where tableId = &#63; and name = any &#63;.
982             *
983             * <p>
984             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
985             * </p>
986             *
987             * @param tableId the table ID
988             * @param names the names
989             * @param start the lower bound of the range of expando columns
990             * @param end the upper bound of the range of expando columns (not inclusive)
991             * @return the range of matching expando columns
992             */
993            @Override
994            public List<ExpandoColumn> findByT_N(long tableId, String[] names,
995                    int start, int end) {
996                    return findByT_N(tableId, names, start, end, null);
997            }
998    
999            /**
1000             * Returns an ordered range of all the expando columns where tableId = &#63; and name = any &#63;.
1001             *
1002             * <p>
1003             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1004             * </p>
1005             *
1006             * @param tableId the table ID
1007             * @param names the names
1008             * @param start the lower bound of the range of expando columns
1009             * @param end the upper bound of the range of expando columns (not inclusive)
1010             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1011             * @return the ordered range of matching expando columns
1012             */
1013            @Override
1014            public List<ExpandoColumn> findByT_N(long tableId, String[] names,
1015                    int start, int end, OrderByComparator<ExpandoColumn> orderByComparator) {
1016                    if (names == null) {
1017                            names = new String[0];
1018                    }
1019                    else {
1020                            names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1021                    }
1022    
1023                    if (names.length == 1) {
1024                            ExpandoColumn expandoColumn = fetchByT_N(tableId, names[0]);
1025    
1026                            if (expandoColumn == null) {
1027                                    return Collections.emptyList();
1028                            }
1029                            else {
1030                                    List<ExpandoColumn> list = new ArrayList<ExpandoColumn>(1);
1031    
1032                                    list.add(expandoColumn);
1033    
1034                                    return list;
1035                            }
1036                    }
1037    
1038                    boolean pagination = true;
1039                    Object[] finderArgs = null;
1040    
1041                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1042                                    (orderByComparator == null)) {
1043                            pagination = false;
1044                            finderArgs = new Object[] { tableId, StringUtil.merge(names) };
1045                    }
1046                    else {
1047                            finderArgs = new Object[] {
1048                                            tableId, StringUtil.merge(names),
1049                                            
1050                                            start, end, orderByComparator
1051                                    };
1052                    }
1053    
1054                    List<ExpandoColumn> list = (List<ExpandoColumn>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1055                                    finderArgs, this);
1056    
1057                    if ((list != null) && !list.isEmpty()) {
1058                            for (ExpandoColumn expandoColumn : list) {
1059                                    if ((tableId != expandoColumn.getTableId()) ||
1060                                                    !ArrayUtil.contains(names, expandoColumn.getName())) {
1061                                            list = null;
1062    
1063                                            break;
1064                                    }
1065                            }
1066                    }
1067    
1068                    if (list == null) {
1069                            StringBundler query = new StringBundler();
1070    
1071                            query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
1072    
1073                            query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1074    
1075                            if (names.length > 0) {
1076                                    query.append(StringPool.OPEN_PARENTHESIS);
1077    
1078                                    for (int i = 0; i < names.length; i++) {
1079                                            String name = names[i];
1080    
1081                                            if (name == null) {
1082                                                    query.append(_FINDER_COLUMN_T_N_NAME_1);
1083                                            }
1084                                            else if (name.equals(StringPool.BLANK)) {
1085                                                    query.append(_FINDER_COLUMN_T_N_NAME_3);
1086                                            }
1087                                            else {
1088                                                    query.append(_FINDER_COLUMN_T_N_NAME_2);
1089                                            }
1090    
1091                                            if ((i + 1) < names.length) {
1092                                                    query.append(WHERE_OR);
1093                                            }
1094                                    }
1095    
1096                                    query.append(StringPool.CLOSE_PARENTHESIS);
1097                            }
1098    
1099                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
1100                                                    1)), query.index() - 1);
1101    
1102                            if (orderByComparator != null) {
1103                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1104                                            orderByComparator);
1105                            }
1106                            else
1107                             if (pagination) {
1108                                    query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL);
1109                            }
1110    
1111                            String sql = query.toString();
1112    
1113                            Session session = null;
1114    
1115                            try {
1116                                    session = openSession();
1117    
1118                                    Query q = session.createQuery(sql);
1119    
1120                                    QueryPos qPos = QueryPos.getInstance(q);
1121    
1122                                    qPos.add(tableId);
1123    
1124                                    for (String name : names) {
1125                                            if ((name != null) && !name.isEmpty()) {
1126                                                    qPos.add(name);
1127                                            }
1128                                    }
1129    
1130                                    if (!pagination) {
1131                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
1132                                                            start, end, false);
1133    
1134                                            Collections.sort(list);
1135    
1136                                            list = Collections.unmodifiableList(list);
1137                                    }
1138                                    else {
1139                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
1140                                                            start, end);
1141                                    }
1142    
1143                                    cacheResult(list);
1144    
1145                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1146                                            finderArgs, list);
1147                            }
1148                            catch (Exception e) {
1149                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N,
1150                                            finderArgs);
1151    
1152                                    throw processException(e);
1153                            }
1154                            finally {
1155                                    closeSession(session);
1156                            }
1157                    }
1158    
1159                    return list;
1160            }
1161    
1162            /**
1163             * Returns the expando column where tableId = &#63; and name = &#63; or throws a {@link NoSuchColumnException} if it could not be found.
1164             *
1165             * @param tableId the table ID
1166             * @param name the name
1167             * @return the matching expando column
1168             * @throws NoSuchColumnException if a matching expando column could not be found
1169             */
1170            @Override
1171            public ExpandoColumn findByT_N(long tableId, String name)
1172                    throws NoSuchColumnException {
1173                    ExpandoColumn expandoColumn = fetchByT_N(tableId, name);
1174    
1175                    if (expandoColumn == null) {
1176                            StringBundler msg = new StringBundler(6);
1177    
1178                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1179    
1180                            msg.append("tableId=");
1181                            msg.append(tableId);
1182    
1183                            msg.append(", name=");
1184                            msg.append(name);
1185    
1186                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1187    
1188                            if (_log.isWarnEnabled()) {
1189                                    _log.warn(msg.toString());
1190                            }
1191    
1192                            throw new NoSuchColumnException(msg.toString());
1193                    }
1194    
1195                    return expandoColumn;
1196            }
1197    
1198            /**
1199             * Returns the expando column where tableId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1200             *
1201             * @param tableId the table ID
1202             * @param name the name
1203             * @return the matching expando column, or <code>null</code> if a matching expando column could not be found
1204             */
1205            @Override
1206            public ExpandoColumn fetchByT_N(long tableId, String name) {
1207                    return fetchByT_N(tableId, name, true);
1208            }
1209    
1210            /**
1211             * Returns the expando column where tableId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1212             *
1213             * @param tableId the table ID
1214             * @param name the name
1215             * @param retrieveFromCache whether to use the finder cache
1216             * @return the matching expando column, or <code>null</code> if a matching expando column could not be found
1217             */
1218            @Override
1219            public ExpandoColumn fetchByT_N(long tableId, String name,
1220                    boolean retrieveFromCache) {
1221                    Object[] finderArgs = new Object[] { tableId, name };
1222    
1223                    Object result = null;
1224    
1225                    if (retrieveFromCache) {
1226                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_T_N,
1227                                            finderArgs, this);
1228                    }
1229    
1230                    if (result instanceof ExpandoColumn) {
1231                            ExpandoColumn expandoColumn = (ExpandoColumn)result;
1232    
1233                            if ((tableId != expandoColumn.getTableId()) ||
1234                                            !Validator.equals(name, expandoColumn.getName())) {
1235                                    result = null;
1236                            }
1237                    }
1238    
1239                    if (result == null) {
1240                            StringBundler query = new StringBundler(4);
1241    
1242                            query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE);
1243    
1244                            query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1245    
1246                            boolean bindName = false;
1247    
1248                            if (name == null) {
1249                                    query.append(_FINDER_COLUMN_T_N_NAME_1);
1250                            }
1251                            else if (name.equals(StringPool.BLANK)) {
1252                                    query.append(_FINDER_COLUMN_T_N_NAME_3);
1253                            }
1254                            else {
1255                                    bindName = true;
1256    
1257                                    query.append(_FINDER_COLUMN_T_N_NAME_2);
1258                            }
1259    
1260                            String sql = query.toString();
1261    
1262                            Session session = null;
1263    
1264                            try {
1265                                    session = openSession();
1266    
1267                                    Query q = session.createQuery(sql);
1268    
1269                                    QueryPos qPos = QueryPos.getInstance(q);
1270    
1271                                    qPos.add(tableId);
1272    
1273                                    if (bindName) {
1274                                            qPos.add(name);
1275                                    }
1276    
1277                                    List<ExpandoColumn> list = q.list();
1278    
1279                                    if (list.isEmpty()) {
1280                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_N,
1281                                                    finderArgs, list);
1282                                    }
1283                                    else {
1284                                            ExpandoColumn expandoColumn = list.get(0);
1285    
1286                                            result = expandoColumn;
1287    
1288                                            cacheResult(expandoColumn);
1289    
1290                                            if ((expandoColumn.getTableId() != tableId) ||
1291                                                            (expandoColumn.getName() == null) ||
1292                                                            !expandoColumn.getName().equals(name)) {
1293                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_N,
1294                                                            finderArgs, expandoColumn);
1295                                            }
1296                                    }
1297                            }
1298                            catch (Exception e) {
1299                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_N,
1300                                            finderArgs);
1301    
1302                                    throw processException(e);
1303                            }
1304                            finally {
1305                                    closeSession(session);
1306                            }
1307                    }
1308    
1309                    if (result instanceof List<?>) {
1310                            return null;
1311                    }
1312                    else {
1313                            return (ExpandoColumn)result;
1314                    }
1315            }
1316    
1317            /**
1318             * Removes the expando column where tableId = &#63; and name = &#63; from the database.
1319             *
1320             * @param tableId the table ID
1321             * @param name the name
1322             * @return the expando column that was removed
1323             */
1324            @Override
1325            public ExpandoColumn removeByT_N(long tableId, String name)
1326                    throws NoSuchColumnException {
1327                    ExpandoColumn expandoColumn = findByT_N(tableId, name);
1328    
1329                    return remove(expandoColumn);
1330            }
1331    
1332            /**
1333             * Returns the number of expando columns where tableId = &#63; and name = &#63;.
1334             *
1335             * @param tableId the table ID
1336             * @param name the name
1337             * @return the number of matching expando columns
1338             */
1339            @Override
1340            public int countByT_N(long tableId, String name) {
1341                    FinderPath finderPath = FINDER_PATH_COUNT_BY_T_N;
1342    
1343                    Object[] finderArgs = new Object[] { tableId, name };
1344    
1345                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1346                                    this);
1347    
1348                    if (count == null) {
1349                            StringBundler query = new StringBundler(3);
1350    
1351                            query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1352    
1353                            query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1354    
1355                            boolean bindName = false;
1356    
1357                            if (name == null) {
1358                                    query.append(_FINDER_COLUMN_T_N_NAME_1);
1359                            }
1360                            else if (name.equals(StringPool.BLANK)) {
1361                                    query.append(_FINDER_COLUMN_T_N_NAME_3);
1362                            }
1363                            else {
1364                                    bindName = true;
1365    
1366                                    query.append(_FINDER_COLUMN_T_N_NAME_2);
1367                            }
1368    
1369                            String sql = query.toString();
1370    
1371                            Session session = null;
1372    
1373                            try {
1374                                    session = openSession();
1375    
1376                                    Query q = session.createQuery(sql);
1377    
1378                                    QueryPos qPos = QueryPos.getInstance(q);
1379    
1380                                    qPos.add(tableId);
1381    
1382                                    if (bindName) {
1383                                            qPos.add(name);
1384                                    }
1385    
1386                                    count = (Long)q.uniqueResult();
1387    
1388                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1389                            }
1390                            catch (Exception e) {
1391                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1392    
1393                                    throw processException(e);
1394                            }
1395                            finally {
1396                                    closeSession(session);
1397                            }
1398                    }
1399    
1400                    return count.intValue();
1401            }
1402    
1403            /**
1404             * Returns the number of expando columns where tableId = &#63; and name = any &#63;.
1405             *
1406             * @param tableId the table ID
1407             * @param names the names
1408             * @return the number of matching expando columns
1409             */
1410            @Override
1411            public int countByT_N(long tableId, String[] names) {
1412                    if (names == null) {
1413                            names = new String[0];
1414                    }
1415                    else {
1416                            names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1417                    }
1418    
1419                    Object[] finderArgs = new Object[] { tableId, StringUtil.merge(names) };
1420    
1421                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1422                                    finderArgs, this);
1423    
1424                    if (count == null) {
1425                            StringBundler query = new StringBundler();
1426    
1427                            query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1428    
1429                            query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1430    
1431                            if (names.length > 0) {
1432                                    query.append(StringPool.OPEN_PARENTHESIS);
1433    
1434                                    for (int i = 0; i < names.length; i++) {
1435                                            String name = names[i];
1436    
1437                                            if (name == null) {
1438                                                    query.append(_FINDER_COLUMN_T_N_NAME_1);
1439                                            }
1440                                            else if (name.equals(StringPool.BLANK)) {
1441                                                    query.append(_FINDER_COLUMN_T_N_NAME_3);
1442                                            }
1443                                            else {
1444                                                    query.append(_FINDER_COLUMN_T_N_NAME_2);
1445                                            }
1446    
1447                                            if ((i + 1) < names.length) {
1448                                                    query.append(WHERE_OR);
1449                                            }
1450                                    }
1451    
1452                                    query.append(StringPool.CLOSE_PARENTHESIS);
1453                            }
1454    
1455                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
1456                                                    1)), query.index() - 1);
1457    
1458                            String sql = query.toString();
1459    
1460                            Session session = null;
1461    
1462                            try {
1463                                    session = openSession();
1464    
1465                                    Query q = session.createQuery(sql);
1466    
1467                                    QueryPos qPos = QueryPos.getInstance(q);
1468    
1469                                    qPos.add(tableId);
1470    
1471                                    for (String name : names) {
1472                                            if ((name != null) && !name.isEmpty()) {
1473                                                    qPos.add(name);
1474                                            }
1475                                    }
1476    
1477                                    count = (Long)q.uniqueResult();
1478    
1479                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1480                                            finderArgs, count);
1481                            }
1482                            catch (Exception e) {
1483                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_T_N,
1484                                            finderArgs);
1485    
1486                                    throw processException(e);
1487                            }
1488                            finally {
1489                                    closeSession(session);
1490                            }
1491                    }
1492    
1493                    return count.intValue();
1494            }
1495    
1496            /**
1497             * Returns the number of expando columns that the user has permission to view where tableId = &#63; and name = &#63;.
1498             *
1499             * @param tableId the table ID
1500             * @param name the name
1501             * @return the number of matching expando columns that the user has permission to view
1502             */
1503            @Override
1504            public int filterCountByT_N(long tableId, String name) {
1505                    if (!InlineSQLHelperUtil.isEnabled()) {
1506                            return countByT_N(tableId, name);
1507                    }
1508    
1509                    StringBundler query = new StringBundler(3);
1510    
1511                    query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1512    
1513                    query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1514    
1515                    boolean bindName = false;
1516    
1517                    if (name == null) {
1518                            query.append(_FINDER_COLUMN_T_N_NAME_1);
1519                    }
1520                    else if (name.equals(StringPool.BLANK)) {
1521                            query.append(_FINDER_COLUMN_T_N_NAME_3);
1522                    }
1523                    else {
1524                            bindName = true;
1525    
1526                            query.append(_FINDER_COLUMN_T_N_NAME_2);
1527                    }
1528    
1529                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1530                                    ExpandoColumn.class.getName(),
1531                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1532    
1533                    Session session = null;
1534    
1535                    try {
1536                            session = openSession();
1537    
1538                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1539    
1540                            q.addScalar(COUNT_COLUMN_NAME,
1541                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1542    
1543                            QueryPos qPos = QueryPos.getInstance(q);
1544    
1545                            qPos.add(tableId);
1546    
1547                            if (bindName) {
1548                                    qPos.add(name);
1549                            }
1550    
1551                            Long count = (Long)q.uniqueResult();
1552    
1553                            return count.intValue();
1554                    }
1555                    catch (Exception e) {
1556                            throw processException(e);
1557                    }
1558                    finally {
1559                            closeSession(session);
1560                    }
1561            }
1562    
1563            /**
1564             * Returns the number of expando columns that the user has permission to view where tableId = &#63; and name = any &#63;.
1565             *
1566             * @param tableId the table ID
1567             * @param names the names
1568             * @return the number of matching expando columns that the user has permission to view
1569             */
1570            @Override
1571            public int filterCountByT_N(long tableId, String[] names) {
1572                    if (!InlineSQLHelperUtil.isEnabled()) {
1573                            return countByT_N(tableId, names);
1574                    }
1575    
1576                    if (names == null) {
1577                            names = new String[0];
1578                    }
1579                    else {
1580                            names = ArrayUtil.distinct(names, NULL_SAFE_STRING_COMPARATOR);
1581                    }
1582    
1583                    StringBundler query = new StringBundler();
1584    
1585                    query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE);
1586    
1587                    query.append(_FINDER_COLUMN_T_N_TABLEID_2);
1588    
1589                    if (names.length > 0) {
1590                            query.append(StringPool.OPEN_PARENTHESIS);
1591    
1592                            for (int i = 0; i < names.length; i++) {
1593                                    String name = names[i];
1594    
1595                                    if (name == null) {
1596                                            query.append(_FINDER_COLUMN_T_N_NAME_1);
1597                                    }
1598                                    else if (name.equals(StringPool.BLANK)) {
1599                                            query.append(_FINDER_COLUMN_T_N_NAME_3);
1600                                    }
1601                                    else {
1602                                            query.append(_FINDER_COLUMN_T_N_NAME_2);
1603                                    }
1604    
1605                                    if ((i + 1) < names.length) {
1606                                            query.append(WHERE_OR);
1607                                    }
1608                            }
1609    
1610                            query.append(StringPool.CLOSE_PARENTHESIS);
1611                    }
1612    
1613                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
1614                            query.index() - 1);
1615    
1616                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1617                                    ExpandoColumn.class.getName(),
1618                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1619    
1620                    Session session = null;
1621    
1622                    try {
1623                            session = openSession();
1624    
1625                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1626    
1627                            q.addScalar(COUNT_COLUMN_NAME,
1628                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1629    
1630                            QueryPos qPos = QueryPos.getInstance(q);
1631    
1632                            qPos.add(tableId);
1633    
1634                            for (String name : names) {
1635                                    if ((name != null) && !name.isEmpty()) {
1636                                            qPos.add(name);
1637                                    }
1638                            }
1639    
1640                            Long count = (Long)q.uniqueResult();
1641    
1642                            return count.intValue();
1643                    }
1644                    catch (Exception e) {
1645                            throw processException(e);
1646                    }
1647                    finally {
1648                            closeSession(session);
1649                    }
1650            }
1651    
1652            private static final String _FINDER_COLUMN_T_N_TABLEID_2 = "expandoColumn.tableId = ? AND ";
1653            private static final String _FINDER_COLUMN_T_N_NAME_1 = "expandoColumn.name IS NULL";
1654            private static final String _FINDER_COLUMN_T_N_NAME_2 = "expandoColumn.name = ?";
1655            private static final String _FINDER_COLUMN_T_N_NAME_3 = "(expandoColumn.name IS NULL OR expandoColumn.name = '')";
1656    
1657            public ExpandoColumnPersistenceImpl() {
1658                    setModelClass(ExpandoColumn.class);
1659            }
1660    
1661            /**
1662             * Caches the expando column in the entity cache if it is enabled.
1663             *
1664             * @param expandoColumn the expando column
1665             */
1666            @Override
1667            public void cacheResult(ExpandoColumn expandoColumn) {
1668                    EntityCacheUtil.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1669                            ExpandoColumnImpl.class, expandoColumn.getPrimaryKey(),
1670                            expandoColumn);
1671    
1672                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_N,
1673                            new Object[] { expandoColumn.getTableId(), expandoColumn.getName() },
1674                            expandoColumn);
1675    
1676                    expandoColumn.resetOriginalValues();
1677            }
1678    
1679            /**
1680             * Caches the expando columns in the entity cache if it is enabled.
1681             *
1682             * @param expandoColumns the expando columns
1683             */
1684            @Override
1685            public void cacheResult(List<ExpandoColumn> expandoColumns) {
1686                    for (ExpandoColumn expandoColumn : expandoColumns) {
1687                            if (EntityCacheUtil.getResult(
1688                                                    ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1689                                                    ExpandoColumnImpl.class, expandoColumn.getPrimaryKey()) == null) {
1690                                    cacheResult(expandoColumn);
1691                            }
1692                            else {
1693                                    expandoColumn.resetOriginalValues();
1694                            }
1695                    }
1696            }
1697    
1698            /**
1699             * Clears the cache for all expando columns.
1700             *
1701             * <p>
1702             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1703             * </p>
1704             */
1705            @Override
1706            public void clearCache() {
1707                    EntityCacheUtil.clearCache(ExpandoColumnImpl.class);
1708    
1709                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1710                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1711                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1712            }
1713    
1714            /**
1715             * Clears the cache for the expando column.
1716             *
1717             * <p>
1718             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1719             * </p>
1720             */
1721            @Override
1722            public void clearCache(ExpandoColumn expandoColumn) {
1723                    EntityCacheUtil.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1724                            ExpandoColumnImpl.class, expandoColumn.getPrimaryKey());
1725    
1726                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1727                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1728    
1729                    clearUniqueFindersCache(expandoColumn);
1730            }
1731    
1732            @Override
1733            public void clearCache(List<ExpandoColumn> expandoColumns) {
1734                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1735                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1736    
1737                    for (ExpandoColumn expandoColumn : expandoColumns) {
1738                            EntityCacheUtil.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1739                                    ExpandoColumnImpl.class, expandoColumn.getPrimaryKey());
1740    
1741                            clearUniqueFindersCache(expandoColumn);
1742                    }
1743            }
1744    
1745            protected void cacheUniqueFindersCache(ExpandoColumn expandoColumn) {
1746                    if (expandoColumn.isNew()) {
1747                            Object[] args = new Object[] {
1748                                            expandoColumn.getTableId(), expandoColumn.getName()
1749                                    };
1750    
1751                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_N, args,
1752                                    Long.valueOf(1));
1753                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_N, args,
1754                                    expandoColumn);
1755                    }
1756                    else {
1757                            ExpandoColumnModelImpl expandoColumnModelImpl = (ExpandoColumnModelImpl)expandoColumn;
1758    
1759                            if ((expandoColumnModelImpl.getColumnBitmask() &
1760                                            FINDER_PATH_FETCH_BY_T_N.getColumnBitmask()) != 0) {
1761                                    Object[] args = new Object[] {
1762                                                    expandoColumn.getTableId(), expandoColumn.getName()
1763                                            };
1764    
1765                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_N, args,
1766                                            Long.valueOf(1));
1767                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_N, args,
1768                                            expandoColumn);
1769                            }
1770                    }
1771            }
1772    
1773            protected void clearUniqueFindersCache(ExpandoColumn expandoColumn) {
1774                    ExpandoColumnModelImpl expandoColumnModelImpl = (ExpandoColumnModelImpl)expandoColumn;
1775    
1776                    Object[] args = new Object[] {
1777                                    expandoColumn.getTableId(), expandoColumn.getName()
1778                            };
1779    
1780                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1781                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_N, args);
1782    
1783                    if ((expandoColumnModelImpl.getColumnBitmask() &
1784                                    FINDER_PATH_FETCH_BY_T_N.getColumnBitmask()) != 0) {
1785                            args = new Object[] {
1786                                            expandoColumnModelImpl.getOriginalTableId(),
1787                                            expandoColumnModelImpl.getOriginalName()
1788                                    };
1789    
1790                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1791                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_N, args);
1792                    }
1793            }
1794    
1795            /**
1796             * Creates a new expando column with the primary key. Does not add the expando column to the database.
1797             *
1798             * @param columnId the primary key for the new expando column
1799             * @return the new expando column
1800             */
1801            @Override
1802            public ExpandoColumn create(long columnId) {
1803                    ExpandoColumn expandoColumn = new ExpandoColumnImpl();
1804    
1805                    expandoColumn.setNew(true);
1806                    expandoColumn.setPrimaryKey(columnId);
1807    
1808                    return expandoColumn;
1809            }
1810    
1811            /**
1812             * Removes the expando column with the primary key from the database. Also notifies the appropriate model listeners.
1813             *
1814             * @param columnId the primary key of the expando column
1815             * @return the expando column that was removed
1816             * @throws NoSuchColumnException if a expando column with the primary key could not be found
1817             */
1818            @Override
1819            public ExpandoColumn remove(long columnId) throws NoSuchColumnException {
1820                    return remove((Serializable)columnId);
1821            }
1822    
1823            /**
1824             * Removes the expando column with the primary key from the database. Also notifies the appropriate model listeners.
1825             *
1826             * @param primaryKey the primary key of the expando column
1827             * @return the expando column that was removed
1828             * @throws NoSuchColumnException if a expando column with the primary key could not be found
1829             */
1830            @Override
1831            public ExpandoColumn remove(Serializable primaryKey)
1832                    throws NoSuchColumnException {
1833                    Session session = null;
1834    
1835                    try {
1836                            session = openSession();
1837    
1838                            ExpandoColumn expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
1839                                            primaryKey);
1840    
1841                            if (expandoColumn == null) {
1842                                    if (_log.isWarnEnabled()) {
1843                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1844                                    }
1845    
1846                                    throw new NoSuchColumnException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1847                                            primaryKey);
1848                            }
1849    
1850                            return remove(expandoColumn);
1851                    }
1852                    catch (NoSuchColumnException nsee) {
1853                            throw nsee;
1854                    }
1855                    catch (Exception e) {
1856                            throw processException(e);
1857                    }
1858                    finally {
1859                            closeSession(session);
1860                    }
1861            }
1862    
1863            @Override
1864            protected ExpandoColumn removeImpl(ExpandoColumn expandoColumn) {
1865                    expandoColumn = toUnwrappedModel(expandoColumn);
1866    
1867                    Session session = null;
1868    
1869                    try {
1870                            session = openSession();
1871    
1872                            if (!session.contains(expandoColumn)) {
1873                                    expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
1874                                                    expandoColumn.getPrimaryKeyObj());
1875                            }
1876    
1877                            if (expandoColumn != null) {
1878                                    session.delete(expandoColumn);
1879                            }
1880                    }
1881                    catch (Exception e) {
1882                            throw processException(e);
1883                    }
1884                    finally {
1885                            closeSession(session);
1886                    }
1887    
1888                    if (expandoColumn != null) {
1889                            clearCache(expandoColumn);
1890                    }
1891    
1892                    return expandoColumn;
1893            }
1894    
1895            @Override
1896            public ExpandoColumn updateImpl(ExpandoColumn expandoColumn) {
1897                    expandoColumn = toUnwrappedModel(expandoColumn);
1898    
1899                    boolean isNew = expandoColumn.isNew();
1900    
1901                    ExpandoColumnModelImpl expandoColumnModelImpl = (ExpandoColumnModelImpl)expandoColumn;
1902    
1903                    Session session = null;
1904    
1905                    try {
1906                            session = openSession();
1907    
1908                            if (expandoColumn.isNew()) {
1909                                    session.save(expandoColumn);
1910    
1911                                    expandoColumn.setNew(false);
1912                            }
1913                            else {
1914                                    session.merge(expandoColumn);
1915                            }
1916                    }
1917                    catch (Exception e) {
1918                            throw processException(e);
1919                    }
1920                    finally {
1921                            closeSession(session);
1922                    }
1923    
1924                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1925    
1926                    if (isNew || !ExpandoColumnModelImpl.COLUMN_BITMASK_ENABLED) {
1927                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1928                    }
1929    
1930                    else {
1931                            if ((expandoColumnModelImpl.getColumnBitmask() &
1932                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID.getColumnBitmask()) != 0) {
1933                                    Object[] args = new Object[] {
1934                                                    expandoColumnModelImpl.getOriginalTableId()
1935                                            };
1936    
1937                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TABLEID, args);
1938                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID,
1939                                            args);
1940    
1941                                    args = new Object[] { expandoColumnModelImpl.getTableId() };
1942    
1943                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TABLEID, args);
1944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TABLEID,
1945                                            args);
1946                            }
1947    
1948                            if ((expandoColumnModelImpl.getColumnBitmask() &
1949                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N.getColumnBitmask()) != 0) {
1950                                    Object[] args = new Object[] {
1951                                                    expandoColumnModelImpl.getOriginalTableId(),
1952                                                    expandoColumnModelImpl.getOriginalName()
1953                                            };
1954    
1955                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1956                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N,
1957                                            args);
1958    
1959                                    args = new Object[] {
1960                                                    expandoColumnModelImpl.getTableId(),
1961                                                    expandoColumnModelImpl.getName()
1962                                            };
1963    
1964                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_N, args);
1965                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N,
1966                                            args);
1967                            }
1968                    }
1969    
1970                    EntityCacheUtil.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
1971                            ExpandoColumnImpl.class, expandoColumn.getPrimaryKey(),
1972                            expandoColumn, false);
1973    
1974                    clearUniqueFindersCache(expandoColumn);
1975                    cacheUniqueFindersCache(expandoColumn);
1976    
1977                    expandoColumn.resetOriginalValues();
1978    
1979                    return expandoColumn;
1980            }
1981    
1982            protected ExpandoColumn toUnwrappedModel(ExpandoColumn expandoColumn) {
1983                    if (expandoColumn instanceof ExpandoColumnImpl) {
1984                            return expandoColumn;
1985                    }
1986    
1987                    ExpandoColumnImpl expandoColumnImpl = new ExpandoColumnImpl();
1988    
1989                    expandoColumnImpl.setNew(expandoColumn.isNew());
1990                    expandoColumnImpl.setPrimaryKey(expandoColumn.getPrimaryKey());
1991    
1992                    expandoColumnImpl.setColumnId(expandoColumn.getColumnId());
1993                    expandoColumnImpl.setCompanyId(expandoColumn.getCompanyId());
1994                    expandoColumnImpl.setTableId(expandoColumn.getTableId());
1995                    expandoColumnImpl.setName(expandoColumn.getName());
1996                    expandoColumnImpl.setType(expandoColumn.getType());
1997                    expandoColumnImpl.setDefaultData(expandoColumn.getDefaultData());
1998                    expandoColumnImpl.setTypeSettings(expandoColumn.getTypeSettings());
1999    
2000                    return expandoColumnImpl;
2001            }
2002    
2003            /**
2004             * Returns the expando column with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2005             *
2006             * @param primaryKey the primary key of the expando column
2007             * @return the expando column
2008             * @throws NoSuchColumnException if a expando column with the primary key could not be found
2009             */
2010            @Override
2011            public ExpandoColumn findByPrimaryKey(Serializable primaryKey)
2012                    throws NoSuchColumnException {
2013                    ExpandoColumn expandoColumn = fetchByPrimaryKey(primaryKey);
2014    
2015                    if (expandoColumn == null) {
2016                            if (_log.isWarnEnabled()) {
2017                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2018                            }
2019    
2020                            throw new NoSuchColumnException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2021                                    primaryKey);
2022                    }
2023    
2024                    return expandoColumn;
2025            }
2026    
2027            /**
2028             * Returns the expando column with the primary key or throws a {@link NoSuchColumnException} if it could not be found.
2029             *
2030             * @param columnId the primary key of the expando column
2031             * @return the expando column
2032             * @throws NoSuchColumnException if a expando column with the primary key could not be found
2033             */
2034            @Override
2035            public ExpandoColumn findByPrimaryKey(long columnId)
2036                    throws NoSuchColumnException {
2037                    return findByPrimaryKey((Serializable)columnId);
2038            }
2039    
2040            /**
2041             * Returns the expando column with the primary key or returns <code>null</code> if it could not be found.
2042             *
2043             * @param primaryKey the primary key of the expando column
2044             * @return the expando column, or <code>null</code> if a expando column with the primary key could not be found
2045             */
2046            @Override
2047            public ExpandoColumn fetchByPrimaryKey(Serializable primaryKey) {
2048                    ExpandoColumn expandoColumn = (ExpandoColumn)EntityCacheUtil.getResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2049                                    ExpandoColumnImpl.class, primaryKey);
2050    
2051                    if (expandoColumn == _nullExpandoColumn) {
2052                            return null;
2053                    }
2054    
2055                    if (expandoColumn == null) {
2056                            Session session = null;
2057    
2058                            try {
2059                                    session = openSession();
2060    
2061                                    expandoColumn = (ExpandoColumn)session.get(ExpandoColumnImpl.class,
2062                                                    primaryKey);
2063    
2064                                    if (expandoColumn != null) {
2065                                            cacheResult(expandoColumn);
2066                                    }
2067                                    else {
2068                                            EntityCacheUtil.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2069                                                    ExpandoColumnImpl.class, primaryKey, _nullExpandoColumn);
2070                                    }
2071                            }
2072                            catch (Exception e) {
2073                                    EntityCacheUtil.removeResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2074                                            ExpandoColumnImpl.class, primaryKey);
2075    
2076                                    throw processException(e);
2077                            }
2078                            finally {
2079                                    closeSession(session);
2080                            }
2081                    }
2082    
2083                    return expandoColumn;
2084            }
2085    
2086            /**
2087             * Returns the expando column with the primary key or returns <code>null</code> if it could not be found.
2088             *
2089             * @param columnId the primary key of the expando column
2090             * @return the expando column, or <code>null</code> if a expando column with the primary key could not be found
2091             */
2092            @Override
2093            public ExpandoColumn fetchByPrimaryKey(long columnId) {
2094                    return fetchByPrimaryKey((Serializable)columnId);
2095            }
2096    
2097            @Override
2098            public Map<Serializable, ExpandoColumn> fetchByPrimaryKeys(
2099                    Set<Serializable> primaryKeys) {
2100                    if (primaryKeys.isEmpty()) {
2101                            return Collections.emptyMap();
2102                    }
2103    
2104                    Map<Serializable, ExpandoColumn> map = new HashMap<Serializable, ExpandoColumn>();
2105    
2106                    if (primaryKeys.size() == 1) {
2107                            Iterator<Serializable> iterator = primaryKeys.iterator();
2108    
2109                            Serializable primaryKey = iterator.next();
2110    
2111                            ExpandoColumn expandoColumn = fetchByPrimaryKey(primaryKey);
2112    
2113                            if (expandoColumn != null) {
2114                                    map.put(primaryKey, expandoColumn);
2115                            }
2116    
2117                            return map;
2118                    }
2119    
2120                    Set<Serializable> uncachedPrimaryKeys = null;
2121    
2122                    for (Serializable primaryKey : primaryKeys) {
2123                            ExpandoColumn expandoColumn = (ExpandoColumn)EntityCacheUtil.getResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2124                                            ExpandoColumnImpl.class, primaryKey);
2125    
2126                            if (expandoColumn == null) {
2127                                    if (uncachedPrimaryKeys == null) {
2128                                            uncachedPrimaryKeys = new HashSet<Serializable>();
2129                                    }
2130    
2131                                    uncachedPrimaryKeys.add(primaryKey);
2132                            }
2133                            else {
2134                                    map.put(primaryKey, expandoColumn);
2135                            }
2136                    }
2137    
2138                    if (uncachedPrimaryKeys == null) {
2139                            return map;
2140                    }
2141    
2142                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2143                                    1);
2144    
2145                    query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE_PKS_IN);
2146    
2147                    for (Serializable primaryKey : uncachedPrimaryKeys) {
2148                            query.append(String.valueOf(primaryKey));
2149    
2150                            query.append(StringPool.COMMA);
2151                    }
2152    
2153                    query.setIndex(query.index() - 1);
2154    
2155                    query.append(StringPool.CLOSE_PARENTHESIS);
2156    
2157                    String sql = query.toString();
2158    
2159                    Session session = null;
2160    
2161                    try {
2162                            session = openSession();
2163    
2164                            Query q = session.createQuery(sql);
2165    
2166                            for (ExpandoColumn expandoColumn : (List<ExpandoColumn>)q.list()) {
2167                                    map.put(expandoColumn.getPrimaryKeyObj(), expandoColumn);
2168    
2169                                    cacheResult(expandoColumn);
2170    
2171                                    uncachedPrimaryKeys.remove(expandoColumn.getPrimaryKeyObj());
2172                            }
2173    
2174                            for (Serializable primaryKey : uncachedPrimaryKeys) {
2175                                    EntityCacheUtil.putResult(ExpandoColumnModelImpl.ENTITY_CACHE_ENABLED,
2176                                            ExpandoColumnImpl.class, primaryKey, _nullExpandoColumn);
2177                            }
2178                    }
2179                    catch (Exception e) {
2180                            throw processException(e);
2181                    }
2182                    finally {
2183                            closeSession(session);
2184                    }
2185    
2186                    return map;
2187            }
2188    
2189            /**
2190             * Returns all the expando columns.
2191             *
2192             * @return the expando columns
2193             */
2194            @Override
2195            public List<ExpandoColumn> findAll() {
2196                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2197            }
2198    
2199            /**
2200             * Returns a range of all the expando columns.
2201             *
2202             * <p>
2203             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2204             * </p>
2205             *
2206             * @param start the lower bound of the range of expando columns
2207             * @param end the upper bound of the range of expando columns (not inclusive)
2208             * @return the range of expando columns
2209             */
2210            @Override
2211            public List<ExpandoColumn> findAll(int start, int end) {
2212                    return findAll(start, end, null);
2213            }
2214    
2215            /**
2216             * Returns an ordered range of all the expando columns.
2217             *
2218             * <p>
2219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link ExpandoColumnModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2220             * </p>
2221             *
2222             * @param start the lower bound of the range of expando columns
2223             * @param end the upper bound of the range of expando columns (not inclusive)
2224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2225             * @return the ordered range of expando columns
2226             */
2227            @Override
2228            public List<ExpandoColumn> findAll(int start, int end,
2229                    OrderByComparator<ExpandoColumn> orderByComparator) {
2230                    boolean pagination = true;
2231                    FinderPath finderPath = null;
2232                    Object[] finderArgs = null;
2233    
2234                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2235                                    (orderByComparator == null)) {
2236                            pagination = false;
2237                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2238                            finderArgs = FINDER_ARGS_EMPTY;
2239                    }
2240                    else {
2241                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2242                            finderArgs = new Object[] { start, end, orderByComparator };
2243                    }
2244    
2245                    List<ExpandoColumn> list = (List<ExpandoColumn>)FinderCacheUtil.getResult(finderPath,
2246                                    finderArgs, this);
2247    
2248                    if (list == null) {
2249                            StringBundler query = null;
2250                            String sql = null;
2251    
2252                            if (orderByComparator != null) {
2253                                    query = new StringBundler(2 +
2254                                                    (orderByComparator.getOrderByFields().length * 3));
2255    
2256                                    query.append(_SQL_SELECT_EXPANDOCOLUMN);
2257    
2258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2259                                            orderByComparator);
2260    
2261                                    sql = query.toString();
2262                            }
2263                            else {
2264                                    sql = _SQL_SELECT_EXPANDOCOLUMN;
2265    
2266                                    if (pagination) {
2267                                            sql = sql.concat(ExpandoColumnModelImpl.ORDER_BY_JPQL);
2268                                    }
2269                            }
2270    
2271                            Session session = null;
2272    
2273                            try {
2274                                    session = openSession();
2275    
2276                                    Query q = session.createQuery(sql);
2277    
2278                                    if (!pagination) {
2279                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
2280                                                            start, end, false);
2281    
2282                                            Collections.sort(list);
2283    
2284                                            list = Collections.unmodifiableList(list);
2285                                    }
2286                                    else {
2287                                            list = (List<ExpandoColumn>)QueryUtil.list(q, getDialect(),
2288                                                            start, end);
2289                                    }
2290    
2291                                    cacheResult(list);
2292    
2293                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2294                            }
2295                            catch (Exception e) {
2296                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2297    
2298                                    throw processException(e);
2299                            }
2300                            finally {
2301                                    closeSession(session);
2302                            }
2303                    }
2304    
2305                    return list;
2306            }
2307    
2308            /**
2309             * Removes all the expando columns from the database.
2310             *
2311             */
2312            @Override
2313            public void removeAll() {
2314                    for (ExpandoColumn expandoColumn : findAll()) {
2315                            remove(expandoColumn);
2316                    }
2317            }
2318    
2319            /**
2320             * Returns the number of expando columns.
2321             *
2322             * @return the number of expando columns
2323             */
2324            @Override
2325            public int countAll() {
2326                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2327                                    FINDER_ARGS_EMPTY, this);
2328    
2329                    if (count == null) {
2330                            Session session = null;
2331    
2332                            try {
2333                                    session = openSession();
2334    
2335                                    Query q = session.createQuery(_SQL_COUNT_EXPANDOCOLUMN);
2336    
2337                                    count = (Long)q.uniqueResult();
2338    
2339                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2340                                            FINDER_ARGS_EMPTY, count);
2341                            }
2342                            catch (Exception e) {
2343                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2344                                            FINDER_ARGS_EMPTY);
2345    
2346                                    throw processException(e);
2347                            }
2348                            finally {
2349                                    closeSession(session);
2350                            }
2351                    }
2352    
2353                    return count.intValue();
2354            }
2355    
2356            @Override
2357            protected Set<String> getBadColumnNames() {
2358                    return _badColumnNames;
2359            }
2360    
2361            /**
2362             * Initializes the expando column persistence.
2363             */
2364            public void afterPropertiesSet() {
2365            }
2366    
2367            public void destroy() {
2368                    EntityCacheUtil.removeCache(ExpandoColumnImpl.class.getName());
2369                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2370                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2371                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2372            }
2373    
2374            private static final String _SQL_SELECT_EXPANDOCOLUMN = "SELECT expandoColumn FROM ExpandoColumn expandoColumn";
2375            private static final String _SQL_SELECT_EXPANDOCOLUMN_WHERE_PKS_IN = "SELECT expandoColumn FROM ExpandoColumn expandoColumn WHERE columnId IN (";
2376            private static final String _SQL_SELECT_EXPANDOCOLUMN_WHERE = "SELECT expandoColumn FROM ExpandoColumn expandoColumn WHERE ";
2377            private static final String _SQL_COUNT_EXPANDOCOLUMN = "SELECT COUNT(expandoColumn) FROM ExpandoColumn expandoColumn";
2378            private static final String _SQL_COUNT_EXPANDOCOLUMN_WHERE = "SELECT COUNT(expandoColumn) FROM ExpandoColumn expandoColumn WHERE ";
2379            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "expandoColumn.columnId";
2380            private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE = "SELECT DISTINCT {expandoColumn.*} FROM ExpandoColumn expandoColumn WHERE ";
2381            private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1 =
2382                    "SELECT {ExpandoColumn.*} FROM (SELECT DISTINCT expandoColumn.columnId FROM ExpandoColumn expandoColumn WHERE ";
2383            private static final String _FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2 =
2384                    ") TEMP_TABLE INNER JOIN ExpandoColumn ON TEMP_TABLE.columnId = ExpandoColumn.columnId";
2385            private static final String _FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE = "SELECT COUNT(DISTINCT expandoColumn.columnId) AS COUNT_VALUE FROM ExpandoColumn expandoColumn WHERE ";
2386            private static final String _FILTER_ENTITY_ALIAS = "expandoColumn";
2387            private static final String _FILTER_ENTITY_TABLE = "ExpandoColumn";
2388            private static final String _ORDER_BY_ENTITY_ALIAS = "expandoColumn.";
2389            private static final String _ORDER_BY_ENTITY_TABLE = "ExpandoColumn.";
2390            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ExpandoColumn exists with the primary key ";
2391            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ExpandoColumn exists with the key {";
2392            private static final Log _log = LogFactoryUtil.getLog(ExpandoColumnPersistenceImpl.class);
2393            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2394                                    "type"
2395                            });
2396            private static final ExpandoColumn _nullExpandoColumn = new ExpandoColumnImpl() {
2397                            @Override
2398                            public Object clone() {
2399                                    return this;
2400                            }
2401    
2402                            @Override
2403                            public CacheModel<ExpandoColumn> toCacheModel() {
2404                                    return _nullExpandoColumnCacheModel;
2405                            }
2406                    };
2407    
2408            private static final CacheModel<ExpandoColumn> _nullExpandoColumnCacheModel = new CacheModel<ExpandoColumn>() {
2409                            @Override
2410                            public ExpandoColumn toEntityModel() {
2411                                    return _nullExpandoColumn;
2412                            }
2413                    };
2414    }