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