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