001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.expando.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
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.Validator;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.ResourcePersistence;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.expando.NoSuchTableException;
044    import com.liferay.portlet.expando.model.ExpandoTable;
045    import com.liferay.portlet.expando.model.impl.ExpandoTableImpl;
046    import com.liferay.portlet.expando.model.impl.ExpandoTableModelImpl;
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 table service.
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link ExpandoTableUtil} to access the expando table persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
059     * </p>
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see ExpandoTablePersistence
067     * @see ExpandoTableUtil
068     * @generated
069     */
070    public class ExpandoTablePersistenceImpl extends BasePersistenceImpl<ExpandoTable>
071            implements ExpandoTablePersistence {
072            public static final String FINDER_CLASS_NAME_ENTITY = ExpandoTableImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074                    ".List";
075            public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
076                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
077                            "findByC_C",
078                            new String[] {
079                                    Long.class.getName(), Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
085                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
086                            "countByC_C",
087                            new String[] { Long.class.getName(), Long.class.getName() });
088            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_N = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
089                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C_N",
091                            new String[] {
092                                    Long.class.getName(), Long.class.getName(),
093                                    String.class.getName()
094                            });
095            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_N = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
096                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097                            "countByC_C_N",
098                            new String[] {
099                                    Long.class.getName(), Long.class.getName(),
100                                    String.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
103                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104                            "findAll", new String[0]);
105            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
106                            ExpandoTableModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107                            "countAll", new String[0]);
108    
109            /**
110             * Caches the expando table in the entity cache if it is enabled.
111             *
112             * @param expandoTable the expando table to cache
113             */
114            public void cacheResult(ExpandoTable expandoTable) {
115                    EntityCacheUtil.putResult(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
116                            ExpandoTableImpl.class, expandoTable.getPrimaryKey(), expandoTable);
117    
118                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_N,
119                            new Object[] {
120                                    new Long(expandoTable.getCompanyId()),
121                                    new Long(expandoTable.getClassNameId()),
122                                    
123                            expandoTable.getName()
124                            }, expandoTable);
125            }
126    
127            /**
128             * Caches the expando tables in the entity cache if it is enabled.
129             *
130             * @param expandoTables the expando tables to cache
131             */
132            public void cacheResult(List<ExpandoTable> expandoTables) {
133                    for (ExpandoTable expandoTable : expandoTables) {
134                            if (EntityCacheUtil.getResult(
135                                                    ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
136                                                    ExpandoTableImpl.class, expandoTable.getPrimaryKey(),
137                                                    this) == null) {
138                                    cacheResult(expandoTable);
139                            }
140                    }
141            }
142    
143            /**
144             * Clears the cache for all expando tables.
145             *
146             * <p>
147             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
148             * </p>
149             */
150            public void clearCache() {
151                    CacheRegistryUtil.clear(ExpandoTableImpl.class.getName());
152                    EntityCacheUtil.clearCache(ExpandoTableImpl.class.getName());
153                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
154                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
155            }
156    
157            /**
158             * Clears the cache for the expando table.
159             *
160             * <p>
161             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
162             * </p>
163             */
164            public void clearCache(ExpandoTable expandoTable) {
165                    EntityCacheUtil.removeResult(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
166                            ExpandoTableImpl.class, expandoTable.getPrimaryKey());
167    
168                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_N,
169                            new Object[] {
170                                    new Long(expandoTable.getCompanyId()),
171                                    new Long(expandoTable.getClassNameId()),
172                                    
173                            expandoTable.getName()
174                            });
175            }
176    
177            /**
178             * Creates a new expando table with the primary key. Does not add the expando table to the database.
179             *
180             * @param tableId the primary key for the new expando table
181             * @return the new expando table
182             */
183            public ExpandoTable create(long tableId) {
184                    ExpandoTable expandoTable = new ExpandoTableImpl();
185    
186                    expandoTable.setNew(true);
187                    expandoTable.setPrimaryKey(tableId);
188    
189                    return expandoTable;
190            }
191    
192            /**
193             * Removes the expando table with the primary key from the database. Also notifies the appropriate model listeners.
194             *
195             * @param primaryKey the primary key of the expando table to remove
196             * @return the expando table that was removed
197             * @throws com.liferay.portal.NoSuchModelException if a expando table with the primary key could not be found
198             * @throws SystemException if a system exception occurred
199             */
200            public ExpandoTable remove(Serializable primaryKey)
201                    throws NoSuchModelException, SystemException {
202                    return remove(((Long)primaryKey).longValue());
203            }
204    
205            /**
206             * Removes the expando table with the primary key from the database. Also notifies the appropriate model listeners.
207             *
208             * @param tableId the primary key of the expando table to remove
209             * @return the expando table that was removed
210             * @throws com.liferay.portlet.expando.NoSuchTableException if a expando table with the primary key could not be found
211             * @throws SystemException if a system exception occurred
212             */
213            public ExpandoTable remove(long tableId)
214                    throws NoSuchTableException, SystemException {
215                    Session session = null;
216    
217                    try {
218                            session = openSession();
219    
220                            ExpandoTable expandoTable = (ExpandoTable)session.get(ExpandoTableImpl.class,
221                                            new Long(tableId));
222    
223                            if (expandoTable == null) {
224                                    if (_log.isWarnEnabled()) {
225                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tableId);
226                                    }
227    
228                                    throw new NoSuchTableException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
229                                            tableId);
230                            }
231    
232                            return remove(expandoTable);
233                    }
234                    catch (NoSuchTableException nsee) {
235                            throw nsee;
236                    }
237                    catch (Exception e) {
238                            throw processException(e);
239                    }
240                    finally {
241                            closeSession(session);
242                    }
243            }
244    
245            protected ExpandoTable removeImpl(ExpandoTable expandoTable)
246                    throws SystemException {
247                    expandoTable = toUnwrappedModel(expandoTable);
248    
249                    Session session = null;
250    
251                    try {
252                            session = openSession();
253    
254                            BatchSessionUtil.delete(session, expandoTable);
255                    }
256                    catch (Exception e) {
257                            throw processException(e);
258                    }
259                    finally {
260                            closeSession(session);
261                    }
262    
263                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264    
265                    ExpandoTableModelImpl expandoTableModelImpl = (ExpandoTableModelImpl)expandoTable;
266    
267                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_N,
268                            new Object[] {
269                                    new Long(expandoTableModelImpl.getOriginalCompanyId()),
270                                    new Long(expandoTableModelImpl.getOriginalClassNameId()),
271                                    
272                            expandoTableModelImpl.getOriginalName()
273                            });
274    
275                    EntityCacheUtil.removeResult(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
276                            ExpandoTableImpl.class, expandoTable.getPrimaryKey());
277    
278                    return expandoTable;
279            }
280    
281            public ExpandoTable updateImpl(
282                    com.liferay.portlet.expando.model.ExpandoTable expandoTable,
283                    boolean merge) throws SystemException {
284                    expandoTable = toUnwrappedModel(expandoTable);
285    
286                    boolean isNew = expandoTable.isNew();
287    
288                    ExpandoTableModelImpl expandoTableModelImpl = (ExpandoTableModelImpl)expandoTable;
289    
290                    Session session = null;
291    
292                    try {
293                            session = openSession();
294    
295                            BatchSessionUtil.update(session, expandoTable, merge);
296    
297                            expandoTable.setNew(false);
298                    }
299                    catch (Exception e) {
300                            throw processException(e);
301                    }
302                    finally {
303                            closeSession(session);
304                    }
305    
306                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
307    
308                    EntityCacheUtil.putResult(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
309                            ExpandoTableImpl.class, expandoTable.getPrimaryKey(), expandoTable);
310    
311                    if (!isNew &&
312                                    ((expandoTable.getCompanyId() != expandoTableModelImpl.getOriginalCompanyId()) ||
313                                    (expandoTable.getClassNameId() != expandoTableModelImpl.getOriginalClassNameId()) ||
314                                    !Validator.equals(expandoTable.getName(),
315                                            expandoTableModelImpl.getOriginalName()))) {
316                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_N,
317                                    new Object[] {
318                                            new Long(expandoTableModelImpl.getOriginalCompanyId()),
319                                            new Long(expandoTableModelImpl.getOriginalClassNameId()),
320                                            
321                                    expandoTableModelImpl.getOriginalName()
322                                    });
323                    }
324    
325                    if (isNew ||
326                                    ((expandoTable.getCompanyId() != expandoTableModelImpl.getOriginalCompanyId()) ||
327                                    (expandoTable.getClassNameId() != expandoTableModelImpl.getOriginalClassNameId()) ||
328                                    !Validator.equals(expandoTable.getName(),
329                                            expandoTableModelImpl.getOriginalName()))) {
330                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_N,
331                                    new Object[] {
332                                            new Long(expandoTable.getCompanyId()),
333                                            new Long(expandoTable.getClassNameId()),
334                                            
335                                    expandoTable.getName()
336                                    }, expandoTable);
337                    }
338    
339                    return expandoTable;
340            }
341    
342            protected ExpandoTable toUnwrappedModel(ExpandoTable expandoTable) {
343                    if (expandoTable instanceof ExpandoTableImpl) {
344                            return expandoTable;
345                    }
346    
347                    ExpandoTableImpl expandoTableImpl = new ExpandoTableImpl();
348    
349                    expandoTableImpl.setNew(expandoTable.isNew());
350                    expandoTableImpl.setPrimaryKey(expandoTable.getPrimaryKey());
351    
352                    expandoTableImpl.setTableId(expandoTable.getTableId());
353                    expandoTableImpl.setCompanyId(expandoTable.getCompanyId());
354                    expandoTableImpl.setClassNameId(expandoTable.getClassNameId());
355                    expandoTableImpl.setName(expandoTable.getName());
356    
357                    return expandoTableImpl;
358            }
359    
360            /**
361             * Finds the expando table with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
362             *
363             * @param primaryKey the primary key of the expando table to find
364             * @return the expando table
365             * @throws com.liferay.portal.NoSuchModelException if a expando table with the primary key could not be found
366             * @throws SystemException if a system exception occurred
367             */
368            public ExpandoTable findByPrimaryKey(Serializable primaryKey)
369                    throws NoSuchModelException, SystemException {
370                    return findByPrimaryKey(((Long)primaryKey).longValue());
371            }
372    
373            /**
374             * Finds the expando table with the primary key or throws a {@link com.liferay.portlet.expando.NoSuchTableException} if it could not be found.
375             *
376             * @param tableId the primary key of the expando table to find
377             * @return the expando table
378             * @throws com.liferay.portlet.expando.NoSuchTableException if a expando table with the primary key could not be found
379             * @throws SystemException if a system exception occurred
380             */
381            public ExpandoTable findByPrimaryKey(long tableId)
382                    throws NoSuchTableException, SystemException {
383                    ExpandoTable expandoTable = fetchByPrimaryKey(tableId);
384    
385                    if (expandoTable == null) {
386                            if (_log.isWarnEnabled()) {
387                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tableId);
388                            }
389    
390                            throw new NoSuchTableException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
391                                    tableId);
392                    }
393    
394                    return expandoTable;
395            }
396    
397            /**
398             * Finds the expando table with the primary key or returns <code>null</code> if it could not be found.
399             *
400             * @param primaryKey the primary key of the expando table to find
401             * @return the expando table, or <code>null</code> if a expando table with the primary key could not be found
402             * @throws SystemException if a system exception occurred
403             */
404            public ExpandoTable fetchByPrimaryKey(Serializable primaryKey)
405                    throws SystemException {
406                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
407            }
408    
409            /**
410             * Finds the expando table with the primary key or returns <code>null</code> if it could not be found.
411             *
412             * @param tableId the primary key of the expando table to find
413             * @return the expando table, or <code>null</code> if a expando table with the primary key could not be found
414             * @throws SystemException if a system exception occurred
415             */
416            public ExpandoTable fetchByPrimaryKey(long tableId)
417                    throws SystemException {
418                    ExpandoTable expandoTable = (ExpandoTable)EntityCacheUtil.getResult(ExpandoTableModelImpl.ENTITY_CACHE_ENABLED,
419                                    ExpandoTableImpl.class, tableId, this);
420    
421                    if (expandoTable == null) {
422                            Session session = null;
423    
424                            try {
425                                    session = openSession();
426    
427                                    expandoTable = (ExpandoTable)session.get(ExpandoTableImpl.class,
428                                                    new Long(tableId));
429                            }
430                            catch (Exception e) {
431                                    throw processException(e);
432                            }
433                            finally {
434                                    if (expandoTable != null) {
435                                            cacheResult(expandoTable);
436                                    }
437    
438                                    closeSession(session);
439                            }
440                    }
441    
442                    return expandoTable;
443            }
444    
445            /**
446             * Finds all the expando tables where companyId = &#63; and classNameId = &#63;.
447             *
448             * @param companyId the company id to search with
449             * @param classNameId the class name id to search with
450             * @return the matching expando tables
451             * @throws SystemException if a system exception occurred
452             */
453            public List<ExpandoTable> findByC_C(long companyId, long classNameId)
454                    throws SystemException {
455                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
456                            QueryUtil.ALL_POS, null);
457            }
458    
459            /**
460             * Finds a range of all the expando tables where companyId = &#63; and classNameId = &#63;.
461             *
462             * <p>
463             * 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.
464             * </p>
465             *
466             * @param companyId the company id to search with
467             * @param classNameId the class name id to search with
468             * @param start the lower bound of the range of expando tables to return
469             * @param end the upper bound of the range of expando tables to return (not inclusive)
470             * @return the range of matching expando tables
471             * @throws SystemException if a system exception occurred
472             */
473            public List<ExpandoTable> findByC_C(long companyId, long classNameId,
474                    int start, int end) throws SystemException {
475                    return findByC_C(companyId, classNameId, start, end, null);
476            }
477    
478            /**
479             * Finds an ordered range of all the expando tables where companyId = &#63; and classNameId = &#63;.
480             *
481             * <p>
482             * 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.
483             * </p>
484             *
485             * @param companyId the company id to search with
486             * @param classNameId the class name id to search with
487             * @param start the lower bound of the range of expando tables to return
488             * @param end the upper bound of the range of expando tables to return (not inclusive)
489             * @param orderByComparator the comparator to order the results by
490             * @return the ordered range of matching expando tables
491             * @throws SystemException if a system exception occurred
492             */
493            public List<ExpandoTable> findByC_C(long companyId, long classNameId,
494                    int start, int end, OrderByComparator orderByComparator)
495                    throws SystemException {
496                    Object[] finderArgs = new Object[] {
497                                    companyId, classNameId,
498                                    
499                                    String.valueOf(start), String.valueOf(end),
500                                    String.valueOf(orderByComparator)
501                            };
502    
503                    List<ExpandoTable> list = (List<ExpandoTable>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
504                                    finderArgs, this);
505    
506                    if (list == null) {
507                            Session session = null;
508    
509                            try {
510                                    session = openSession();
511    
512                                    StringBundler query = null;
513    
514                                    if (orderByComparator != null) {
515                                            query = new StringBundler(4 +
516                                                            (orderByComparator.getOrderByFields().length * 3));
517                                    }
518                                    else {
519                                            query = new StringBundler(3);
520                                    }
521    
522                                    query.append(_SQL_SELECT_EXPANDOTABLE_WHERE);
523    
524                                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
525    
526                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
527    
528                                    if (orderByComparator != null) {
529                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
530                                                    orderByComparator);
531                                    }
532    
533                                    String sql = query.toString();
534    
535                                    Query q = session.createQuery(sql);
536    
537                                    QueryPos qPos = QueryPos.getInstance(q);
538    
539                                    qPos.add(companyId);
540    
541                                    qPos.add(classNameId);
542    
543                                    list = (List<ExpandoTable>)QueryUtil.list(q, getDialect(),
544                                                    start, end);
545                            }
546                            catch (Exception e) {
547                                    throw processException(e);
548                            }
549                            finally {
550                                    if (list == null) {
551                                            list = new ArrayList<ExpandoTable>();
552                                    }
553    
554                                    cacheResult(list);
555    
556                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
557                                            list);
558    
559                                    closeSession(session);
560                            }
561                    }
562    
563                    return list;
564            }
565    
566            /**
567             * Finds the first expando table in the ordered set where companyId = &#63; and classNameId = &#63;.
568             *
569             * <p>
570             * 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.
571             * </p>
572             *
573             * @param companyId the company id to search with
574             * @param classNameId the class name id to search with
575             * @param orderByComparator the comparator to order the set by
576             * @return the first matching expando table
577             * @throws com.liferay.portlet.expando.NoSuchTableException if a matching expando table could not be found
578             * @throws SystemException if a system exception occurred
579             */
580            public ExpandoTable findByC_C_First(long companyId, long classNameId,
581                    OrderByComparator orderByComparator)
582                    throws NoSuchTableException, SystemException {
583                    List<ExpandoTable> list = findByC_C(companyId, classNameId, 0, 1,
584                                    orderByComparator);
585    
586                    if (list.isEmpty()) {
587                            StringBundler msg = new StringBundler(6);
588    
589                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
590    
591                            msg.append("companyId=");
592                            msg.append(companyId);
593    
594                            msg.append(", classNameId=");
595                            msg.append(classNameId);
596    
597                            msg.append(StringPool.CLOSE_CURLY_BRACE);
598    
599                            throw new NoSuchTableException(msg.toString());
600                    }
601                    else {
602                            return list.get(0);
603                    }
604            }
605    
606            /**
607             * Finds the last expando table in the ordered set where companyId = &#63; and classNameId = &#63;.
608             *
609             * <p>
610             * 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.
611             * </p>
612             *
613             * @param companyId the company id to search with
614             * @param classNameId the class name id to search with
615             * @param orderByComparator the comparator to order the set by
616             * @return the last matching expando table
617             * @throws com.liferay.portlet.expando.NoSuchTableException if a matching expando table could not be found
618             * @throws SystemException if a system exception occurred
619             */
620            public ExpandoTable findByC_C_Last(long companyId, long classNameId,
621                    OrderByComparator orderByComparator)
622                    throws NoSuchTableException, SystemException {
623                    int count = countByC_C(companyId, classNameId);
624    
625                    List<ExpandoTable> list = findByC_C(companyId, classNameId, count - 1,
626                                    count, orderByComparator);
627    
628                    if (list.isEmpty()) {
629                            StringBundler msg = new StringBundler(6);
630    
631                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
632    
633                            msg.append("companyId=");
634                            msg.append(companyId);
635    
636                            msg.append(", classNameId=");
637                            msg.append(classNameId);
638    
639                            msg.append(StringPool.CLOSE_CURLY_BRACE);
640    
641                            throw new NoSuchTableException(msg.toString());
642                    }
643                    else {
644                            return list.get(0);
645                    }
646            }
647    
648            /**
649             * Finds the expando tables before and after the current expando table in the ordered set where companyId = &#63; and classNameId = &#63;.
650             *
651             * <p>
652             * 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.
653             * </p>
654             *
655             * @param tableId the primary key of the current expando table
656             * @param companyId the company id to search with
657             * @param classNameId the class name id to search with
658             * @param orderByComparator the comparator to order the set by
659             * @return the previous, current, and next expando table
660             * @throws com.liferay.portlet.expando.NoSuchTableException if a expando table with the primary key could not be found
661             * @throws SystemException if a system exception occurred
662             */
663            public ExpandoTable[] findByC_C_PrevAndNext(long tableId, long companyId,
664                    long classNameId, OrderByComparator orderByComparator)
665                    throws NoSuchTableException, SystemException {
666                    ExpandoTable expandoTable = findByPrimaryKey(tableId);
667    
668                    Session session = null;
669    
670                    try {
671                            session = openSession();
672    
673                            ExpandoTable[] array = new ExpandoTableImpl[3];
674    
675                            array[0] = getByC_C_PrevAndNext(session, expandoTable, companyId,
676                                            classNameId, orderByComparator, true);
677    
678                            array[1] = expandoTable;
679    
680                            array[2] = getByC_C_PrevAndNext(session, expandoTable, companyId,
681                                            classNameId, orderByComparator, false);
682    
683                            return array;
684                    }
685                    catch (Exception e) {
686                            throw processException(e);
687                    }
688                    finally {
689                            closeSession(session);
690                    }
691            }
692    
693            protected ExpandoTable getByC_C_PrevAndNext(Session session,
694                    ExpandoTable expandoTable, long companyId, long classNameId,
695                    OrderByComparator orderByComparator, boolean previous) {
696                    StringBundler query = null;
697    
698                    if (orderByComparator != null) {
699                            query = new StringBundler(6 +
700                                            (orderByComparator.getOrderByFields().length * 6));
701                    }
702                    else {
703                            query = new StringBundler(3);
704                    }
705    
706                    query.append(_SQL_SELECT_EXPANDOTABLE_WHERE);
707    
708                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
709    
710                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
711    
712                    if (orderByComparator != null) {
713                            String[] orderByFields = orderByComparator.getOrderByFields();
714    
715                            if (orderByFields.length > 0) {
716                                    query.append(WHERE_AND);
717                            }
718    
719                            for (int i = 0; i < orderByFields.length; i++) {
720                                    query.append(_ORDER_BY_ENTITY_ALIAS);
721                                    query.append(orderByFields[i]);
722    
723                                    if ((i + 1) < orderByFields.length) {
724                                            if (orderByComparator.isAscending() ^ previous) {
725                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
726                                            }
727                                            else {
728                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
729                                            }
730                                    }
731                                    else {
732                                            if (orderByComparator.isAscending() ^ previous) {
733                                                    query.append(WHERE_GREATER_THAN);
734                                            }
735                                            else {
736                                                    query.append(WHERE_LESSER_THAN);
737                                            }
738                                    }
739                            }
740    
741                            query.append(ORDER_BY_CLAUSE);
742    
743                            for (int i = 0; i < orderByFields.length; i++) {
744                                    query.append(_ORDER_BY_ENTITY_ALIAS);
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    
766                    String sql = query.toString();
767    
768                    Query q = session.createQuery(sql);
769    
770                    q.setFirstResult(0);
771                    q.setMaxResults(2);
772    
773                    QueryPos qPos = QueryPos.getInstance(q);
774    
775                    qPos.add(companyId);
776    
777                    qPos.add(classNameId);
778    
779                    if (orderByComparator != null) {
780                            Object[] values = orderByComparator.getOrderByValues(expandoTable);
781    
782                            for (Object value : values) {
783                                    qPos.add(value);
784                            }
785                    }
786    
787                    List<ExpandoTable> list = q.list();
788    
789                    if (list.size() == 2) {
790                            return list.get(1);
791                    }
792                    else {
793                            return null;
794                    }
795            }
796    
797            /**
798             * Finds the expando table where companyId = &#63; and classNameId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.expando.NoSuchTableException} if it could not be found.
799             *
800             * @param companyId the company id to search with
801             * @param classNameId the class name id to search with
802             * @param name the name to search with
803             * @return the matching expando table
804             * @throws com.liferay.portlet.expando.NoSuchTableException if a matching expando table could not be found
805             * @throws SystemException if a system exception occurred
806             */
807            public ExpandoTable findByC_C_N(long companyId, long classNameId,
808                    String name) throws NoSuchTableException, SystemException {
809                    ExpandoTable expandoTable = fetchByC_C_N(companyId, classNameId, name);
810    
811                    if (expandoTable == null) {
812                            StringBundler msg = new StringBundler(8);
813    
814                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
815    
816                            msg.append("companyId=");
817                            msg.append(companyId);
818    
819                            msg.append(", classNameId=");
820                            msg.append(classNameId);
821    
822                            msg.append(", name=");
823                            msg.append(name);
824    
825                            msg.append(StringPool.CLOSE_CURLY_BRACE);
826    
827                            if (_log.isWarnEnabled()) {
828                                    _log.warn(msg.toString());
829                            }
830    
831                            throw new NoSuchTableException(msg.toString());
832                    }
833    
834                    return expandoTable;
835            }
836    
837            /**
838             * Finds the expando table where companyId = &#63; and classNameId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
839             *
840             * @param companyId the company id to search with
841             * @param classNameId the class name id to search with
842             * @param name the name to search with
843             * @return the matching expando table, or <code>null</code> if a matching expando table could not be found
844             * @throws SystemException if a system exception occurred
845             */
846            public ExpandoTable fetchByC_C_N(long companyId, long classNameId,
847                    String name) throws SystemException {
848                    return fetchByC_C_N(companyId, classNameId, name, true);
849            }
850    
851            /**
852             * Finds the expando table where companyId = &#63; and classNameId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
853             *
854             * @param companyId the company id to search with
855             * @param classNameId the class name id to search with
856             * @param name the name to search with
857             * @return the matching expando table, or <code>null</code> if a matching expando table could not be found
858             * @throws SystemException if a system exception occurred
859             */
860            public ExpandoTable fetchByC_C_N(long companyId, long classNameId,
861                    String name, boolean retrieveFromCache) throws SystemException {
862                    Object[] finderArgs = new Object[] { companyId, classNameId, name };
863    
864                    Object result = null;
865    
866                    if (retrieveFromCache) {
867                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_N,
868                                            finderArgs, this);
869                    }
870    
871                    if (result == null) {
872                            Session session = null;
873    
874                            try {
875                                    session = openSession();
876    
877                                    StringBundler query = new StringBundler(4);
878    
879                                    query.append(_SQL_SELECT_EXPANDOTABLE_WHERE);
880    
881                                    query.append(_FINDER_COLUMN_C_C_N_COMPANYID_2);
882    
883                                    query.append(_FINDER_COLUMN_C_C_N_CLASSNAMEID_2);
884    
885                                    if (name == null) {
886                                            query.append(_FINDER_COLUMN_C_C_N_NAME_1);
887                                    }
888                                    else {
889                                            if (name.equals(StringPool.BLANK)) {
890                                                    query.append(_FINDER_COLUMN_C_C_N_NAME_3);
891                                            }
892                                            else {
893                                                    query.append(_FINDER_COLUMN_C_C_N_NAME_2);
894                                            }
895                                    }
896    
897                                    String sql = query.toString();
898    
899                                    Query q = session.createQuery(sql);
900    
901                                    QueryPos qPos = QueryPos.getInstance(q);
902    
903                                    qPos.add(companyId);
904    
905                                    qPos.add(classNameId);
906    
907                                    if (name != null) {
908                                            qPos.add(name);
909                                    }
910    
911                                    List<ExpandoTable> list = q.list();
912    
913                                    result = list;
914    
915                                    ExpandoTable expandoTable = null;
916    
917                                    if (list.isEmpty()) {
918                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_N,
919                                                    finderArgs, list);
920                                    }
921                                    else {
922                                            expandoTable = list.get(0);
923    
924                                            cacheResult(expandoTable);
925    
926                                            if ((expandoTable.getCompanyId() != companyId) ||
927                                                            (expandoTable.getClassNameId() != classNameId) ||
928                                                            (expandoTable.getName() == null) ||
929                                                            !expandoTable.getName().equals(name)) {
930                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_N,
931                                                            finderArgs, expandoTable);
932                                            }
933                                    }
934    
935                                    return expandoTable;
936                            }
937                            catch (Exception e) {
938                                    throw processException(e);
939                            }
940                            finally {
941                                    if (result == null) {
942                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_N,
943                                                    finderArgs, new ArrayList<ExpandoTable>());
944                                    }
945    
946                                    closeSession(session);
947                            }
948                    }
949                    else {
950                            if (result instanceof List<?>) {
951                                    return null;
952                            }
953                            else {
954                                    return (ExpandoTable)result;
955                            }
956                    }
957            }
958    
959            /**
960             * Finds all the expando tables.
961             *
962             * @return the expando tables
963             * @throws SystemException if a system exception occurred
964             */
965            public List<ExpandoTable> findAll() throws SystemException {
966                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
967            }
968    
969            /**
970             * Finds a range of all the expando tables.
971             *
972             * <p>
973             * 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.
974             * </p>
975             *
976             * @param start the lower bound of the range of expando tables to return
977             * @param end the upper bound of the range of expando tables to return (not inclusive)
978             * @return the range of expando tables
979             * @throws SystemException if a system exception occurred
980             */
981            public List<ExpandoTable> findAll(int start, int end)
982                    throws SystemException {
983                    return findAll(start, end, null);
984            }
985    
986            /**
987             * Finds an ordered range of all the expando tables.
988             *
989             * <p>
990             * 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.
991             * </p>
992             *
993             * @param start the lower bound of the range of expando tables to return
994             * @param end the upper bound of the range of expando tables to return (not inclusive)
995             * @param orderByComparator the comparator to order the results by
996             * @return the ordered range of expando tables
997             * @throws SystemException if a system exception occurred
998             */
999            public List<ExpandoTable> findAll(int start, int end,
1000                    OrderByComparator orderByComparator) throws SystemException {
1001                    Object[] finderArgs = new Object[] {
1002                                    String.valueOf(start), String.valueOf(end),
1003                                    String.valueOf(orderByComparator)
1004                            };
1005    
1006                    List<ExpandoTable> list = (List<ExpandoTable>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1007                                    finderArgs, this);
1008    
1009                    if (list == null) {
1010                            Session session = null;
1011    
1012                            try {
1013                                    session = openSession();
1014    
1015                                    StringBundler query = null;
1016                                    String sql = null;
1017    
1018                                    if (orderByComparator != null) {
1019                                            query = new StringBundler(2 +
1020                                                            (orderByComparator.getOrderByFields().length * 3));
1021    
1022                                            query.append(_SQL_SELECT_EXPANDOTABLE);
1023    
1024                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1025                                                    orderByComparator);
1026    
1027                                            sql = query.toString();
1028                                    }
1029                                    else {
1030                                            sql = _SQL_SELECT_EXPANDOTABLE;
1031                                    }
1032    
1033                                    Query q = session.createQuery(sql);
1034    
1035                                    if (orderByComparator == null) {
1036                                            list = (List<ExpandoTable>)QueryUtil.list(q, getDialect(),
1037                                                            start, end, false);
1038    
1039                                            Collections.sort(list);
1040                                    }
1041                                    else {
1042                                            list = (List<ExpandoTable>)QueryUtil.list(q, getDialect(),
1043                                                            start, end);
1044                                    }
1045                            }
1046                            catch (Exception e) {
1047                                    throw processException(e);
1048                            }
1049                            finally {
1050                                    if (list == null) {
1051                                            list = new ArrayList<ExpandoTable>();
1052                                    }
1053    
1054                                    cacheResult(list);
1055    
1056                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1057    
1058                                    closeSession(session);
1059                            }
1060                    }
1061    
1062                    return list;
1063            }
1064    
1065            /**
1066             * Removes all the expando tables where companyId = &#63; and classNameId = &#63; from the database.
1067             *
1068             * @param companyId the company id to search with
1069             * @param classNameId the class name id to search with
1070             * @throws SystemException if a system exception occurred
1071             */
1072            public void removeByC_C(long companyId, long classNameId)
1073                    throws SystemException {
1074                    for (ExpandoTable expandoTable : findByC_C(companyId, classNameId)) {
1075                            remove(expandoTable);
1076                    }
1077            }
1078    
1079            /**
1080             * Removes the expando table where companyId = &#63; and classNameId = &#63; and name = &#63; from the database.
1081             *
1082             * @param companyId the company id to search with
1083             * @param classNameId the class name id to search with
1084             * @param name the name to search with
1085             * @throws SystemException if a system exception occurred
1086             */
1087            public void removeByC_C_N(long companyId, long classNameId, String name)
1088                    throws NoSuchTableException, SystemException {
1089                    ExpandoTable expandoTable = findByC_C_N(companyId, classNameId, name);
1090    
1091                    remove(expandoTable);
1092            }
1093    
1094            /**
1095             * Removes all the expando tables from the database.
1096             *
1097             * @throws SystemException if a system exception occurred
1098             */
1099            public void removeAll() throws SystemException {
1100                    for (ExpandoTable expandoTable : findAll()) {
1101                            remove(expandoTable);
1102                    }
1103            }
1104    
1105            /**
1106             * Counts all the expando tables where companyId = &#63; and classNameId = &#63;.
1107             *
1108             * @param companyId the company id to search with
1109             * @param classNameId the class name id to search with
1110             * @return the number of matching expando tables
1111             * @throws SystemException if a system exception occurred
1112             */
1113            public int countByC_C(long companyId, long classNameId)
1114                    throws SystemException {
1115                    Object[] finderArgs = new Object[] { companyId, classNameId };
1116    
1117                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1118                                    finderArgs, this);
1119    
1120                    if (count == null) {
1121                            Session session = null;
1122    
1123                            try {
1124                                    session = openSession();
1125    
1126                                    StringBundler query = new StringBundler(3);
1127    
1128                                    query.append(_SQL_COUNT_EXPANDOTABLE_WHERE);
1129    
1130                                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1131    
1132                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1133    
1134                                    String sql = query.toString();
1135    
1136                                    Query q = session.createQuery(sql);
1137    
1138                                    QueryPos qPos = QueryPos.getInstance(q);
1139    
1140                                    qPos.add(companyId);
1141    
1142                                    qPos.add(classNameId);
1143    
1144                                    count = (Long)q.uniqueResult();
1145                            }
1146                            catch (Exception e) {
1147                                    throw processException(e);
1148                            }
1149                            finally {
1150                                    if (count == null) {
1151                                            count = Long.valueOf(0);
1152                                    }
1153    
1154                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1155                                            count);
1156    
1157                                    closeSession(session);
1158                            }
1159                    }
1160    
1161                    return count.intValue();
1162            }
1163    
1164            /**
1165             * Counts all the expando tables where companyId = &#63; and classNameId = &#63; and name = &#63;.
1166             *
1167             * @param companyId the company id to search with
1168             * @param classNameId the class name id to search with
1169             * @param name the name to search with
1170             * @return the number of matching expando tables
1171             * @throws SystemException if a system exception occurred
1172             */
1173            public int countByC_C_N(long companyId, long classNameId, String name)
1174                    throws SystemException {
1175                    Object[] finderArgs = new Object[] { companyId, classNameId, name };
1176    
1177                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_N,
1178                                    finderArgs, this);
1179    
1180                    if (count == null) {
1181                            Session session = null;
1182    
1183                            try {
1184                                    session = openSession();
1185    
1186                                    StringBundler query = new StringBundler(4);
1187    
1188                                    query.append(_SQL_COUNT_EXPANDOTABLE_WHERE);
1189    
1190                                    query.append(_FINDER_COLUMN_C_C_N_COMPANYID_2);
1191    
1192                                    query.append(_FINDER_COLUMN_C_C_N_CLASSNAMEID_2);
1193    
1194                                    if (name == null) {
1195                                            query.append(_FINDER_COLUMN_C_C_N_NAME_1);
1196                                    }
1197                                    else {
1198                                            if (name.equals(StringPool.BLANK)) {
1199                                                    query.append(_FINDER_COLUMN_C_C_N_NAME_3);
1200                                            }
1201                                            else {
1202                                                    query.append(_FINDER_COLUMN_C_C_N_NAME_2);
1203                                            }
1204                                    }
1205    
1206                                    String sql = query.toString();
1207    
1208                                    Query q = session.createQuery(sql);
1209    
1210                                    QueryPos qPos = QueryPos.getInstance(q);
1211    
1212                                    qPos.add(companyId);
1213    
1214                                    qPos.add(classNameId);
1215    
1216                                    if (name != null) {
1217                                            qPos.add(name);
1218                                    }
1219    
1220                                    count = (Long)q.uniqueResult();
1221                            }
1222                            catch (Exception e) {
1223                                    throw processException(e);
1224                            }
1225                            finally {
1226                                    if (count == null) {
1227                                            count = Long.valueOf(0);
1228                                    }
1229    
1230                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_N,
1231                                            finderArgs, count);
1232    
1233                                    closeSession(session);
1234                            }
1235                    }
1236    
1237                    return count.intValue();
1238            }
1239    
1240            /**
1241             * Counts all the expando tables.
1242             *
1243             * @return the number of expando tables
1244             * @throws SystemException if a system exception occurred
1245             */
1246            public int countAll() throws SystemException {
1247                    Object[] finderArgs = new Object[0];
1248    
1249                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1250                                    finderArgs, this);
1251    
1252                    if (count == null) {
1253                            Session session = null;
1254    
1255                            try {
1256                                    session = openSession();
1257    
1258                                    Query q = session.createQuery(_SQL_COUNT_EXPANDOTABLE);
1259    
1260                                    count = (Long)q.uniqueResult();
1261                            }
1262                            catch (Exception e) {
1263                                    throw processException(e);
1264                            }
1265                            finally {
1266                                    if (count == null) {
1267                                            count = Long.valueOf(0);
1268                                    }
1269    
1270                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1271                                            count);
1272    
1273                                    closeSession(session);
1274                            }
1275                    }
1276    
1277                    return count.intValue();
1278            }
1279    
1280            /**
1281             * Initializes the expando table persistence.
1282             */
1283            public void afterPropertiesSet() {
1284                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1285                                            com.liferay.portal.util.PropsUtil.get(
1286                                                    "value.object.listener.com.liferay.portlet.expando.model.ExpandoTable")));
1287    
1288                    if (listenerClassNames.length > 0) {
1289                            try {
1290                                    List<ModelListener<ExpandoTable>> listenersList = new ArrayList<ModelListener<ExpandoTable>>();
1291    
1292                                    for (String listenerClassName : listenerClassNames) {
1293                                            listenersList.add((ModelListener<ExpandoTable>)InstanceFactory.newInstance(
1294                                                            listenerClassName));
1295                                    }
1296    
1297                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1298                            }
1299                            catch (Exception e) {
1300                                    _log.error(e);
1301                            }
1302                    }
1303            }
1304    
1305            public void destroy() {
1306                    EntityCacheUtil.removeCache(ExpandoTableImpl.class.getName());
1307                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1308                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1309            }
1310    
1311            @BeanReference(type = ExpandoColumnPersistence.class)
1312            protected ExpandoColumnPersistence expandoColumnPersistence;
1313            @BeanReference(type = ExpandoRowPersistence.class)
1314            protected ExpandoRowPersistence expandoRowPersistence;
1315            @BeanReference(type = ExpandoTablePersistence.class)
1316            protected ExpandoTablePersistence expandoTablePersistence;
1317            @BeanReference(type = ExpandoValuePersistence.class)
1318            protected ExpandoValuePersistence expandoValuePersistence;
1319            @BeanReference(type = ResourcePersistence.class)
1320            protected ResourcePersistence resourcePersistence;
1321            @BeanReference(type = UserPersistence.class)
1322            protected UserPersistence userPersistence;
1323            private static final String _SQL_SELECT_EXPANDOTABLE = "SELECT expandoTable FROM ExpandoTable expandoTable";
1324            private static final String _SQL_SELECT_EXPANDOTABLE_WHERE = "SELECT expandoTable FROM ExpandoTable expandoTable WHERE ";
1325            private static final String _SQL_COUNT_EXPANDOTABLE = "SELECT COUNT(expandoTable) FROM ExpandoTable expandoTable";
1326            private static final String _SQL_COUNT_EXPANDOTABLE_WHERE = "SELECT COUNT(expandoTable) FROM ExpandoTable expandoTable WHERE ";
1327            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "expandoTable.companyId = ? AND ";
1328            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "expandoTable.classNameId = ?";
1329            private static final String _FINDER_COLUMN_C_C_N_COMPANYID_2 = "expandoTable.companyId = ? AND ";
1330            private static final String _FINDER_COLUMN_C_C_N_CLASSNAMEID_2 = "expandoTable.classNameId = ? AND ";
1331            private static final String _FINDER_COLUMN_C_C_N_NAME_1 = "expandoTable.name IS NULL";
1332            private static final String _FINDER_COLUMN_C_C_N_NAME_2 = "expandoTable.name = ?";
1333            private static final String _FINDER_COLUMN_C_C_N_NAME_3 = "(expandoTable.name IS NULL OR expandoTable.name = ?)";
1334            private static final String _ORDER_BY_ENTITY_ALIAS = "expandoTable.";
1335            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ExpandoTable exists with the primary key ";
1336            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ExpandoTable exists with the key {";
1337            private static Log _log = LogFactoryUtil.getLog(ExpandoTablePersistenceImpl.class);
1338    }