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