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