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