001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.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    
369                    else {
370                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
371                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
372                                    Object[] args = new Object[] {
373                                                    ddmStorageLinkModelImpl.getOriginalUuid()
374                                            };
375    
376                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
377                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
378                                            args);
379    
380                                    args = new Object[] { ddmStorageLinkModelImpl.getUuid() };
381    
382                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
383                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
384                                            args);
385                            }
386    
387                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
388                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
389                                    Object[] args = new Object[] {
390                                                    Long.valueOf(ddmStorageLinkModelImpl.getOriginalStructureId())
391                                            };
392    
393                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
394                                            args);
395                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
396                                            args);
397    
398                                    args = new Object[] {
399                                                    Long.valueOf(ddmStorageLinkModelImpl.getStructureId())
400                                            };
401    
402                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
403                                            args);
404                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
405                                            args);
406                            }
407                    }
408    
409                    EntityCacheUtil.putResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
410                            DDMStorageLinkImpl.class, ddmStorageLink.getPrimaryKey(),
411                            ddmStorageLink);
412    
413                    if (isNew) {
414                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
415                                    new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) },
416                                    ddmStorageLink);
417                    }
418                    else {
419                            if ((ddmStorageLinkModelImpl.getColumnBitmask() &
420                                            FINDER_PATH_FETCH_BY_CLASSPK.getColumnBitmask()) != 0) {
421                                    Object[] args = new Object[] {
422                                                    Long.valueOf(ddmStorageLinkModelImpl.getOriginalClassPK())
423                                            };
424    
425                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSPK, args);
426    
427                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK, args);
428    
429                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
430                                            new Object[] { Long.valueOf(ddmStorageLink.getClassPK()) },
431                                            ddmStorageLink);
432                            }
433                    }
434    
435                    return ddmStorageLink;
436            }
437    
438            protected DDMStorageLink toUnwrappedModel(DDMStorageLink ddmStorageLink) {
439                    if (ddmStorageLink instanceof DDMStorageLinkImpl) {
440                            return ddmStorageLink;
441                    }
442    
443                    DDMStorageLinkImpl ddmStorageLinkImpl = new DDMStorageLinkImpl();
444    
445                    ddmStorageLinkImpl.setNew(ddmStorageLink.isNew());
446                    ddmStorageLinkImpl.setPrimaryKey(ddmStorageLink.getPrimaryKey());
447    
448                    ddmStorageLinkImpl.setUuid(ddmStorageLink.getUuid());
449                    ddmStorageLinkImpl.setStorageLinkId(ddmStorageLink.getStorageLinkId());
450                    ddmStorageLinkImpl.setClassNameId(ddmStorageLink.getClassNameId());
451                    ddmStorageLinkImpl.setClassPK(ddmStorageLink.getClassPK());
452                    ddmStorageLinkImpl.setStructureId(ddmStorageLink.getStructureId());
453    
454                    return ddmStorageLinkImpl;
455            }
456    
457            /**
458             * 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.
459             *
460             * @param primaryKey the primary key of the d d m storage link
461             * @return the d d m storage link
462             * @throws com.liferay.portal.NoSuchModelException if a d d m storage link with the primary key could not be found
463             * @throws SystemException if a system exception occurred
464             */
465            @Override
466            public DDMStorageLink findByPrimaryKey(Serializable primaryKey)
467                    throws NoSuchModelException, SystemException {
468                    return findByPrimaryKey(((Long)primaryKey).longValue());
469            }
470    
471            /**
472             * 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.
473             *
474             * @param storageLinkId the primary key of the d d m storage link
475             * @return the d d m storage link
476             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
477             * @throws SystemException if a system exception occurred
478             */
479            public DDMStorageLink findByPrimaryKey(long storageLinkId)
480                    throws NoSuchStorageLinkException, SystemException {
481                    DDMStorageLink ddmStorageLink = fetchByPrimaryKey(storageLinkId);
482    
483                    if (ddmStorageLink == null) {
484                            if (_log.isWarnEnabled()) {
485                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + storageLinkId);
486                            }
487    
488                            throw new NoSuchStorageLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
489                                    storageLinkId);
490                    }
491    
492                    return ddmStorageLink;
493            }
494    
495            /**
496             * Returns the d d m storage link with the primary key or returns <code>null</code> if it could not be found.
497             *
498             * @param primaryKey the primary key of the d d m storage link
499             * @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
500             * @throws SystemException if a system exception occurred
501             */
502            @Override
503            public DDMStorageLink fetchByPrimaryKey(Serializable primaryKey)
504                    throws SystemException {
505                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
506            }
507    
508            /**
509             * Returns the d d m storage link with the primary key or returns <code>null</code> if it could not be found.
510             *
511             * @param storageLinkId the primary key of the d d m storage link
512             * @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
513             * @throws SystemException if a system exception occurred
514             */
515            public DDMStorageLink fetchByPrimaryKey(long storageLinkId)
516                    throws SystemException {
517                    DDMStorageLink ddmStorageLink = (DDMStorageLink)EntityCacheUtil.getResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
518                                    DDMStorageLinkImpl.class, storageLinkId);
519    
520                    if (ddmStorageLink == _nullDDMStorageLink) {
521                            return null;
522                    }
523    
524                    if (ddmStorageLink == null) {
525                            Session session = null;
526    
527                            boolean hasException = false;
528    
529                            try {
530                                    session = openSession();
531    
532                                    ddmStorageLink = (DDMStorageLink)session.get(DDMStorageLinkImpl.class,
533                                                    Long.valueOf(storageLinkId));
534                            }
535                            catch (Exception e) {
536                                    hasException = true;
537    
538                                    throw processException(e);
539                            }
540                            finally {
541                                    if (ddmStorageLink != null) {
542                                            cacheResult(ddmStorageLink);
543                                    }
544                                    else if (!hasException) {
545                                            EntityCacheUtil.putResult(DDMStorageLinkModelImpl.ENTITY_CACHE_ENABLED,
546                                                    DDMStorageLinkImpl.class, storageLinkId,
547                                                    _nullDDMStorageLink);
548                                    }
549    
550                                    closeSession(session);
551                            }
552                    }
553    
554                    return ddmStorageLink;
555            }
556    
557            /**
558             * Returns all the d d m storage links where uuid = &#63;.
559             *
560             * @param uuid the uuid
561             * @return the matching d d m storage links
562             * @throws SystemException if a system exception occurred
563             */
564            public List<DDMStorageLink> findByUuid(String uuid)
565                    throws SystemException {
566                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
567            }
568    
569            /**
570             * Returns a range of all the d d m storage links where uuid = &#63;.
571             *
572             * <p>
573             * 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.
574             * </p>
575             *
576             * @param uuid the uuid
577             * @param start the lower bound of the range of d d m storage links
578             * @param end the upper bound of the range of d d m storage links (not inclusive)
579             * @return the range of matching d d m storage links
580             * @throws SystemException if a system exception occurred
581             */
582            public List<DDMStorageLink> findByUuid(String uuid, int start, int end)
583                    throws SystemException {
584                    return findByUuid(uuid, start, end, null);
585            }
586    
587            /**
588             * Returns an ordered range of all the d d m storage links where uuid = &#63;.
589             *
590             * <p>
591             * 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.
592             * </p>
593             *
594             * @param uuid the uuid
595             * @param start the lower bound of the range of d d m storage links
596             * @param end the upper bound of the range of d d m storage links (not inclusive)
597             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
598             * @return the ordered range of matching d d m storage links
599             * @throws SystemException if a system exception occurred
600             */
601            public List<DDMStorageLink> findByUuid(String uuid, int start, int end,
602                    OrderByComparator orderByComparator) throws SystemException {
603                    FinderPath finderPath = null;
604                    Object[] finderArgs = null;
605    
606                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
607                                    (orderByComparator == null)) {
608                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
609                            finderArgs = new Object[] { uuid };
610                    }
611                    else {
612                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
613                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
614                    }
615    
616                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
617                                    finderArgs, this);
618    
619                    if ((list != null) && !list.isEmpty()) {
620                            for (DDMStorageLink ddmStorageLink : list) {
621                                    if (!Validator.equals(uuid, ddmStorageLink.getUuid())) {
622                                            list = null;
623    
624                                            break;
625                                    }
626                            }
627                    }
628    
629                    if (list == null) {
630                            StringBundler query = null;
631    
632                            if (orderByComparator != null) {
633                                    query = new StringBundler(3 +
634                                                    (orderByComparator.getOrderByFields().length * 3));
635                            }
636                            else {
637                                    query = new StringBundler(2);
638                            }
639    
640                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
641    
642                            if (uuid == null) {
643                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
644                            }
645                            else {
646                                    if (uuid.equals(StringPool.BLANK)) {
647                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
648                                    }
649                                    else {
650                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
651                                    }
652                            }
653    
654                            if (orderByComparator != null) {
655                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
656                                            orderByComparator);
657                            }
658    
659                            String sql = query.toString();
660    
661                            Session session = null;
662    
663                            try {
664                                    session = openSession();
665    
666                                    Query q = session.createQuery(sql);
667    
668                                    QueryPos qPos = QueryPos.getInstance(q);
669    
670                                    if (uuid != null) {
671                                            qPos.add(uuid);
672                                    }
673    
674                                    list = (List<DDMStorageLink>)QueryUtil.list(q, getDialect(),
675                                                    start, end);
676                            }
677                            catch (Exception e) {
678                                    throw processException(e);
679                            }
680                            finally {
681                                    if (list == null) {
682                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
683                                    }
684                                    else {
685                                            cacheResult(list);
686    
687                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
688                                    }
689    
690                                    closeSession(session);
691                            }
692                    }
693    
694                    return list;
695            }
696    
697            /**
698             * Returns the first d d m storage link in the ordered set where uuid = &#63;.
699             *
700             * @param uuid the uuid
701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
702             * @return the first matching d d m storage link
703             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
704             * @throws SystemException if a system exception occurred
705             */
706            public DDMStorageLink findByUuid_First(String uuid,
707                    OrderByComparator orderByComparator)
708                    throws NoSuchStorageLinkException, SystemException {
709                    DDMStorageLink ddmStorageLink = fetchByUuid_First(uuid,
710                                    orderByComparator);
711    
712                    if (ddmStorageLink != null) {
713                            return ddmStorageLink;
714                    }
715    
716                    StringBundler msg = new StringBundler(4);
717    
718                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
719    
720                    msg.append("uuid=");
721                    msg.append(uuid);
722    
723                    msg.append(StringPool.CLOSE_CURLY_BRACE);
724    
725                    throw new NoSuchStorageLinkException(msg.toString());
726            }
727    
728            /**
729             * Returns the first d d m storage link in the ordered set where uuid = &#63;.
730             *
731             * @param uuid the uuid
732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
733             * @return the first matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
734             * @throws SystemException if a system exception occurred
735             */
736            public DDMStorageLink fetchByUuid_First(String uuid,
737                    OrderByComparator orderByComparator) throws SystemException {
738                    List<DDMStorageLink> list = findByUuid(uuid, 0, 1, orderByComparator);
739    
740                    if (!list.isEmpty()) {
741                            return list.get(0);
742                    }
743    
744                    return null;
745            }
746    
747            /**
748             * Returns the last d d m storage link in the ordered set where uuid = &#63;.
749             *
750             * @param uuid the uuid
751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
752             * @return the last matching d d m storage link
753             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
754             * @throws SystemException if a system exception occurred
755             */
756            public DDMStorageLink findByUuid_Last(String uuid,
757                    OrderByComparator orderByComparator)
758                    throws NoSuchStorageLinkException, SystemException {
759                    DDMStorageLink ddmStorageLink = fetchByUuid_Last(uuid, orderByComparator);
760    
761                    if (ddmStorageLink != null) {
762                            return ddmStorageLink;
763                    }
764    
765                    StringBundler msg = new StringBundler(4);
766    
767                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
768    
769                    msg.append("uuid=");
770                    msg.append(uuid);
771    
772                    msg.append(StringPool.CLOSE_CURLY_BRACE);
773    
774                    throw new NoSuchStorageLinkException(msg.toString());
775            }
776    
777            /**
778             * Returns the last d d m storage link in the ordered set where uuid = &#63;.
779             *
780             * @param uuid the uuid
781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
782             * @return the last matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
783             * @throws SystemException if a system exception occurred
784             */
785            public DDMStorageLink fetchByUuid_Last(String uuid,
786                    OrderByComparator orderByComparator) throws SystemException {
787                    int count = countByUuid(uuid);
788    
789                    List<DDMStorageLink> list = findByUuid(uuid, count - 1, count,
790                                    orderByComparator);
791    
792                    if (!list.isEmpty()) {
793                            return list.get(0);
794                    }
795    
796                    return null;
797            }
798    
799            /**
800             * Returns the d d m storage links before and after the current d d m storage link in the ordered set where uuid = &#63;.
801             *
802             * @param storageLinkId the primary key of the current d d m storage link
803             * @param uuid the uuid
804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
805             * @return the previous, current, and next d d m storage link
806             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
807             * @throws SystemException if a system exception occurred
808             */
809            public DDMStorageLink[] findByUuid_PrevAndNext(long storageLinkId,
810                    String uuid, OrderByComparator orderByComparator)
811                    throws NoSuchStorageLinkException, SystemException {
812                    DDMStorageLink ddmStorageLink = findByPrimaryKey(storageLinkId);
813    
814                    Session session = null;
815    
816                    try {
817                            session = openSession();
818    
819                            DDMStorageLink[] array = new DDMStorageLinkImpl[3];
820    
821                            array[0] = getByUuid_PrevAndNext(session, ddmStorageLink, uuid,
822                                            orderByComparator, true);
823    
824                            array[1] = ddmStorageLink;
825    
826                            array[2] = getByUuid_PrevAndNext(session, ddmStorageLink, uuid,
827                                            orderByComparator, false);
828    
829                            return array;
830                    }
831                    catch (Exception e) {
832                            throw processException(e);
833                    }
834                    finally {
835                            closeSession(session);
836                    }
837            }
838    
839            protected DDMStorageLink getByUuid_PrevAndNext(Session session,
840                    DDMStorageLink ddmStorageLink, String uuid,
841                    OrderByComparator orderByComparator, boolean previous) {
842                    StringBundler query = null;
843    
844                    if (orderByComparator != null) {
845                            query = new StringBundler(6 +
846                                            (orderByComparator.getOrderByFields().length * 6));
847                    }
848                    else {
849                            query = new StringBundler(3);
850                    }
851    
852                    query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
853    
854                    if (uuid == null) {
855                            query.append(_FINDER_COLUMN_UUID_UUID_1);
856                    }
857                    else {
858                            if (uuid.equals(StringPool.BLANK)) {
859                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
860                            }
861                            else {
862                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
863                            }
864                    }
865    
866                    if (orderByComparator != null) {
867                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
868    
869                            if (orderByConditionFields.length > 0) {
870                                    query.append(WHERE_AND);
871                            }
872    
873                            for (int i = 0; i < orderByConditionFields.length; i++) {
874                                    query.append(_ORDER_BY_ENTITY_ALIAS);
875                                    query.append(orderByConditionFields[i]);
876    
877                                    if ((i + 1) < orderByConditionFields.length) {
878                                            if (orderByComparator.isAscending() ^ previous) {
879                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
880                                            }
881                                            else {
882                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
883                                            }
884                                    }
885                                    else {
886                                            if (orderByComparator.isAscending() ^ previous) {
887                                                    query.append(WHERE_GREATER_THAN);
888                                            }
889                                            else {
890                                                    query.append(WHERE_LESSER_THAN);
891                                            }
892                                    }
893                            }
894    
895                            query.append(ORDER_BY_CLAUSE);
896    
897                            String[] orderByFields = orderByComparator.getOrderByFields();
898    
899                            for (int i = 0; i < orderByFields.length; i++) {
900                                    query.append(_ORDER_BY_ENTITY_ALIAS);
901                                    query.append(orderByFields[i]);
902    
903                                    if ((i + 1) < orderByFields.length) {
904                                            if (orderByComparator.isAscending() ^ previous) {
905                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
906                                            }
907                                            else {
908                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
909                                            }
910                                    }
911                                    else {
912                                            if (orderByComparator.isAscending() ^ previous) {
913                                                    query.append(ORDER_BY_ASC);
914                                            }
915                                            else {
916                                                    query.append(ORDER_BY_DESC);
917                                            }
918                                    }
919                            }
920                    }
921    
922                    String sql = query.toString();
923    
924                    Query q = session.createQuery(sql);
925    
926                    q.setFirstResult(0);
927                    q.setMaxResults(2);
928    
929                    QueryPos qPos = QueryPos.getInstance(q);
930    
931                    if (uuid != null) {
932                            qPos.add(uuid);
933                    }
934    
935                    if (orderByComparator != null) {
936                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStorageLink);
937    
938                            for (Object value : values) {
939                                    qPos.add(value);
940                            }
941                    }
942    
943                    List<DDMStorageLink> list = q.list();
944    
945                    if (list.size() == 2) {
946                            return list.get(1);
947                    }
948                    else {
949                            return null;
950                    }
951            }
952    
953            /**
954             * 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.
955             *
956             * @param classPK the class p k
957             * @return the matching d d m storage link
958             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
959             * @throws SystemException if a system exception occurred
960             */
961            public DDMStorageLink findByClassPK(long classPK)
962                    throws NoSuchStorageLinkException, SystemException {
963                    DDMStorageLink ddmStorageLink = fetchByClassPK(classPK);
964    
965                    if (ddmStorageLink == null) {
966                            StringBundler msg = new StringBundler(4);
967    
968                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
969    
970                            msg.append("classPK=");
971                            msg.append(classPK);
972    
973                            msg.append(StringPool.CLOSE_CURLY_BRACE);
974    
975                            if (_log.isWarnEnabled()) {
976                                    _log.warn(msg.toString());
977                            }
978    
979                            throw new NoSuchStorageLinkException(msg.toString());
980                    }
981    
982                    return ddmStorageLink;
983            }
984    
985            /**
986             * 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.
987             *
988             * @param classPK the class p k
989             * @return the matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
990             * @throws SystemException if a system exception occurred
991             */
992            public DDMStorageLink fetchByClassPK(long classPK)
993                    throws SystemException {
994                    return fetchByClassPK(classPK, true);
995            }
996    
997            /**
998             * 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.
999             *
1000             * @param classPK the class p k
1001             * @param retrieveFromCache whether to use the finder cache
1002             * @return the matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
1003             * @throws SystemException if a system exception occurred
1004             */
1005            public DDMStorageLink fetchByClassPK(long classPK, boolean retrieveFromCache)
1006                    throws SystemException {
1007                    Object[] finderArgs = new Object[] { classPK };
1008    
1009                    Object result = null;
1010    
1011                    if (retrieveFromCache) {
1012                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CLASSPK,
1013                                            finderArgs, this);
1014                    }
1015    
1016                    if (result instanceof DDMStorageLink) {
1017                            DDMStorageLink ddmStorageLink = (DDMStorageLink)result;
1018    
1019                            if ((classPK != ddmStorageLink.getClassPK())) {
1020                                    result = null;
1021                            }
1022                    }
1023    
1024                    if (result == null) {
1025                            StringBundler query = new StringBundler(2);
1026    
1027                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1028    
1029                            query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1030    
1031                            String sql = query.toString();
1032    
1033                            Session session = null;
1034    
1035                            try {
1036                                    session = openSession();
1037    
1038                                    Query q = session.createQuery(sql);
1039    
1040                                    QueryPos qPos = QueryPos.getInstance(q);
1041    
1042                                    qPos.add(classPK);
1043    
1044                                    List<DDMStorageLink> list = q.list();
1045    
1046                                    result = list;
1047    
1048                                    DDMStorageLink ddmStorageLink = null;
1049    
1050                                    if (list.isEmpty()) {
1051                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1052                                                    finderArgs, list);
1053                                    }
1054                                    else {
1055                                            ddmStorageLink = list.get(0);
1056    
1057                                            cacheResult(ddmStorageLink);
1058    
1059                                            if ((ddmStorageLink.getClassPK() != classPK)) {
1060                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CLASSPK,
1061                                                            finderArgs, ddmStorageLink);
1062                                            }
1063                                    }
1064    
1065                                    return ddmStorageLink;
1066                            }
1067                            catch (Exception e) {
1068                                    throw processException(e);
1069                            }
1070                            finally {
1071                                    if (result == null) {
1072                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CLASSPK,
1073                                                    finderArgs);
1074                                    }
1075    
1076                                    closeSession(session);
1077                            }
1078                    }
1079                    else {
1080                            if (result instanceof List<?>) {
1081                                    return null;
1082                            }
1083                            else {
1084                                    return (DDMStorageLink)result;
1085                            }
1086                    }
1087            }
1088    
1089            /**
1090             * Returns all the d d m storage links where structureId = &#63;.
1091             *
1092             * @param structureId the structure ID
1093             * @return the matching d d m storage links
1094             * @throws SystemException if a system exception occurred
1095             */
1096            public List<DDMStorageLink> findByStructureId(long structureId)
1097                    throws SystemException {
1098                    return findByStructureId(structureId, QueryUtil.ALL_POS,
1099                            QueryUtil.ALL_POS, null);
1100            }
1101    
1102            /**
1103             * Returns a range of all the d d m storage links where structureId = &#63;.
1104             *
1105             * <p>
1106             * 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.
1107             * </p>
1108             *
1109             * @param structureId the structure ID
1110             * @param start the lower bound of the range of d d m storage links
1111             * @param end the upper bound of the range of d d m storage links (not inclusive)
1112             * @return the range of matching d d m storage links
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public List<DDMStorageLink> findByStructureId(long structureId, int start,
1116                    int end) throws SystemException {
1117                    return findByStructureId(structureId, start, end, null);
1118            }
1119    
1120            /**
1121             * Returns an ordered range of all the d d m storage links where structureId = &#63;.
1122             *
1123             * <p>
1124             * 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.
1125             * </p>
1126             *
1127             * @param structureId the structure ID
1128             * @param start the lower bound of the range of d d m storage links
1129             * @param end the upper bound of the range of d d m storage links (not inclusive)
1130             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1131             * @return the ordered range of matching d d m storage links
1132             * @throws SystemException if a system exception occurred
1133             */
1134            public List<DDMStorageLink> findByStructureId(long structureId, int start,
1135                    int end, OrderByComparator orderByComparator) throws SystemException {
1136                    FinderPath finderPath = null;
1137                    Object[] finderArgs = null;
1138    
1139                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1140                                    (orderByComparator == null)) {
1141                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
1142                            finderArgs = new Object[] { structureId };
1143                    }
1144                    else {
1145                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
1146                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
1147                    }
1148    
1149                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
1150                                    finderArgs, this);
1151    
1152                    if ((list != null) && !list.isEmpty()) {
1153                            for (DDMStorageLink ddmStorageLink : list) {
1154                                    if ((structureId != ddmStorageLink.getStructureId())) {
1155                                            list = null;
1156    
1157                                            break;
1158                                    }
1159                            }
1160                    }
1161    
1162                    if (list == null) {
1163                            StringBundler query = null;
1164    
1165                            if (orderByComparator != null) {
1166                                    query = new StringBundler(3 +
1167                                                    (orderByComparator.getOrderByFields().length * 3));
1168                            }
1169                            else {
1170                                    query = new StringBundler(2);
1171                            }
1172    
1173                            query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1174    
1175                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1176    
1177                            if (orderByComparator != null) {
1178                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1179                                            orderByComparator);
1180                            }
1181    
1182                            String sql = query.toString();
1183    
1184                            Session session = null;
1185    
1186                            try {
1187                                    session = openSession();
1188    
1189                                    Query q = session.createQuery(sql);
1190    
1191                                    QueryPos qPos = QueryPos.getInstance(q);
1192    
1193                                    qPos.add(structureId);
1194    
1195                                    list = (List<DDMStorageLink>)QueryUtil.list(q, getDialect(),
1196                                                    start, end);
1197                            }
1198                            catch (Exception e) {
1199                                    throw processException(e);
1200                            }
1201                            finally {
1202                                    if (list == null) {
1203                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1204                                    }
1205                                    else {
1206                                            cacheResult(list);
1207    
1208                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1209                                    }
1210    
1211                                    closeSession(session);
1212                            }
1213                    }
1214    
1215                    return list;
1216            }
1217    
1218            /**
1219             * Returns the first d d m storage link in the ordered set where structureId = &#63;.
1220             *
1221             * @param structureId the structure ID
1222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1223             * @return the first matching d d m storage link
1224             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
1225             * @throws SystemException if a system exception occurred
1226             */
1227            public DDMStorageLink findByStructureId_First(long structureId,
1228                    OrderByComparator orderByComparator)
1229                    throws NoSuchStorageLinkException, SystemException {
1230                    DDMStorageLink ddmStorageLink = fetchByStructureId_First(structureId,
1231                                    orderByComparator);
1232    
1233                    if (ddmStorageLink != null) {
1234                            return ddmStorageLink;
1235                    }
1236    
1237                    StringBundler msg = new StringBundler(4);
1238    
1239                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240    
1241                    msg.append("structureId=");
1242                    msg.append(structureId);
1243    
1244                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1245    
1246                    throw new NoSuchStorageLinkException(msg.toString());
1247            }
1248    
1249            /**
1250             * Returns the first d d m storage link in the ordered set where structureId = &#63;.
1251             *
1252             * @param structureId the structure ID
1253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1254             * @return the first matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
1255             * @throws SystemException if a system exception occurred
1256             */
1257            public DDMStorageLink fetchByStructureId_First(long structureId,
1258                    OrderByComparator orderByComparator) throws SystemException {
1259                    List<DDMStorageLink> list = findByStructureId(structureId, 0, 1,
1260                                    orderByComparator);
1261    
1262                    if (!list.isEmpty()) {
1263                            return list.get(0);
1264                    }
1265    
1266                    return null;
1267            }
1268    
1269            /**
1270             * Returns the last d d m storage link in the ordered set where structureId = &#63;.
1271             *
1272             * @param structureId the structure ID
1273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1274             * @return the last matching d d m storage link
1275             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a matching d d m storage link could not be found
1276             * @throws SystemException if a system exception occurred
1277             */
1278            public DDMStorageLink findByStructureId_Last(long structureId,
1279                    OrderByComparator orderByComparator)
1280                    throws NoSuchStorageLinkException, SystemException {
1281                    DDMStorageLink ddmStorageLink = fetchByStructureId_Last(structureId,
1282                                    orderByComparator);
1283    
1284                    if (ddmStorageLink != null) {
1285                            return ddmStorageLink;
1286                    }
1287    
1288                    StringBundler msg = new StringBundler(4);
1289    
1290                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1291    
1292                    msg.append("structureId=");
1293                    msg.append(structureId);
1294    
1295                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1296    
1297                    throw new NoSuchStorageLinkException(msg.toString());
1298            }
1299    
1300            /**
1301             * Returns the last d d m storage link in the ordered set where structureId = &#63;.
1302             *
1303             * @param structureId the structure ID
1304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1305             * @return the last matching d d m storage link, or <code>null</code> if a matching d d m storage link could not be found
1306             * @throws SystemException if a system exception occurred
1307             */
1308            public DDMStorageLink fetchByStructureId_Last(long structureId,
1309                    OrderByComparator orderByComparator) throws SystemException {
1310                    int count = countByStructureId(structureId);
1311    
1312                    List<DDMStorageLink> list = findByStructureId(structureId, count - 1,
1313                                    count, orderByComparator);
1314    
1315                    if (!list.isEmpty()) {
1316                            return list.get(0);
1317                    }
1318    
1319                    return null;
1320            }
1321    
1322            /**
1323             * Returns the d d m storage links before and after the current d d m storage link in the ordered set where structureId = &#63;.
1324             *
1325             * @param storageLinkId the primary key of the current d d m storage link
1326             * @param structureId the structure ID
1327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1328             * @return the previous, current, and next d d m storage link
1329             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStorageLinkException if a d d m storage link with the primary key could not be found
1330             * @throws SystemException if a system exception occurred
1331             */
1332            public DDMStorageLink[] findByStructureId_PrevAndNext(long storageLinkId,
1333                    long structureId, OrderByComparator orderByComparator)
1334                    throws NoSuchStorageLinkException, SystemException {
1335                    DDMStorageLink ddmStorageLink = findByPrimaryKey(storageLinkId);
1336    
1337                    Session session = null;
1338    
1339                    try {
1340                            session = openSession();
1341    
1342                            DDMStorageLink[] array = new DDMStorageLinkImpl[3];
1343    
1344                            array[0] = getByStructureId_PrevAndNext(session, ddmStorageLink,
1345                                            structureId, orderByComparator, true);
1346    
1347                            array[1] = ddmStorageLink;
1348    
1349                            array[2] = getByStructureId_PrevAndNext(session, ddmStorageLink,
1350                                            structureId, orderByComparator, false);
1351    
1352                            return array;
1353                    }
1354                    catch (Exception e) {
1355                            throw processException(e);
1356                    }
1357                    finally {
1358                            closeSession(session);
1359                    }
1360            }
1361    
1362            protected DDMStorageLink getByStructureId_PrevAndNext(Session session,
1363                    DDMStorageLink ddmStorageLink, long structureId,
1364                    OrderByComparator orderByComparator, boolean previous) {
1365                    StringBundler query = null;
1366    
1367                    if (orderByComparator != null) {
1368                            query = new StringBundler(6 +
1369                                            (orderByComparator.getOrderByFields().length * 6));
1370                    }
1371                    else {
1372                            query = new StringBundler(3);
1373                    }
1374    
1375                    query.append(_SQL_SELECT_DDMSTORAGELINK_WHERE);
1376    
1377                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1378    
1379                    if (orderByComparator != null) {
1380                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1381    
1382                            if (orderByConditionFields.length > 0) {
1383                                    query.append(WHERE_AND);
1384                            }
1385    
1386                            for (int i = 0; i < orderByConditionFields.length; i++) {
1387                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1388                                    query.append(orderByConditionFields[i]);
1389    
1390                                    if ((i + 1) < orderByConditionFields.length) {
1391                                            if (orderByComparator.isAscending() ^ previous) {
1392                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1393                                            }
1394                                            else {
1395                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1396                                            }
1397                                    }
1398                                    else {
1399                                            if (orderByComparator.isAscending() ^ previous) {
1400                                                    query.append(WHERE_GREATER_THAN);
1401                                            }
1402                                            else {
1403                                                    query.append(WHERE_LESSER_THAN);
1404                                            }
1405                                    }
1406                            }
1407    
1408                            query.append(ORDER_BY_CLAUSE);
1409    
1410                            String[] orderByFields = orderByComparator.getOrderByFields();
1411    
1412                            for (int i = 0; i < orderByFields.length; i++) {
1413                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1414                                    query.append(orderByFields[i]);
1415    
1416                                    if ((i + 1) < orderByFields.length) {
1417                                            if (orderByComparator.isAscending() ^ previous) {
1418                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1419                                            }
1420                                            else {
1421                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1422                                            }
1423                                    }
1424                                    else {
1425                                            if (orderByComparator.isAscending() ^ previous) {
1426                                                    query.append(ORDER_BY_ASC);
1427                                            }
1428                                            else {
1429                                                    query.append(ORDER_BY_DESC);
1430                                            }
1431                                    }
1432                            }
1433                    }
1434    
1435                    String sql = query.toString();
1436    
1437                    Query q = session.createQuery(sql);
1438    
1439                    q.setFirstResult(0);
1440                    q.setMaxResults(2);
1441    
1442                    QueryPos qPos = QueryPos.getInstance(q);
1443    
1444                    qPos.add(structureId);
1445    
1446                    if (orderByComparator != null) {
1447                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStorageLink);
1448    
1449                            for (Object value : values) {
1450                                    qPos.add(value);
1451                            }
1452                    }
1453    
1454                    List<DDMStorageLink> list = q.list();
1455    
1456                    if (list.size() == 2) {
1457                            return list.get(1);
1458                    }
1459                    else {
1460                            return null;
1461                    }
1462            }
1463    
1464            /**
1465             * Returns all the d d m storage links.
1466             *
1467             * @return the d d m storage links
1468             * @throws SystemException if a system exception occurred
1469             */
1470            public List<DDMStorageLink> findAll() throws SystemException {
1471                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1472            }
1473    
1474            /**
1475             * Returns a range of all the d d m storage links.
1476             *
1477             * <p>
1478             * 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.
1479             * </p>
1480             *
1481             * @param start the lower bound of the range of d d m storage links
1482             * @param end the upper bound of the range of d d m storage links (not inclusive)
1483             * @return the range of d d m storage links
1484             * @throws SystemException if a system exception occurred
1485             */
1486            public List<DDMStorageLink> findAll(int start, int end)
1487                    throws SystemException {
1488                    return findAll(start, end, null);
1489            }
1490    
1491            /**
1492             * Returns an ordered range of all the d d m storage links.
1493             *
1494             * <p>
1495             * 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.
1496             * </p>
1497             *
1498             * @param start the lower bound of the range of d d m storage links
1499             * @param end the upper bound of the range of d d m storage links (not inclusive)
1500             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1501             * @return the ordered range of d d m storage links
1502             * @throws SystemException if a system exception occurred
1503             */
1504            public List<DDMStorageLink> findAll(int start, int end,
1505                    OrderByComparator orderByComparator) throws SystemException {
1506                    FinderPath finderPath = null;
1507                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1508    
1509                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1510                                    (orderByComparator == null)) {
1511                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1512                            finderArgs = FINDER_ARGS_EMPTY;
1513                    }
1514                    else {
1515                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1516                            finderArgs = new Object[] { start, end, orderByComparator };
1517                    }
1518    
1519                    List<DDMStorageLink> list = (List<DDMStorageLink>)FinderCacheUtil.getResult(finderPath,
1520                                    finderArgs, this);
1521    
1522                    if (list == null) {
1523                            StringBundler query = null;
1524                            String sql = null;
1525    
1526                            if (orderByComparator != null) {
1527                                    query = new StringBundler(2 +
1528                                                    (orderByComparator.getOrderByFields().length * 3));
1529    
1530                                    query.append(_SQL_SELECT_DDMSTORAGELINK);
1531    
1532                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1533                                            orderByComparator);
1534    
1535                                    sql = query.toString();
1536                            }
1537                            else {
1538                                    sql = _SQL_SELECT_DDMSTORAGELINK;
1539                            }
1540    
1541                            Session session = null;
1542    
1543                            try {
1544                                    session = openSession();
1545    
1546                                    Query q = session.createQuery(sql);
1547    
1548                                    if (orderByComparator == null) {
1549                                            list = (List<DDMStorageLink>)QueryUtil.list(q,
1550                                                            getDialect(), start, end, false);
1551    
1552                                            Collections.sort(list);
1553                                    }
1554                                    else {
1555                                            list = (List<DDMStorageLink>)QueryUtil.list(q,
1556                                                            getDialect(), start, end);
1557                                    }
1558                            }
1559                            catch (Exception e) {
1560                                    throw processException(e);
1561                            }
1562                            finally {
1563                                    if (list == null) {
1564                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1565                                    }
1566                                    else {
1567                                            cacheResult(list);
1568    
1569                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1570                                    }
1571    
1572                                    closeSession(session);
1573                            }
1574                    }
1575    
1576                    return list;
1577            }
1578    
1579            /**
1580             * Removes all the d d m storage links where uuid = &#63; from the database.
1581             *
1582             * @param uuid the uuid
1583             * @throws SystemException if a system exception occurred
1584             */
1585            public void removeByUuid(String uuid) throws SystemException {
1586                    for (DDMStorageLink ddmStorageLink : findByUuid(uuid)) {
1587                            remove(ddmStorageLink);
1588                    }
1589            }
1590    
1591            /**
1592             * Removes the d d m storage link where classPK = &#63; from the database.
1593             *
1594             * @param classPK the class p k
1595             * @return the d d m storage link that was removed
1596             * @throws SystemException if a system exception occurred
1597             */
1598            public DDMStorageLink removeByClassPK(long classPK)
1599                    throws NoSuchStorageLinkException, SystemException {
1600                    DDMStorageLink ddmStorageLink = findByClassPK(classPK);
1601    
1602                    return remove(ddmStorageLink);
1603            }
1604    
1605            /**
1606             * Removes all the d d m storage links where structureId = &#63; from the database.
1607             *
1608             * @param structureId the structure ID
1609             * @throws SystemException if a system exception occurred
1610             */
1611            public void removeByStructureId(long structureId) throws SystemException {
1612                    for (DDMStorageLink ddmStorageLink : findByStructureId(structureId)) {
1613                            remove(ddmStorageLink);
1614                    }
1615            }
1616    
1617            /**
1618             * Removes all the d d m storage links from the database.
1619             *
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public void removeAll() throws SystemException {
1623                    for (DDMStorageLink ddmStorageLink : findAll()) {
1624                            remove(ddmStorageLink);
1625                    }
1626            }
1627    
1628            /**
1629             * Returns the number of d d m storage links where uuid = &#63;.
1630             *
1631             * @param uuid the uuid
1632             * @return the number of matching d d m storage links
1633             * @throws SystemException if a system exception occurred
1634             */
1635            public int countByUuid(String uuid) throws SystemException {
1636                    Object[] finderArgs = new Object[] { uuid };
1637    
1638                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1639                                    finderArgs, this);
1640    
1641                    if (count == null) {
1642                            StringBundler query = new StringBundler(2);
1643    
1644                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1645    
1646                            if (uuid == null) {
1647                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1648                            }
1649                            else {
1650                                    if (uuid.equals(StringPool.BLANK)) {
1651                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1652                                    }
1653                                    else {
1654                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1655                                    }
1656                            }
1657    
1658                            String sql = query.toString();
1659    
1660                            Session session = null;
1661    
1662                            try {
1663                                    session = openSession();
1664    
1665                                    Query q = session.createQuery(sql);
1666    
1667                                    QueryPos qPos = QueryPos.getInstance(q);
1668    
1669                                    if (uuid != null) {
1670                                            qPos.add(uuid);
1671                                    }
1672    
1673                                    count = (Long)q.uniqueResult();
1674                            }
1675                            catch (Exception e) {
1676                                    throw processException(e);
1677                            }
1678                            finally {
1679                                    if (count == null) {
1680                                            count = Long.valueOf(0);
1681                                    }
1682    
1683                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1684                                            finderArgs, count);
1685    
1686                                    closeSession(session);
1687                            }
1688                    }
1689    
1690                    return count.intValue();
1691            }
1692    
1693            /**
1694             * Returns the number of d d m storage links where classPK = &#63;.
1695             *
1696             * @param classPK the class p k
1697             * @return the number of matching d d m storage links
1698             * @throws SystemException if a system exception occurred
1699             */
1700            public int countByClassPK(long classPK) throws SystemException {
1701                    Object[] finderArgs = new Object[] { classPK };
1702    
1703                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSPK,
1704                                    finderArgs, this);
1705    
1706                    if (count == null) {
1707                            StringBundler query = new StringBundler(2);
1708    
1709                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1710    
1711                            query.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
1712    
1713                            String sql = query.toString();
1714    
1715                            Session session = null;
1716    
1717                            try {
1718                                    session = openSession();
1719    
1720                                    Query q = session.createQuery(sql);
1721    
1722                                    QueryPos qPos = QueryPos.getInstance(q);
1723    
1724                                    qPos.add(classPK);
1725    
1726                                    count = (Long)q.uniqueResult();
1727                            }
1728                            catch (Exception e) {
1729                                    throw processException(e);
1730                            }
1731                            finally {
1732                                    if (count == null) {
1733                                            count = Long.valueOf(0);
1734                                    }
1735    
1736                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSPK,
1737                                            finderArgs, count);
1738    
1739                                    closeSession(session);
1740                            }
1741                    }
1742    
1743                    return count.intValue();
1744            }
1745    
1746            /**
1747             * Returns the number of d d m storage links where structureId = &#63;.
1748             *
1749             * @param structureId the structure ID
1750             * @return the number of matching d d m storage links
1751             * @throws SystemException if a system exception occurred
1752             */
1753            public int countByStructureId(long structureId) throws SystemException {
1754                    Object[] finderArgs = new Object[] { structureId };
1755    
1756                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1757                                    finderArgs, this);
1758    
1759                    if (count == null) {
1760                            StringBundler query = new StringBundler(2);
1761    
1762                            query.append(_SQL_COUNT_DDMSTORAGELINK_WHERE);
1763    
1764                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1765    
1766                            String sql = query.toString();
1767    
1768                            Session session = null;
1769    
1770                            try {
1771                                    session = openSession();
1772    
1773                                    Query q = session.createQuery(sql);
1774    
1775                                    QueryPos qPos = QueryPos.getInstance(q);
1776    
1777                                    qPos.add(structureId);
1778    
1779                                    count = (Long)q.uniqueResult();
1780                            }
1781                            catch (Exception e) {
1782                                    throw processException(e);
1783                            }
1784                            finally {
1785                                    if (count == null) {
1786                                            count = Long.valueOf(0);
1787                                    }
1788    
1789                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1790                                            finderArgs, count);
1791    
1792                                    closeSession(session);
1793                            }
1794                    }
1795    
1796                    return count.intValue();
1797            }
1798    
1799            /**
1800             * Returns the number of d d m storage links.
1801             *
1802             * @return the number of d d m storage links
1803             * @throws SystemException if a system exception occurred
1804             */
1805            public int countAll() throws SystemException {
1806                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1807                                    FINDER_ARGS_EMPTY, this);
1808    
1809                    if (count == null) {
1810                            Session session = null;
1811    
1812                            try {
1813                                    session = openSession();
1814    
1815                                    Query q = session.createQuery(_SQL_COUNT_DDMSTORAGELINK);
1816    
1817                                    count = (Long)q.uniqueResult();
1818                            }
1819                            catch (Exception e) {
1820                                    throw processException(e);
1821                            }
1822                            finally {
1823                                    if (count == null) {
1824                                            count = Long.valueOf(0);
1825                                    }
1826    
1827                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1828                                            FINDER_ARGS_EMPTY, count);
1829    
1830                                    closeSession(session);
1831                            }
1832                    }
1833    
1834                    return count.intValue();
1835            }
1836    
1837            /**
1838             * Initializes the d d m storage link persistence.
1839             */
1840            public void afterPropertiesSet() {
1841                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1842                                            com.liferay.portal.util.PropsUtil.get(
1843                                                    "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink")));
1844    
1845                    if (listenerClassNames.length > 0) {
1846                            try {
1847                                    List<ModelListener<DDMStorageLink>> listenersList = new ArrayList<ModelListener<DDMStorageLink>>();
1848    
1849                                    for (String listenerClassName : listenerClassNames) {
1850                                            listenersList.add((ModelListener<DDMStorageLink>)InstanceFactory.newInstance(
1851                                                            listenerClassName));
1852                                    }
1853    
1854                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1855                            }
1856                            catch (Exception e) {
1857                                    _log.error(e);
1858                            }
1859                    }
1860            }
1861    
1862            public void destroy() {
1863                    EntityCacheUtil.removeCache(DDMStorageLinkImpl.class.getName());
1864                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1865                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1866            }
1867    
1868            @BeanReference(type = DDMContentPersistence.class)
1869            protected DDMContentPersistence ddmContentPersistence;
1870            @BeanReference(type = DDMStorageLinkPersistence.class)
1871            protected DDMStorageLinkPersistence ddmStorageLinkPersistence;
1872            @BeanReference(type = DDMStructurePersistence.class)
1873            protected DDMStructurePersistence ddmStructurePersistence;
1874            @BeanReference(type = DDMStructureLinkPersistence.class)
1875            protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
1876            @BeanReference(type = DDMTemplatePersistence.class)
1877            protected DDMTemplatePersistence ddmTemplatePersistence;
1878            @BeanReference(type = ResourcePersistence.class)
1879            protected ResourcePersistence resourcePersistence;
1880            @BeanReference(type = UserPersistence.class)
1881            protected UserPersistence userPersistence;
1882            private static final String _SQL_SELECT_DDMSTORAGELINK = "SELECT ddmStorageLink FROM DDMStorageLink ddmStorageLink";
1883            private static final String _SQL_SELECT_DDMSTORAGELINK_WHERE = "SELECT ddmStorageLink FROM DDMStorageLink ddmStorageLink WHERE ";
1884            private static final String _SQL_COUNT_DDMSTORAGELINK = "SELECT COUNT(ddmStorageLink) FROM DDMStorageLink ddmStorageLink";
1885            private static final String _SQL_COUNT_DDMSTORAGELINK_WHERE = "SELECT COUNT(ddmStorageLink) FROM DDMStorageLink ddmStorageLink WHERE ";
1886            private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmStorageLink.uuid IS NULL";
1887            private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmStorageLink.uuid = ?";
1888            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmStorageLink.uuid IS NULL OR ddmStorageLink.uuid = ?)";
1889            private static final String _FINDER_COLUMN_CLASSPK_CLASSPK_2 = "ddmStorageLink.classPK = ?";
1890            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "ddmStorageLink.structureId = ?";
1891            private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStorageLink.";
1892            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStorageLink exists with the primary key ";
1893            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStorageLink exists with the key {";
1894            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1895            private static Log _log = LogFactoryUtil.getLog(DDMStorageLinkPersistenceImpl.class);
1896            private static DDMStorageLink _nullDDMStorageLink = new DDMStorageLinkImpl() {
1897                            @Override
1898                            public Object clone() {
1899                                    return this;
1900                            }
1901    
1902                            @Override
1903                            public CacheModel<DDMStorageLink> toCacheModel() {
1904                                    return _nullDDMStorageLinkCacheModel;
1905                            }
1906                    };
1907    
1908            private static CacheModel<DDMStorageLink> _nullDDMStorageLinkCacheModel = new CacheModel<DDMStorageLink>() {
1909                            public DDMStorageLink toEntityModel() {
1910                                    return _nullDDMStorageLink;
1911                            }
1912                    };
1913    }