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