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