001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.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.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException;
046    import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink;
047    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStorageLinkImpl;
048    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStorageLinkModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the d d m storage link service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see DDMStorageLinkPersistence
065     * @see DDMStorageLinkUtil
066     * @generated
067     */
068    public class DDMStorageLinkPersistenceImpl extends BasePersistenceImpl<DDMStorageLink>
069            implements DDMStorageLinkPersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link DDMStorageLinkUtil} to access the d d m storage link persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = DDMStorageLinkImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
081                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
082                            DDMStorageLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083                            "findByUuid",
084                            new String[] {
085                                    String.class.getName(),
086                                    
087                            "java.lang.Integer", "java.lang.Integer",
088                                    "com.liferay.portal.kernel.util.OrderByComparator"
089                            });
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
091                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
092                            DDMStorageLinkImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094                            new String[] { String.class.getName() },
095                            DDMStorageLinkModelImpl.UUID_COLUMN_BITMASK);
096            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
097                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099                            new String[] { String.class.getName() });
100            public static final FinderPath FINDER_PATH_FETCH_BY_CLASSPK = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
101                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
102                            DDMStorageLinkImpl.class, FINDER_CLASS_NAME_ENTITY,
103                            "fetchByClassPK", new String[] { Long.class.getName() },
104                            DDMStorageLinkModelImpl.CLASSPK_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_CLASSPK = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
106                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassPK",
108                            new String[] { Long.class.getName() });
109            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
110                    new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
111                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
112                            DDMStorageLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
113                            "findByStructureId",
114                            new String[] {
115                                    Long.class.getName(),
116                                    
117                            "java.lang.Integer", "java.lang.Integer",
118                                    "com.liferay.portal.kernel.util.OrderByComparator"
119                            });
120            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
121                    new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
122                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
123                            DDMStorageLinkImpl.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
125                            new String[] { Long.class.getName() },
126                            DDMStorageLinkModelImpl.STRUCTUREID_COLUMN_BITMASK);
127            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
128                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
130                            new String[] { Long.class.getName() });
131            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
132                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
133                            DDMStorageLinkImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
134                            "findAll", new String[0]);
135            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
136                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED,
137                            DDMStorageLinkImpl.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
139            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
140                            DDMStorageLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
142    
143            /**
144             * Caches the d d m storage link in the entity cache if it is enabled.
145             *
146             * @param ddmStorageLink the d d m storage link
147             */
148            public void cacheResult(DDMStorageLink ddmStorageLink) {
149                    EntityCacheUtil.putResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
150                            DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey(),
151                            ddmStorageLink);
152    
153                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
154                            new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) },
155                            ddmStorageLink);
156    
157                    ddmStorageLink.resetOriginalValues();
158            }
159    
160            /**
161             * Caches the d d m storage links in the entity cache if it is enabled.
162             *
163             * @param ddmStorageLinks the d d m storage links
164             */
165            public void cacheResult(List<DDMStorageLink> ddmStorageLinks) {
166                    for (DDMStorageLink ddmStorageLink : ddmStorageLinks) {
167                            if (EntityCacheUtil.getResult(
168                                                    DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
169                                                    DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey()) == null) {
170                                    cacheResult(ddmStorageLink);
171                            }
172                            else {
173                                    ddmStorageLink.resetOriginalValues();
174                            }
175                    }
176            }
177    
178            /**
179             * Clears the cache for all d d m storage links.
180             *
181             * <p>
182             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
183             * </p>
184             */
185            @Override
186            public void clearCache() {
187                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
188                            CacheRegistryUtil.clear(DDMStorageLinkImpl.class.getName());
189                    }
190    
191                    EntityCacheUtil.clearCache(DDMStorageLinkImpl.class.getName());
192    
193                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
194                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
195                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
196            }
197    
198            /**
199             * Clears the cache for the d d m storage link.
200             *
201             * <p>
202             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
203             * </p>
204             */
205            @Override
206            public void clearCache(DDMStorageLink ddmStorageLink) {
207                    EntityCacheUtil.removeResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
208                            DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey());
209    
210                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
211                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
212    
213                    clearUniqueFindersCache(ddmStorageLink);
214            }
215    
216            @Override
217            public void clearCache(List<DDMStorageLink> ddmStorageLinks) {
218                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
219                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
220    
221                    for (DDMStorageLink ddmStorageLink : ddmStorageLinks) {
222                            EntityCacheUtil.removeResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
223                                    DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey());
224    
225                            clearUniqueFindersCache(ddmStorageLink);
226                    }
227            }
228    
229            protected void clearUniqueFindersCache(DDMStorageLink ddmStorageLink) {
230                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK,
231                            new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) });
232            }
233    
234            /**
235             * Creates a new d d m storage link with the primary key. Does not add the d d m storage link to the database.
236             *
237             * @param storageLinkId the primary key for the new d d m storage link
238             * @return the new d d m storage link
239             */
240            public DDMStorageLink create(long storageLinkId) {
241                    DDMStorageLink ddmStorageLink = new DDMStorageLinkImpl();
242    
243                    ddmStorageLink.setNew(true);
244                    ddmStorageLink.setPrimaryKey(storageLinkId);
245    
246                    String uuid = PortalUUIDUtil.generate();
247    
248                    ddmStorageLink.setUuid(uuid);
249    
250                    return ddmStorageLink;
251            }
252    
253            /**
254             * Removes the d d m storage link with the primary key from the database. Also notifies the appropriate model listeners.
255             *
256             * @param storageLinkId the primary key of the d d m storage link
257             * @return the d d m storage link that was removed
258             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
259             * @throws SystemException if a system exception occurred
260             */
261            public DDMStorageLink remove(long storageLinkId)
262                    throws NoSuchStorageLinkException, SystemException {
263                    return remove(Long.valueOf(storageLinkId));
264            }
265    
266            /**
267             * Removes the d d m storage link with the primary key from the database. Also notifies the appropriate model listeners.
268             *
269             * @param primaryKey the primary key of the d d m storage link
270             * @return the d d m storage link that was removed
271             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
272             * @throws SystemException if a system exception occurred
273             */
274            @Override
275            public DDMStorageLink remove(Serializable primaryKey)
276                    throws NoSuchStorageLinkException, SystemException {
277                    Session session = null;
278    
279                    try {
280                            session = openSession();
281    
282                            DDMStorageLink ddmStorageLink = (DDMStorageLink)session.get(DDMStorageLinkImpl.class,
283                                            primaryKey);
284    
285                            if (ddmStorageLink == null) {
286                                    if (_log.isWarnEnabled()) {
287                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
288                                    }
289    
290                                    throw new NoSuchStorageLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
291                                            primaryKey);
292                            }
293    
294                            return remove(ddmStorageLink);
295                    }
296                    catch (NoSuchStorageLinkException nsee) {
297                            throw nsee;
298                    }
299                    catch (Exception e) {
300                            throw processException(e);
301                    }
302                    finally {
303                            closeSession(session);
304                    }
305            }
306    
307            @Override
308            protected DDMStorageLink removeImpl(DDMStorageLink ddmStorageLink)
309                    throws SystemException {
310                    ddmStorageLink = toUnwrappedModel(ddmStorageLink);
311    
312                    Session session = null;
313    
314                    try {
315                            session = openSession();
316    
317                            BatchSessionUtil.delete(session, ddmStorageLink);
318                    }
319                    catch (Exception e) {
320                            throw processException(e);
321                    }
322                    finally {
323                            closeSession(session);
324                    }
325    
326                    clearCache(ddmStorageLink);
327    
328                    return ddmStorageLink;
329            }
330    
331            @Override
332            public DDMStorageLink updateImpl(
333                    com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink ddmStorageLink,
334                    boolean merge) throws SystemException {
335                    ddmStorageLink = toUnwrappedModel(ddmStorageLink);
336    
337                    boolean isNew = ddmStorageLink.isNew();
338    
339                    DDMStorageLinkModelImpl ddmStorageLinkModelImpl = (DDMStorageLinkModelImpl)ddmStorageLink;
340    
341                    if (Validator.isNull(ddmStorageLink.getUuid())) {
342                            String uuid = PortalUUIDUtil.generate();
343    
344                            ddmStorageLink.setUuid(uuid);
345                    }
346    
347                    Session session = null;
348    
349                    try {
350                            session = openSession();
351    
352                            BatchSessionUtil.update(session, ddmStorageLink, merge);
353    
354                            ddmStorageLink.setNew(false);
355                    }
356                    catch (Exception e) {
357                            throw processException(e);
358                    }
359                    finally {
360                            closeSession(session);
361                    }
362    
363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
364    
365                    if (isNew || !DDMStorageLinkModelImpl.COLUMN_BITMASK_ENABLED) {
366                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
367                    }
368                    else {
369                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
370                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
371                                    Object[] args = new Object[] {
372                                                    ddmStorageLinkModelImpl.getOriginalUuid()
373                                            };
374    
375                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
376                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
377                                            args);
378    
379                                    args = new Object[] { ddmStorageLinkModelImpl.getUuid() };
380    
381                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
382                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
383                                            args);
384                            }
385    
386                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
387                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
388                                    Object[] args = new Object[] {
389                                                    Long.valueOf(ddmStorageLinkModelImpl.getOriginalStructureId())
390                                            };
391    
392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
393                                            args);
394                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
395                                            args);
396    
397                                    args = new Object[] {
398                                                    Long.valueOf(ddmStorageLinkModelImpl.getStructureId())
399                                            };
400    
401                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
402                                            args);
403                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
404                                            args);
405                            }
406                    }
407    
408                    EntityCacheUtil.putResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
409                            DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey(),
410                            ddmStorageLink);
411    
412                    if (isNew) {
413                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
414                                    new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) },
415                                    ddmStorageLink);
416                    }
417                    else {
418                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
419                                            FINDER_PATH_FETCH_BY_CLASSPK.getColumnBitmask()) != 0) {
420                                    Object[] args = new Object[] {
421                                                    Long.valueOf(ddmStorageLinkModelImpl.getOriginalClassPK())
422                                            };
423    
424                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSPK, args);
425                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK, args);
426    
427                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
428                                            new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) },
429                                            ddmStorageLink);
430                            }
431                    }
432    
433                    return ddmStorageLink;
434            }
435    
436            protected DDMStorageLink toUnwrappedModel(DDMStorageLink ddmStorageLink) {
437                    if (ddmStorageLink instanceof DDMStorageLinkImpl) {
438                            return ddmStorageLink;
439                    }
440    
441                    DDMStorageLinkImpl ddmStorageLinkImpl = new DDMStorageLinkImpl();
442    
443                    ddmStorageLinkImpl.setNew(ddmStorageLink.isNew());
444                    ddmStorageLinkImpl.setPrimaryKey(ddmStorageLink.getPrimaryKey());
445    
446                    ddmStorageLinkImpl.setUuid(ddmStorageLink.getUuid());
447                    ddmStorageLinkImpl.setStorageLinkId(ddmStorageLink.getStorageLinkId());
448                    ddmStorageLinkImpl.setClassNameId(ddmStorageLink.getClassNameId());
449                    ddmStorageLinkImpl.setClassPK(ddmStorageLink.getClassPK());
450                    ddmStorageLinkImpl.setStructureId(ddmStorageLink.getStructureId());
451    
452                    return ddmStorageLinkImpl;
453            }
454    
455            /**
456             * Returns the d d m storage link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
457             *
458             * @param primaryKey the primary key of the d d m storage link
459             * @return the d d m storage link
460             * @throws com.liferay.portal.NoSuchModelException if a d d m storage link with the primary key could not be found
461             * @throws SystemException if a system exception occurred
462             */
463            @Override
464            public DDMStorageLink findByPrimaryKey(Serializable primaryKey)
465                    throws NoSuchModelException, SystemException {
466                    return findByPrimaryKey(((Long)primaryKey).longValue());
467            }
468    
469            /**
470             * Returns the d d m storage link with the primary key or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException} if it could not be found.
471             *
472             * @param storageLinkId the primary key of the d d m storage link
473             * @return the d d m storage link
474             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
475             * @throws SystemException if a system exception occurred
476             */
477            public DDMStorageLink findByPrimaryKey(long storageLinkId)
478                    throws NoSuchStorageLinkException, SystemException {
479                    DDMStorageLink ddmStorageLink = fetchByPrimaryKey(storageLinkId);
480    
481                    if (ddmStorageLink == null) {
482                            if (_log.isWarnEnabled()) {
483                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + storageLinkId);
484                            }
485    
486                            throw new NoSuchStorageLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
487                                    storageLinkId);
488                    }
489    
490                    return ddmStorageLink;
491            }
492    
493            /**
494             * Returns the d d m storage link with the primary key or returns <code>null</code> if it could not be found.
495             *
496             * @param primaryKey the primary key of the d d m storage link
497             * @return the d d m storage link, or <code>null</code> if a d d m storage link with the primary key could not be found
498             * @throws SystemException if a system exception occurred
499             */
500            @Override
501            public DDMStorageLink fetchByPrimaryKey(Serializable primaryKey)
502                    throws SystemException {
503                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
504            }
505    
506            /**
507             * Returns the d d m storage link with the primary key or returns <code>null</code> if it could not be found.
508             *
509             * @param storageLinkId the primary key of the d d m storage link
510             * @return the d d m storage link, or <code>null</code> if a d d m storage link with the primary key could not be found
511             * @throws SystemException if a system exception occurred
512             */
513            public DDMStorageLink fetchByPrimaryKey(long storageLinkId)
514                    throws SystemException {
515                    DDMStorageLink ddmStorageLink = (DDMStorageLink)EntityCacheUtil.getResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
516                                    DDMStorageLinkImpl.class, storageLinkId);
517    
518                    if (ddmStorageLink == _nullDDMStorageLink) {
519                            return null;
520                    }
521    
522                    if (ddmStorageLink == null) {
523                            Session session = null;
524    
525                            boolean hasException = false;
526    
527                            try {
528                                    session = openSession();
529    
530                                    ddmStorageLink = (DDMStorageLink)session.get(DDMStorageLinkImpl.class,
531                                                    Long.valueOf(storageLinkId));
532                            }
533                            catch (Exception e) {
534                                    hasException = true;
535    
536                                    throw processException(e);
537                            }
538                            finally {
539                                    if (ddmStorageLink != null) {
540                                            cacheResult(ddmStorageLink);
541                                    }
542                                    else if (!hasException) {
543                                            EntityCacheUtil.putResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
544                                                    DDMStorageLinkImpl.class, storageLinkId,
545                                                    _nullDDMStorageLink);
546                                    }
547    
548                                    closeSession(session);
549                            }
550                    }
551    
552                    return ddmStorageLink;
553            }
554    
555            /**
556             * Returns all the d d m storage links where uuid = &#63;.
557             *
558             * @param uuid the uuid
559             * @return the matching d d m storage links
560             * @throws SystemException if a system exception occurred
561             */
562            public List<DDMStorageLink> findByUuid(String uuid)
563                    throws SystemException {
564                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
565            }
566    
567            /**
568             * Returns a range of all the d d m storage links where uuid = &#63;.
569             *
570             * <p>
571             * 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.
572             * </p>
573             *
574             * @param uuid the uuid
575             * @param start the lower bound of the range of d d m storage links
576             * @param end the upper bound of the range of d d m storage links (not inclusive)
577             * @return the range of matching d d m storage links
578             * @throws SystemException if a system exception occurred
579             */
580            public List<DDMStorageLink> findByUuid(String uuid, int start, int end)
581                    throws SystemException {
582                    return findByUuid(uuid, start, end, null);
583            }
584    
585            /**
586             * Returns an ordered range of all the d d m storage links where uuid = &#63;.
587             *
588             * <p>
589             * 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.
590             * </p>
591             *
592             * @param uuid the uuid
593             * @param start the lower bound of the range of d d m storage links
594             * @param end the upper bound of the range of d d m storage links (not inclusive)
595             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
596             * @return the ordered range of matching d d m storage links
597             * @throws SystemException if a system exception occurred
598             */
599            public List<DDMStorageLink> findByUuid(String uuid, int start, int end,
600                    OrderByComparator orderByComparator) throws SystemException {
601                    FinderPath finderPath = null;
602                    Object[] finderArgs = null;
603    
604                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
605                                    (orderByComparator == null)) {
606                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
607                            finderArgs = new Object[] { uuid };
608                    }
609                    else {
610                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
611                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
612                    }
613    
614                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
615                                    finderArgs, this);
616    
617                    if ((list != null) && !list.isEmpty()) {
618                            for (DDMStorageLink ddmStorageLink : list) {
619                                    if (!Validator.equals(uuid, ddmStorageLink.getUuid())) {
620                                            list = null;
621    
622                                            break;
623                                    }
624                            }
625                    }
626    
627                    if (list == null) {
628                            StringBundler query = null;
629    
630                            if (orderByComparator != null) {
631                                    query = new StringBundler(3 +
632                                                    (orderByComparator.getOrderByFields().length * 3));
633                            }
634                            else {
635                                    query = new StringBundler(2);
636                            }
637    
638                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
639    
640                            if (uuid == null) {
641                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
642                            }
643                            else {
644                                    if (uuid.equals(StringPool.BLANK)) {
645                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
646                                    }
647                                    else {
648                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
649                                    }
650                            }
651    
652                            if (orderByComparator != null) {
653                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
654                                            orderByComparator);
655                            }
656    
657                            String sql = query.toString();
658    
659                            Session session = null;
660    
661                            try {
662                                    session = openSession();
663    
664                                    Query q = session.createQuery(sql);
665    
666                                    QueryPos qPos = QueryPos.getInstance(q);
667    
668                                    if (uuid != null) {
669                                            qPos.add(uuid);
670                                    }
671    
672                                    list = (List<DDMStorageLink>)QueryUtil.list(q, getDialect(),
673                                                    start, end);
674                            }
675                            catch (Exception e) {
676                                    throw processException(e);
677                            }
678                            finally {
679                                    if (list == null) {
680                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
681                                    }
682                                    else {
683                                            cacheResult(list);
684    
685                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
686                                    }
687    
688                                    closeSession(session);
689                            }
690                    }
691    
692                    return list;
693            }
694    
695            /**
696             * Returns the first d d m storage link in the ordered set where uuid = &#63;.
697             *
698             * <p>
699             * 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.
700             * </p>
701             *
702             * @param uuid the uuid
703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
704             * @return the first matching d d m storage link
705             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
706             * @throws SystemException if a system exception occurred
707             */
708            public DDMStorageLink findByUuid_First(String uuid,
709                    OrderByComparator orderByComparator)
710                    throws NoSuchStorageLinkException, SystemException {
711                    List<DDMStorageLink> list = findByUuid(uuid, 0, 1, orderByComparator);
712    
713                    if (list.isEmpty()) {
714                            StringBundler msg = new StringBundler(4);
715    
716                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
717    
718                            msg.append("uuid=");
719                            msg.append(uuid);
720    
721                            msg.append(StringPool.CLOSE_CURLY_BRACE);
722    
723                            throw new NoSuchStorageLinkException(msg.toString());
724                    }
725                    else {
726                            return list.get(0);
727                    }
728            }
729    
730            /**
731             * Returns the last d d m storage link in the ordered set where uuid = &#63;.
732             *
733             * <p>
734             * 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.
735             * </p>
736             *
737             * @param uuid the uuid
738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
739             * @return the last matching d d m storage link
740             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
741             * @throws SystemException if a system exception occurred
742             */
743            public DDMStorageLink findByUuid_Last(String uuid,
744                    OrderByComparator orderByComparator)
745                    throws NoSuchStorageLinkException, SystemException {
746                    int count = countByUuid(uuid);
747    
748                    List<DDMStorageLink> list = findByUuid(uuid, count - 1, count,
749                                    orderByComparator);
750    
751                    if (list.isEmpty()) {
752                            StringBundler msg = new StringBundler(4);
753    
754                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
755    
756                            msg.append("uuid=");
757                            msg.append(uuid);
758    
759                            msg.append(StringPool.CLOSE_CURLY_BRACE);
760    
761                            throw new NoSuchStorageLinkException(msg.toString());
762                    }
763                    else {
764                            return list.get(0);
765                    }
766            }
767    
768            /**
769             * Returns the d d m storage links before and after the current d d m storage link in the ordered set where uuid = &#63;.
770             *
771             * <p>
772             * 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.
773             * </p>
774             *
775             * @param storageLinkId the primary key of the current d d m storage link
776             * @param uuid the uuid
777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
778             * @return the previous, current, and next d d m storage link
779             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
780             * @throws SystemException if a system exception occurred
781             */
782            public DDMStorageLink[] findByUuid_PrevAndNext(long storageLinkId,
783                    String uuid, OrderByComparator orderByComparator)
784                    throws NoSuchStorageLinkException, SystemException {
785                    DDMStorageLink ddmStorageLink = findByPrimaryKey(storageLinkId);
786    
787                    Session session = null;
788    
789                    try {
790                            session = openSession();
791    
792                            DDMStorageLink[] array = new DDMStorageLinkImpl[3];
793    
794                            array[0] = getByUuid_PrevAndNext(session, ddmStorageLink, uuid,
795                                            orderByComparator, true);
796    
797                            array[1] = ddmStorageLink;
798    
799                            array[2] = getByUuid_PrevAndNext(session, ddmStorageLink, uuid,
800                                            orderByComparator, false);
801    
802                            return array;
803                    }
804                    catch (Exception e) {
805                            throw processException(e);
806                    }
807                    finally {
808                            closeSession(session);
809                    }
810            }
811    
812            protected DDMStorageLink getByUuid_PrevAndNext(Session session,
813                    DDMStorageLink ddmStorageLink, String uuid,
814                    OrderByComparator orderByComparator, boolean previous) {
815                    StringBundler query = null;
816    
817                    if (orderByComparator != null) {
818                            query = new StringBundler(6 +
819                                            (orderByComparator.getOrderByFields().length * 6));
820                    }
821                    else {
822                            query = new StringBundler(3);
823                    }
824    
825                    query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
826    
827                    if (uuid == null) {
828                            query.append(_FINDER_COLUMN_UUID_UUID_1);
829                    }
830                    else {
831                            if (uuid.equals(StringPool.BLANK)) {
832                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
833                            }
834                            else {
835                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
836                            }
837                    }
838    
839                    if (orderByComparator != null) {
840                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
841    
842                            if (orderByConditionFields.length > 0) {
843                                    query.append(WHERE_AND);
844                            }
845    
846                            for (int i = 0; i < orderByConditionFields.length; i++) {
847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
848                                    query.append(orderByConditionFields[i]);
849    
850                                    if ((i + 1) < orderByConditionFields.length) {
851                                            if (orderByComparator.isAscending() ^ previous) {
852                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
853                                            }
854                                            else {
855                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
856                                            }
857                                    }
858                                    else {
859                                            if (orderByComparator.isAscending() ^ previous) {
860                                                    query.append(WHERE_GREATER_THAN);
861                                            }
862                                            else {
863                                                    query.append(WHERE_LESSER_THAN);
864                                            }
865                                    }
866                            }
867    
868                            query.append(ORDER_BY_CLAUSE);
869    
870                            String[] orderByFields = orderByComparator.getOrderByFields();
871    
872                            for (int i = 0; i < orderByFields.length; i++) {
873                                    query.append(_ORDER_BY_ENTITY_ALIAS);
874                                    query.append(orderByFields[i]);
875    
876                                    if ((i + 1) < orderByFields.length) {
877                                            if (orderByComparator.isAscending() ^ previous) {
878                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
879                                            }
880                                            else {
881                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
882                                            }
883                                    }
884                                    else {
885                                            if (orderByComparator.isAscending() ^ previous) {
886                                                    query.append(ORDER_BY_ASC);
887                                            }
888                                            else {
889                                                    query.append(ORDER_BY_DESC);
890                                            }
891                                    }
892                            }
893                    }
894    
895                    String sql = query.toString();
896    
897                    Query q = session.createQuery(sql);
898    
899                    q.setFirstResult(0);
900                    q.setMaxResults(2);
901    
902                    QueryPos qPos = QueryPos.getInstance(q);
903    
904                    if (uuid != null) {
905                            qPos.add(uuid);
906                    }
907    
908                    if (orderByComparator != null) {
909                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStorageLink);
910    
911                            for (Object value : values) {
912                                    qPos.add(value);
913                            }
914                    }
915    
916                    List<DDMStorageLink> list = q.list();
917    
918                    if (list.size() == 2) {
919                            return list.get(1);
920                    }
921                    else {
922                            return null;
923                    }
924            }
925    
926            /**
927             * Returns the d d m storage link where classPK = &#63; or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException} if it could not be found.
928             *
929             * @param classPK the class p k
930             * @return the matching d d m storage link
931             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
932             * @throws SystemException if a system exception occurred
933             */
934            public DDMStorageLink findByClassPK(long classPK)
935                    throws NoSuchStorageLinkException, SystemException {
936                    DDMStorageLink ddmStorageLink = fetchByClassPK(classPK);
937    
938                    if (ddmStorageLink == null) {
939                            StringBundler msg = new StringBundler(4);
940    
941                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
942    
943                            msg.append("classPK=");
944                            msg.append(classPK);
945    
946                            msg.append(StringPool.CLOSE_CURLY_BRACE);
947    
948                            if (_log.isWarnEnabled()) {
949                                    _log.warn(msg.toString());
950                            }
951    
952                            throw new NoSuchStorageLinkException(msg.toString());
953                    }
954    
955                    return ddmStorageLink;
956            }
957    
958            /**
959             * Returns the d d m storage link where classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
960             *
961             * @param classPK the class p k
962             * @return the matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
963             * @throws SystemException if a system exception occurred
964             */
965            public DDMStorageLink fetchByClassPK(long classPK)
966                    throws SystemException {
967                    return fetchByClassPK(classPK, true);
968            }
969    
970            /**
971             * Returns the d d m storage link where classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
972             *
973             * @param classPK the class p k
974             * @param retrieveFromCache whether to use the finder cache
975             * @return the matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
976             * @throws SystemException if a system exception occurred
977             */
978            public DDMStorageLink fetchByClassPK(long classPK, boolean retrieveFromCache)
979                    throws SystemException {
980                    Object[] finderArgs = new Object[] { classPK };
981    
982                    Object result = null;
983    
984                    if (retrieveFromCache) {
985                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CLASSPK,
986                                            finderArgs, this);
987                    }
988    
989                    if (result instanceof DDMStorageLink) {
990                            DDMStorageLink ddmStorageLink = (DDMStorageLink)result;
991    
992                            if ((classPK != ddmStorageLink.getClassPK())) {
993                                    result = null;
994                            }
995                    }
996    
997                    if (result == null) {
998                            StringBundler query = new StringBundler(2);
999    
1000                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1001    
1002                            query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1003    
1004                            String sql = query.toString();
1005    
1006                            Session session = null;
1007    
1008                            try {
1009                                    session = openSession();
1010    
1011                                    Query q = session.createQuery(sql);
1012    
1013                                    QueryPos qPos = QueryPos.getInstance(q);
1014    
1015                                    qPos.add(classPK);
1016    
1017                                    List<DDMStorageLink> list = q.list();
1018    
1019                                    result = list;
1020    
1021                                    DDMStorageLink ddmStorageLink = null;
1022    
1023                                    if (list.isEmpty()) {
1024                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1025                                                    finderArgs, list);
1026                                    }
1027                                    else {
1028                                            ddmStorageLink = list.get(0);
1029    
1030                                            cacheResult(ddmStorageLink);
1031    
1032                                            if ((ddmStorageLink.getClassPK() != classPK)) {
1033                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1034                                                            finderArgs, ddmStorageLink);
1035                                            }
1036                                    }
1037    
1038                                    return ddmStorageLink;
1039                            }
1040                            catch (Exception e) {
1041                                    throw processException(e);
1042                            }
1043                            finally {
1044                                    if (result == null) {
1045                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK,
1046                                                    finderArgs);
1047                                    }
1048    
1049                                    closeSession(session);
1050                            }
1051                    }
1052                    else {
1053                            if (result instanceof List<?>) {
1054                                    return null;
1055                            }
1056                            else {
1057                                    return (DDMStorageLink)result;
1058                            }
1059                    }
1060            }
1061    
1062            /**
1063             * Returns all the d d m storage links where structureId = &#63;.
1064             *
1065             * @param structureId the structure ID
1066             * @return the matching d d m storage links
1067             * @throws SystemException if a system exception occurred
1068             */
1069            public List<DDMStorageLink> findByStructureId(long structureId)
1070                    throws SystemException {
1071                    return findByStructureId(structureId, QueryUtil.ALL_POS,
1072                            QueryUtil.ALL_POS, null);
1073            }
1074    
1075            /**
1076             * Returns a range of all the d d m storage links where structureId = &#63;.
1077             *
1078             * <p>
1079             * 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.
1080             * </p>
1081             *
1082             * @param structureId the structure ID
1083             * @param start the lower bound of the range of d d m storage links
1084             * @param end the upper bound of the range of d d m storage links (not inclusive)
1085             * @return the range of matching d d m storage links
1086             * @throws SystemException if a system exception occurred
1087             */
1088            public List<DDMStorageLink> findByStructureId(long structureId, int start,
1089                    int end) throws SystemException {
1090                    return findByStructureId(structureId, start, end, null);
1091            }
1092    
1093            /**
1094             * Returns an ordered range of all the d d m storage links where structureId = &#63;.
1095             *
1096             * <p>
1097             * 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.
1098             * </p>
1099             *
1100             * @param structureId the structure ID
1101             * @param start the lower bound of the range of d d m storage links
1102             * @param end the upper bound of the range of d d m storage links (not inclusive)
1103             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1104             * @return the ordered range of matching d d m storage links
1105             * @throws SystemException if a system exception occurred
1106             */
1107            public List<DDMStorageLink> findByStructureId(long structureId, int start,
1108                    int end, OrderByComparator orderByComparator) throws SystemException {
1109                    FinderPath finderPath = null;
1110                    Object[] finderArgs = null;
1111    
1112                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1113                                    (orderByComparator == null)) {
1114                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
1115                            finderArgs = new Object[] { structureId };
1116                    }
1117                    else {
1118                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
1119                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
1120                    }
1121    
1122                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
1123                                    finderArgs, this);
1124    
1125                    if ((list != null) && !list.isEmpty()) {
1126                            for (DDMStorageLink ddmStorageLink : list) {
1127                                    if ((structureId != ddmStorageLink.getStructureId())) {
1128                                            list = null;
1129    
1130                                            break;
1131                                    }
1132                            }
1133                    }
1134    
1135                    if (list == null) {
1136                            StringBundler query = null;
1137    
1138                            if (orderByComparator != null) {
1139                                    query = new StringBundler(3 +
1140                                                    (orderByComparator.getOrderByFields().length * 3));
1141                            }
1142                            else {
1143                                    query = new StringBundler(2);
1144                            }
1145    
1146                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1147    
1148                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1149    
1150                            if (orderByComparator != null) {
1151                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1152                                            orderByComparator);
1153                            }
1154    
1155                            String sql = query.toString();
1156    
1157                            Session session = null;
1158    
1159                            try {
1160                                    session = openSession();
1161    
1162                                    Query q = session.createQuery(sql);
1163    
1164                                    QueryPos qPos = QueryPos.getInstance(q);
1165    
1166                                    qPos.add(structureId);
1167    
1168                                    list = (List<DDMStorageLink>)QueryUtil.list(q, getDialect(),
1169                                                    start, end);
1170                            }
1171                            catch (Exception e) {
1172                                    throw processException(e);
1173                            }
1174                            finally {
1175                                    if (list == null) {
1176                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1177                                    }
1178                                    else {
1179                                            cacheResult(list);
1180    
1181                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1182                                    }
1183    
1184                                    closeSession(session);
1185                            }
1186                    }
1187    
1188                    return list;
1189            }
1190    
1191            /**
1192             * Returns the first d d m storage link in the ordered set where structureId = &#63;.
1193             *
1194             * <p>
1195             * 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.
1196             * </p>
1197             *
1198             * @param structureId the structure ID
1199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1200             * @return the first matching d d m storage link
1201             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
1202             * @throws SystemException if a system exception occurred
1203             */
1204            public DDMStorageLink findByStructureId_First(long structureId,
1205                    OrderByComparator orderByComparator)
1206                    throws NoSuchStorageLinkException, SystemException {
1207                    List<DDMStorageLink> list = findByStructureId(structureId, 0, 1,
1208                                    orderByComparator);
1209    
1210                    if (list.isEmpty()) {
1211                            StringBundler msg = new StringBundler(4);
1212    
1213                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1214    
1215                            msg.append("structureId=");
1216                            msg.append(structureId);
1217    
1218                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1219    
1220                            throw new NoSuchStorageLinkException(msg.toString());
1221                    }
1222                    else {
1223                            return list.get(0);
1224                    }
1225            }
1226    
1227            /**
1228             * Returns the last d d m storage link in the ordered set where structureId = &#63;.
1229             *
1230             * <p>
1231             * 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.
1232             * </p>
1233             *
1234             * @param structureId the structure ID
1235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1236             * @return the last matching d d m storage link
1237             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
1238             * @throws SystemException if a system exception occurred
1239             */
1240            public DDMStorageLink findByStructureId_Last(long structureId,
1241                    OrderByComparator orderByComparator)
1242                    throws NoSuchStorageLinkException, SystemException {
1243                    int count = countByStructureId(structureId);
1244    
1245                    List<DDMStorageLink> list = findByStructureId(structureId, count - 1,
1246                                    count, orderByComparator);
1247    
1248                    if (list.isEmpty()) {
1249                            StringBundler msg = new StringBundler(4);
1250    
1251                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252    
1253                            msg.append("structureId=");
1254                            msg.append(structureId);
1255    
1256                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1257    
1258                            throw new NoSuchStorageLinkException(msg.toString());
1259                    }
1260                    else {
1261                            return list.get(0);
1262                    }
1263            }
1264    
1265            /**
1266             * Returns the d d m storage links before and after the current d d m storage link in the ordered set where structureId = &#63;.
1267             *
1268             * <p>
1269             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1270             * </p>
1271             *
1272             * @param storageLinkId the primary key of the current d d m storage link
1273             * @param structureId the structure ID
1274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1275             * @return the previous, current, and next d d m storage link
1276             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
1277             * @throws SystemException if a system exception occurred
1278             */
1279            public DDMStorageLink[] findByStructureId_PrevAndNext(long storageLinkId,
1280                    long structureId, OrderByComparator orderByComparator)
1281                    throws NoSuchStorageLinkException, SystemException {
1282                    DDMStorageLink ddmStorageLink = findByPrimaryKey(storageLinkId);
1283    
1284                    Session session = null;
1285    
1286                    try {
1287                            session = openSession();
1288    
1289                            DDMStorageLink[] array = new DDMStorageLinkImpl[3];
1290    
1291                            array[0] = getByStructureId_PrevAndNext(session, ddmStorageLink,
1292                                            structureId, orderByComparator, true);
1293    
1294                            array[1] = ddmStorageLink;
1295    
1296                            array[2] = getByStructureId_PrevAndNext(session, ddmStorageLink,
1297                                            structureId, orderByComparator, false);
1298    
1299                            return array;
1300                    }
1301                    catch (Exception e) {
1302                            throw processException(e);
1303                    }
1304                    finally {
1305                            closeSession(session);
1306                    }
1307            }
1308    
1309            protected DDMStorageLink getByStructureId_PrevAndNext(Session session,
1310                    DDMStorageLink ddmStorageLink, long structureId,
1311                    OrderByComparator orderByComparator, boolean previous) {
1312                    StringBundler query = null;
1313    
1314                    if (orderByComparator != null) {
1315                            query = new StringBundler(6 +
1316                                            (orderByComparator.getOrderByFields().length * 6));
1317                    }
1318                    else {
1319                            query = new StringBundler(3);
1320                    }
1321    
1322                    query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1323    
1324                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1325    
1326                    if (orderByComparator != null) {
1327                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1328    
1329                            if (orderByConditionFields.length > 0) {
1330                                    query.append(WHERE_AND);
1331                            }
1332    
1333                            for (int i = 0; i < orderByConditionFields.length; i++) {
1334                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1335                                    query.append(orderByConditionFields[i]);
1336    
1337                                    if ((i + 1) < orderByConditionFields.length) {
1338                                            if (orderByComparator.isAscending() ^ previous) {
1339                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1340                                            }
1341                                            else {
1342                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1343                                            }
1344                                    }
1345                                    else {
1346                                            if (orderByComparator.isAscending() ^ previous) {
1347                                                    query.append(WHERE_GREATER_THAN);
1348                                            }
1349                                            else {
1350                                                    query.append(WHERE_LESSER_THAN);
1351                                            }
1352                                    }
1353                            }
1354    
1355                            query.append(ORDER_BY_CLAUSE);
1356    
1357                            String[] orderByFields = orderByComparator.getOrderByFields();
1358    
1359                            for (int i = 0; i < orderByFields.length; i++) {
1360                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1361                                    query.append(orderByFields[i]);
1362    
1363                                    if ((i + 1) < orderByFields.length) {
1364                                            if (orderByComparator.isAscending() ^ previous) {
1365                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1366                                            }
1367                                            else {
1368                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1369                                            }
1370                                    }
1371                                    else {
1372                                            if (orderByComparator.isAscending() ^ previous) {
1373                                                    query.append(ORDER_BY_ASC);
1374                                            }
1375                                            else {
1376                                                    query.append(ORDER_BY_DESC);
1377                                            }
1378                                    }
1379                            }
1380                    }
1381    
1382                    String sql = query.toString();
1383    
1384                    Query q = session.createQuery(sql);
1385    
1386                    q.setFirstResult(0);
1387                    q.setMaxResults(2);
1388    
1389                    QueryPos qPos = QueryPos.getInstance(q);
1390    
1391                    qPos.add(structureId);
1392    
1393                    if (orderByComparator != null) {
1394                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStorageLink);
1395    
1396                            for (Object value : values) {
1397                                    qPos.add(value);
1398                            }
1399                    }
1400    
1401                    List<DDMStorageLink> list = q.list();
1402    
1403                    if (list.size() == 2) {
1404                            return list.get(1);
1405                    }
1406                    else {
1407                            return null;
1408                    }
1409            }
1410    
1411            /**
1412             * Returns all the d d m storage links.
1413             *
1414             * @return the d d m storage links
1415             * @throws SystemException if a system exception occurred
1416             */
1417            public List<DDMStorageLink> findAll() throws SystemException {
1418                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1419            }
1420    
1421            /**
1422             * Returns a range of all the d d m storage links.
1423             *
1424             * <p>
1425             * 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.
1426             * </p>
1427             *
1428             * @param start the lower bound of the range of d d m storage links
1429             * @param end the upper bound of the range of d d m storage links (not inclusive)
1430             * @return the range of d d m storage links
1431             * @throws SystemException if a system exception occurred
1432             */
1433            public List<DDMStorageLink> findAll(int start, int end)
1434                    throws SystemException {
1435                    return findAll(start, end, null);
1436            }
1437    
1438            /**
1439             * Returns an ordered range of all the d d m storage links.
1440             *
1441             * <p>
1442             * 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.
1443             * </p>
1444             *
1445             * @param start the lower bound of the range of d d m storage links
1446             * @param end the upper bound of the range of d d m storage links (not inclusive)
1447             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1448             * @return the ordered range of d d m storage links
1449             * @throws SystemException if a system exception occurred
1450             */
1451            public List<DDMStorageLink> findAll(int start, int end,
1452                    OrderByComparator orderByComparator) throws SystemException {
1453                    FinderPath finderPath = null;
1454                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1455    
1456                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1457                                    (orderByComparator == null)) {
1458                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1459                            finderArgs = FINDER_ARGS_EMPTY;
1460                    }
1461                    else {
1462                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1463                            finderArgs = new Object[] { start, end, orderByComparator };
1464                    }
1465    
1466                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
1467                                    finderArgs, this);
1468    
1469                    if (list == null) {
1470                            StringBundler query = null;
1471                            String sql = null;
1472    
1473                            if (orderByComparator != null) {
1474                                    query = new StringBundler(2 +
1475                                                    (orderByComparator.getOrderByFields().length * 3));
1476    
1477                                    query.append(_SQL_SELECT_DDMSTORAGELINK);
1478    
1479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1480                                            orderByComparator);
1481    
1482                                    sql = query.toString();
1483                            }
1484                            else {
1485                                    sql = _SQL_SELECT_DDMSTORAGELINK;
1486                            }
1487    
1488                            Session session = null;
1489    
1490                            try {
1491                                    session = openSession();
1492    
1493                                    Query q = session.createQuery(sql);
1494    
1495                                    if (orderByComparator == null) {
1496                                            list = (List<DDMStorageLink>)QueryUtil.list(q,
1497                                                            getDialect(), start, end, false);
1498    
1499                                            Collections.sort(list);
1500                                    }
1501                                    else {
1502                                            list = (List<DDMStorageLink>)QueryUtil.list(q,
1503                                                            getDialect(), start, end);
1504                                    }
1505                            }
1506                            catch (Exception e) {
1507                                    throw processException(e);
1508                            }
1509                            finally {
1510                                    if (list == null) {
1511                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1512                                    }
1513                                    else {
1514                                            cacheResult(list);
1515    
1516                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1517                                    }
1518    
1519                                    closeSession(session);
1520                            }
1521                    }
1522    
1523                    return list;
1524            }
1525    
1526            /**
1527             * Removes all the d d m storage links where uuid = &#63; from the database.
1528             *
1529             * @param uuid the uuid
1530             * @throws SystemException if a system exception occurred
1531             */
1532            public void removeByUuid(String uuid) throws SystemException {
1533                    for (DDMStorageLink ddmStorageLink : findByUuid(uuid)) {
1534                            remove(ddmStorageLink);
1535                    }
1536            }
1537    
1538            /**
1539             * Removes the d d m storage link where classPK = &#63; from the database.
1540             *
1541             * @param classPK the class p k
1542             * @throws SystemException if a system exception occurred
1543             */
1544            public void removeByClassPK(long classPK)
1545                    throws NoSuchStorageLinkException, SystemException {
1546                    DDMStorageLink ddmStorageLink = findByClassPK(classPK);
1547    
1548                    remove(ddmStorageLink);
1549            }
1550    
1551            /**
1552             * Removes all the d d m storage links where structureId = &#63; from the database.
1553             *
1554             * @param structureId the structure ID
1555             * @throws SystemException if a system exception occurred
1556             */
1557            public void removeByStructureId(long structureId) throws SystemException {
1558                    for (DDMStorageLink ddmStorageLink : findByStructureId(structureId)) {
1559                            remove(ddmStorageLink);
1560                    }
1561            }
1562    
1563            /**
1564             * Removes all the d d m storage links from the database.
1565             *
1566             * @throws SystemException if a system exception occurred
1567             */
1568            public void removeAll() throws SystemException {
1569                    for (DDMStorageLink ddmStorageLink : findAll()) {
1570                            remove(ddmStorageLink);
1571                    }
1572            }
1573    
1574            /**
1575             * Returns the number of d d m storage links where uuid = &#63;.
1576             *
1577             * @param uuid the uuid
1578             * @return the number of matching d d m storage links
1579             * @throws SystemException if a system exception occurred
1580             */
1581            public int countByUuid(String uuid) throws SystemException {
1582                    Object[] finderArgs = new Object[] { uuid };
1583    
1584                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1585                                    finderArgs, this);
1586    
1587                    if (count == null) {
1588                            StringBundler query = new StringBundler(2);
1589    
1590                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1591    
1592                            if (uuid == null) {
1593                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1594                            }
1595                            else {
1596                                    if (uuid.equals(StringPool.BLANK)) {
1597                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1598                                    }
1599                                    else {
1600                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1601                                    }
1602                            }
1603    
1604                            String sql = query.toString();
1605    
1606                            Session session = null;
1607    
1608                            try {
1609                                    session = openSession();
1610    
1611                                    Query q = session.createQuery(sql);
1612    
1613                                    QueryPos qPos = QueryPos.getInstance(q);
1614    
1615                                    if (uuid != null) {
1616                                            qPos.add(uuid);
1617                                    }
1618    
1619                                    count = (Long)q.uniqueResult();
1620                            }
1621                            catch (Exception e) {
1622                                    throw processException(e);
1623                            }
1624                            finally {
1625                                    if (count == null) {
1626                                            count = Long.valueOf(0);
1627                                    }
1628    
1629                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1630                                            finderArgs, count);
1631    
1632                                    closeSession(session);
1633                            }
1634                    }
1635    
1636                    return count.intValue();
1637            }
1638    
1639            /**
1640             * Returns the number of d d m storage links where classPK = &#63;.
1641             *
1642             * @param classPK the class p k
1643             * @return the number of matching d d m storage links
1644             * @throws SystemException if a system exception occurred
1645             */
1646            public int countByClassPK(long classPK) throws SystemException {
1647                    Object[] finderArgs = new Object[] { classPK };
1648    
1649                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSPK,
1650                                    finderArgs, this);
1651    
1652                    if (count == null) {
1653                            StringBundler query = new StringBundler(2);
1654    
1655                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1656    
1657                            query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1658    
1659                            String sql = query.toString();
1660    
1661                            Session session = null;
1662    
1663                            try {
1664                                    session = openSession();
1665    
1666                                    Query q = session.createQuery(sql);
1667    
1668                                    QueryPos qPos = QueryPos.getInstance(q);
1669    
1670                                    qPos.add(classPK);
1671    
1672                                    count = (Long)q.uniqueResult();
1673                            }
1674                            catch (Exception e) {
1675                                    throw processException(e);
1676                            }
1677                            finally {
1678                                    if (count == null) {
1679                                            count = Long.valueOf(0);
1680                                    }
1681    
1682                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSPK,
1683                                            finderArgs, count);
1684    
1685                                    closeSession(session);
1686                            }
1687                    }
1688    
1689                    return count.intValue();
1690            }
1691    
1692            /**
1693             * Returns the number of d d m storage links where structureId = &#63;.
1694             *
1695             * @param structureId the structure ID
1696             * @return the number of matching d d m storage links
1697             * @throws SystemException if a system exception occurred
1698             */
1699            public int countByStructureId(long structureId) throws SystemException {
1700                    Object[] finderArgs = new Object[] { structureId };
1701    
1702                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1703                                    finderArgs, this);
1704    
1705                    if (count == null) {
1706                            StringBundler query = new StringBundler(2);
1707    
1708                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1709    
1710                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1711    
1712                            String sql = query.toString();
1713    
1714                            Session session = null;
1715    
1716                            try {
1717                                    session = openSession();
1718    
1719                                    Query q = session.createQuery(sql);
1720    
1721                                    QueryPos qPos = QueryPos.getInstance(q);
1722    
1723                                    qPos.add(structureId);
1724    
1725                                    count = (Long)q.uniqueResult();
1726                            }
1727                            catch (Exception e) {
1728                                    throw processException(e);
1729                            }
1730                            finally {
1731                                    if (count == null) {
1732                                            count = Long.valueOf(0);
1733                                    }
1734    
1735                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1736                                            finderArgs, count);
1737    
1738                                    closeSession(session);
1739                            }
1740                    }
1741    
1742                    return count.intValue();
1743            }
1744    
1745            /**
1746             * Returns the number of d d m storage links.
1747             *
1748             * @return the number of d d m storage links
1749             * @throws SystemException if a system exception occurred
1750             */
1751            public int countAll() throws SystemException {
1752                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1753                                    FINDER_ARGS_EMPTY, this);
1754    
1755                    if (count == null) {
1756                            Session session = null;
1757    
1758                            try {
1759                                    session = openSession();
1760    
1761                                    Query q = session.createQuery(_SQL_COUNT_DDMSTORAGELINK);
1762    
1763                                    count = (Long)q.uniqueResult();
1764                            }
1765                            catch (Exception e) {
1766                                    throw processException(e);
1767                            }
1768                            finally {
1769                                    if (count == null) {
1770                                            count = Long.valueOf(0);
1771                                    }
1772    
1773                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1774                                            FINDER_ARGS_EMPTY, count);
1775    
1776                                    closeSession(session);
1777                            }
1778                    }
1779    
1780                    return count.intValue();
1781            }
1782    
1783            /**
1784             * Initializes the d d m storage link persistence.
1785             */
1786            public void afterPropertiesSet() {
1787                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1788                                            com.liferay.portal.util.PropsUtil.get(
1789                                                    "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink")));
1790    
1791                    if (listenerClassNames.length > 0) {
1792                            try {
1793                                    List<ModelListener<DDMStorageLink>> listenersList = new ArrayList<ModelListener<DDMStorageLink>>();
1794    
1795                                    for (String listenerClassName : listenerClassNames) {
1796                                            listenersList.add((ModelListener<DDMStorageLink>)InstanceFactory.newInstance(
1797                                                            listenerClassName));
1798                                    }
1799    
1800                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1801                            }
1802                            catch (Exception e) {
1803                                    _log.error(e);
1804                            }
1805                    }
1806            }
1807    
1808            public void destroy() {
1809                    EntityCacheUtil.removeCache(DDMStorageLinkImpl.class.getName());
1810                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1811                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1812            }
1813    
1814            @BeanReference(type = DDMContentPersistence.class)
1815            protected DDMContentPersistence ddmContentPersistence;
1816            @BeanReference(type = DDMStorageLinkPersistence.class)
1817            protected DDMStorageLinkPersistence ddmStorageLinkPersistence;
1818            @BeanReference(type = DDMStructurePersistence.class)
1819            protected DDMStructurePersistence ddmStructurePersistence;
1820            @BeanReference(type = DDMStructureLinkPersistence.class)
1821            protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
1822            @BeanReference(type = DDMTemplatePersistence.class)
1823            protected DDMTemplatePersistence ddmTemplatePersistence;
1824            @BeanReference(type = ResourcePersistence.class)
1825            protected ResourcePersistence resourcePersistence;
1826            @BeanReference(type = UserPersistence.class)
1827            protected UserPersistence userPersistence;
1828            private static final String _SQL_SELECT_DDMSTORAGELINK = "SELECT ddmStorageLink FROM DDMStorageLink ddmStorageLink";
1829            private static final String _SQL_SELECT_DDMSTORAGELINK_WHERE = "SELECT ddmStorageLink FROM DDMStorageLink ddmStorageLink WHERE ";
1830            private static final String _SQL_COUNT_DDMSTORAGELINK = "SELECT COUNT(ddmStorageLink) FROM DDMStorageLink ddmStorageLink";
1831            private static final String _SQL_COUNT_DDMSTORAGELINK_WHERE = "SELECT COUNT(ddmStorageLink) FROM DDMStorageLink ddmStorageLink WHERE ";
1832            private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmStorageLink.uuid IS NULL";
1833            private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmStorageLink.uuid = ?";
1834            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmStorageLink.uuid IS NULL OR ddmStorageLink.uuid = ?)";
1835            private static final String _FINDER_COLUMN_CLASSPK_CLASSPK_2 = "ddmStorageLink.classPK = ?";
1836            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "ddmStorageLink.structureId = ?";
1837            private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStorageLink.";
1838            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStorageLink exists with the primary key ";
1839            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStorageLink exists with the key {";
1840            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1841            private static Log _log = LogFactoryUtil.getLog(DDMStorageLinkPersistenceImpl.class);
1842            private static DDMStorageLink _nullDDMStorageLink = new DDMStorageLinkImpl() {
1843                            @Override
1844                            public Object clone() {
1845                                    return this;
1846                            }
1847    
1848                            @Override
1849                            public CacheModel<DDMStorageLink> toCacheModel() {
1850                                    return _nullDDMStorageLinkCacheModel;
1851                            }
1852                    };
1853    
1854            private static CacheModel<DDMStorageLink> _nullDDMStorageLinkCacheModel = new CacheModel<DDMStorageLink>() {
1855                            public DDMStorageLink toEntityModel() {
1856                                    return _nullDDMStorageLink;
1857                            }
1858                    };
1859    }