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