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