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