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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.ArrayUtil;
032    import com.liferay.portal.kernel.util.GetterUtil;
033    import com.liferay.portal.kernel.util.InstanceFactory;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
047    import com.liferay.portlet.dynamicdatamapping.NoSuchStructureException;
048    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
049    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl;
050    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl;
051    
052    import java.io.Serializable;
053    
054    import java.util.ArrayList;
055    import java.util.Collections;
056    import java.util.List;
057    
058    /**
059     * The persistence implementation for the d d m structure service.
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see DDMStructurePersistence
067     * @see DDMStructureUtil
068     * @generated
069     */
070    public class DDMStructurePersistenceImpl extends BasePersistenceImpl<DDMStructure>
071            implements DDMStructurePersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link DDMStructureUtil} to access the d d m structure persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = DDMStructureImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
083                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
085                            new String[] {
086                                    String.class.getName(),
087                                    
088                            "java.lang.Integer", "java.lang.Integer",
089                                    "com.liferay.portal.kernel.util.OrderByComparator"
090                            });
091            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
092                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094                            new String[] { String.class.getName() },
095                            DDMStructureModelImpl.UUID_COLUMN_BITMASK);
096            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
097                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099                            new String[] { String.class.getName() });
100            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
101                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
102                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
103                            new String[] { String.class.getName(), Long.class.getName() },
104                            DDMStructureModelImpl.UUID_COLUMN_BITMASK |
105                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
107                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
109                            new String[] { String.class.getName(), Long.class.getName() });
110            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
111                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
112                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
113                            new String[] {
114                                    String.class.getName(), Long.class.getName(),
115                                    
116                            "java.lang.Integer", "java.lang.Integer",
117                                    "com.liferay.portal.kernel.util.OrderByComparator"
118                            });
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
120                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
121                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
123                            new String[] { String.class.getName(), Long.class.getName() },
124                            DDMStructureModelImpl.UUID_COLUMN_BITMASK |
125                            DDMStructureModelImpl.COMPANYID_COLUMN_BITMASK);
126            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
127                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
129                            new String[] { String.class.getName(), Long.class.getName() });
130            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
131                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
132                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
133                            new String[] {
134                                    Long.class.getName(),
135                                    
136                            "java.lang.Integer", "java.lang.Integer",
137                                    "com.liferay.portal.kernel.util.OrderByComparator"
138                            });
139            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
140                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
141                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
143                            new String[] { Long.class.getName() },
144                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
145            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
146                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
148                            new String[] { Long.class.getName() });
149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
150                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
151                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
152                            new String[] { Long.class.getName() });
153            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
154                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
155                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
156                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByClassNameId",
157                            new String[] {
158                                    Long.class.getName(),
159                                    
160                            "java.lang.Integer", "java.lang.Integer",
161                                    "com.liferay.portal.kernel.util.OrderByComparator"
162                            });
163            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
164                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
165                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
166                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
167                            new String[] { Long.class.getName() },
168                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
169            public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
170                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
171                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
172                            new String[] { Long.class.getName() });
173            public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
174                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
175                            FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
176                            new String[] { Long.class.getName(), String.class.getName() },
177                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
178                            DDMStructureModelImpl.STRUCTUREKEY_COLUMN_BITMASK);
179            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
180                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
181                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
182                            new String[] { Long.class.getName(), String.class.getName() });
183            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
184                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
185                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
186                            new String[] {
187                                    Long.class.getName(), Long.class.getName(),
188                                    
189                            "java.lang.Integer", "java.lang.Integer",
190                                    "com.liferay.portal.kernel.util.OrderByComparator"
191                            });
192            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
193                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
194                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
195                            new String[] { Long.class.getName(), Long.class.getName() },
196                            DDMStructureModelImpl.COMPANYID_COLUMN_BITMASK |
197                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
198            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
199                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
200                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
201                            new String[] { Long.class.getName(), Long.class.getName() });
202            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
203                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
204                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_D",
205                            new String[] {
206                                    Long.class.getName(), String.class.getName(),
207                                    String.class.getName(),
208                                    
209                            "java.lang.Integer", "java.lang.Integer",
210                                    "com.liferay.portal.kernel.util.OrderByComparator"
211                            });
212            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
213                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
214                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_D",
215                            new String[] {
216                                    Long.class.getName(), String.class.getName(),
217                                    String.class.getName()
218                            },
219                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
220                            DDMStructureModelImpl.NAME_COLUMN_BITMASK |
221                            DDMStructureModelImpl.DESCRIPTION_COLUMN_BITMASK);
222            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
223                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
224                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_D",
225                            new String[] {
226                                    Long.class.getName(), String.class.getName(),
227                                    String.class.getName()
228                            });
229            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
230                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
231                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
232            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
233                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
234                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
235            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
236                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
237                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
238    
239            /**
240             * Caches the d d m structure in the entity cache if it is enabled.
241             *
242             * @param ddmStructure the d d m structure
243             */
244            public void cacheResult(DDMStructure ddmStructure) {
245                    EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
246                            DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
247    
248                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
249                            new Object[] {
250                                    ddmStructure.getUuid(), Long.valueOf(ddmStructure.getGroupId())
251                            }, ddmStructure);
252    
253                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
254                            new Object[] {
255                                    Long.valueOf(ddmStructure.getGroupId()),
256                                    
257                            ddmStructure.getStructureKey()
258                            }, ddmStructure);
259    
260                    ddmStructure.resetOriginalValues();
261            }
262    
263            /**
264             * Caches the d d m structures in the entity cache if it is enabled.
265             *
266             * @param ddmStructures the d d m structures
267             */
268            public void cacheResult(List<DDMStructure> ddmStructures) {
269                    for (DDMStructure ddmStructure : ddmStructures) {
270                            if (EntityCacheUtil.getResult(
271                                                    DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
272                                                    DDMStructureImpl.class, ddmStructure.getPrimaryKey()) == null) {
273                                    cacheResult(ddmStructure);
274                            }
275                            else {
276                                    ddmStructure.resetOriginalValues();
277                            }
278                    }
279            }
280    
281            /**
282             * Clears the cache for all d d m structures.
283             *
284             * <p>
285             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
286             * </p>
287             */
288            @Override
289            public void clearCache() {
290                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
291                            CacheRegistryUtil.clear(DDMStructureImpl.class.getName());
292                    }
293    
294                    EntityCacheUtil.clearCache(DDMStructureImpl.class.getName());
295    
296                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
297                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
298                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
299            }
300    
301            /**
302             * Clears the cache for the d d m structure.
303             *
304             * <p>
305             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
306             * </p>
307             */
308            @Override
309            public void clearCache(DDMStructure ddmStructure) {
310                    EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
311                            DDMStructureImpl.class, ddmStructure.getPrimaryKey());
312    
313                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
314                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
315    
316                    clearUniqueFindersCache(ddmStructure);
317            }
318    
319            @Override
320            public void clearCache(List<DDMStructure> ddmStructures) {
321                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
322                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
323    
324                    for (DDMStructure ddmStructure : ddmStructures) {
325                            EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
326                                    DDMStructureImpl.class, ddmStructure.getPrimaryKey());
327    
328                            clearUniqueFindersCache(ddmStructure);
329                    }
330            }
331    
332            protected void clearUniqueFindersCache(DDMStructure ddmStructure) {
333                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
334                            new Object[] {
335                                    ddmStructure.getUuid(), Long.valueOf(ddmStructure.getGroupId())
336                            });
337    
338                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
339                            new Object[] {
340                                    Long.valueOf(ddmStructure.getGroupId()),
341                                    
342                            ddmStructure.getStructureKey()
343                            });
344            }
345    
346            /**
347             * Creates a new d d m structure with the primary key. Does not add the d d m structure to the database.
348             *
349             * @param structureId the primary key for the new d d m structure
350             * @return the new d d m structure
351             */
352            public DDMStructure create(long structureId) {
353                    DDMStructure ddmStructure = new DDMStructureImpl();
354    
355                    ddmStructure.setNew(true);
356                    ddmStructure.setPrimaryKey(structureId);
357    
358                    String uuid = PortalUUIDUtil.generate();
359    
360                    ddmStructure.setUuid(uuid);
361    
362                    return ddmStructure;
363            }
364    
365            /**
366             * Removes the d d m structure with the primary key from the database. Also notifies the appropriate model listeners.
367             *
368             * @param structureId the primary key of the d d m structure
369             * @return the d d m structure that was removed
370             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
371             * @throws SystemException if a system exception occurred
372             */
373            public DDMStructure remove(long structureId)
374                    throws NoSuchStructureException, SystemException {
375                    return remove(Long.valueOf(structureId));
376            }
377    
378            /**
379             * Removes the d d m structure with the primary key from the database. Also notifies the appropriate model listeners.
380             *
381             * @param primaryKey the primary key of the d d m structure
382             * @return the d d m structure that was removed
383             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
384             * @throws SystemException if a system exception occurred
385             */
386            @Override
387            public DDMStructure remove(Serializable primaryKey)
388                    throws NoSuchStructureException, SystemException {
389                    Session session = null;
390    
391                    try {
392                            session = openSession();
393    
394                            DDMStructure ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
395                                            primaryKey);
396    
397                            if (ddmStructure == null) {
398                                    if (_log.isWarnEnabled()) {
399                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
400                                    }
401    
402                                    throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
403                                            primaryKey);
404                            }
405    
406                            return remove(ddmStructure);
407                    }
408                    catch (NoSuchStructureException nsee) {
409                            throw nsee;
410                    }
411                    catch (Exception e) {
412                            throw processException(e);
413                    }
414                    finally {
415                            closeSession(session);
416                    }
417            }
418    
419            @Override
420            protected DDMStructure removeImpl(DDMStructure ddmStructure)
421                    throws SystemException {
422                    ddmStructure = toUnwrappedModel(ddmStructure);
423    
424                    Session session = null;
425    
426                    try {
427                            session = openSession();
428    
429                            if (ddmStructure.isCachedModel()) {
430                                    ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
431                                                    ddmStructure.getPrimaryKeyObj());
432                            }
433    
434                            session.delete(ddmStructure);
435                    }
436                    catch (Exception e) {
437                            throw processException(e);
438                    }
439                    finally {
440                            closeSession(session);
441                    }
442    
443                    clearCache(ddmStructure);
444    
445                    return ddmStructure;
446            }
447    
448            @Override
449            public DDMStructure updateImpl(
450                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
451                    throws SystemException {
452                    ddmStructure = toUnwrappedModel(ddmStructure);
453    
454                    boolean isNew = ddmStructure.isNew();
455    
456                    DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
457    
458                    if (Validator.isNull(ddmStructure.getUuid())) {
459                            String uuid = PortalUUIDUtil.generate();
460    
461                            ddmStructure.setUuid(uuid);
462                    }
463    
464                    Session session = null;
465    
466                    try {
467                            session = openSession();
468    
469                            if (ddmStructure.isNew()) {
470                                    session.save(ddmStructure);
471    
472                                    ddmStructure.setNew(false);
473                            }
474                            else {
475                                    session.merge(ddmStructure);
476                            }
477                    }
478                    catch (Exception e) {
479                            throw processException(e);
480                    }
481                    finally {
482                            closeSession(session);
483                    }
484    
485                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
486    
487                    if (isNew || !DDMStructureModelImpl.COLUMN_BITMASK_ENABLED) {
488                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
489                    }
490    
491                    else {
492                            if ((ddmStructureModelImpl.getColumnBitmask() &
493                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
494                                    Object[] args = new Object[] {
495                                                    ddmStructureModelImpl.getOriginalUuid()
496                                            };
497    
498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
500                                            args);
501    
502                                    args = new Object[] { ddmStructureModelImpl.getUuid() };
503    
504                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
505                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
506                                            args);
507                            }
508    
509                            if ((ddmStructureModelImpl.getColumnBitmask() &
510                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
511                                    Object[] args = new Object[] {
512                                                    ddmStructureModelImpl.getOriginalUuid(),
513                                                    Long.valueOf(ddmStructureModelImpl.getOriginalCompanyId())
514                                            };
515    
516                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
517                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
518                                            args);
519    
520                                    args = new Object[] {
521                                                    ddmStructureModelImpl.getUuid(),
522                                                    Long.valueOf(ddmStructureModelImpl.getCompanyId())
523                                            };
524    
525                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
526                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
527                                            args);
528                            }
529    
530                            if ((ddmStructureModelImpl.getColumnBitmask() &
531                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
532                                    Object[] args = new Object[] {
533                                                    Long.valueOf(ddmStructureModelImpl.getOriginalGroupId())
534                                            };
535    
536                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
537                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
538                                            args);
539    
540                                    args = new Object[] {
541                                                    Long.valueOf(ddmStructureModelImpl.getGroupId())
542                                            };
543    
544                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
545                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
546                                            args);
547                            }
548    
549                            if ((ddmStructureModelImpl.getColumnBitmask() &
550                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
551                                    Object[] args = new Object[] {
552                                                    Long.valueOf(ddmStructureModelImpl.getOriginalClassNameId())
553                                            };
554    
555                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
556                                            args);
557                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
558                                            args);
559    
560                                    args = new Object[] {
561                                                    Long.valueOf(ddmStructureModelImpl.getClassNameId())
562                                            };
563    
564                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
565                                            args);
566                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
567                                            args);
568                            }
569    
570                            if ((ddmStructureModelImpl.getColumnBitmask() &
571                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
572                                    Object[] args = new Object[] {
573                                                    Long.valueOf(ddmStructureModelImpl.getOriginalCompanyId()),
574                                                    Long.valueOf(ddmStructureModelImpl.getOriginalClassNameId())
575                                            };
576    
577                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
578                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
579                                            args);
580    
581                                    args = new Object[] {
582                                                    Long.valueOf(ddmStructureModelImpl.getCompanyId()),
583                                                    Long.valueOf(ddmStructureModelImpl.getClassNameId())
584                                            };
585    
586                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
587                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
588                                            args);
589                            }
590    
591                            if ((ddmStructureModelImpl.getColumnBitmask() &
592                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D.getColumnBitmask()) != 0) {
593                                    Object[] args = new Object[] {
594                                                    Long.valueOf(ddmStructureModelImpl.getOriginalGroupId()),
595                                                    
596                                                    ddmStructureModelImpl.getOriginalName(),
597                                                    
598                                                    ddmStructureModelImpl.getOriginalDescription()
599                                            };
600    
601                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
602                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
603                                            args);
604    
605                                    args = new Object[] {
606                                                    Long.valueOf(ddmStructureModelImpl.getGroupId()),
607                                                    
608                                                    ddmStructureModelImpl.getName(),
609                                                    
610                                                    ddmStructureModelImpl.getDescription()
611                                            };
612    
613                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
614                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
615                                            args);
616                            }
617                    }
618    
619                    EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
620                            DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
621    
622                    if (isNew) {
623                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
624                                    new Object[] {
625                                            ddmStructure.getUuid(),
626                                            Long.valueOf(ddmStructure.getGroupId())
627                                    }, ddmStructure);
628    
629                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
630                                    new Object[] {
631                                            Long.valueOf(ddmStructure.getGroupId()),
632                                            
633                                    ddmStructure.getStructureKey()
634                                    }, ddmStructure);
635                    }
636                    else {
637                            if ((ddmStructureModelImpl.getColumnBitmask() &
638                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
639                                    Object[] args = new Object[] {
640                                                    ddmStructureModelImpl.getOriginalUuid(),
641                                                    Long.valueOf(ddmStructureModelImpl.getOriginalGroupId())
642                                            };
643    
644                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
645    
646                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
647    
648                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
649                                            new Object[] {
650                                                    ddmStructure.getUuid(),
651                                                    Long.valueOf(ddmStructure.getGroupId())
652                                            }, ddmStructure);
653                            }
654    
655                            if ((ddmStructureModelImpl.getColumnBitmask() &
656                                            FINDER_PATH_FETCH_BY_G_S.getColumnBitmask()) != 0) {
657                                    Object[] args = new Object[] {
658                                                    Long.valueOf(ddmStructureModelImpl.getOriginalGroupId()),
659                                                    
660                                                    ddmStructureModelImpl.getOriginalStructureKey()
661                                            };
662    
663                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
664    
665                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S, args);
666    
667                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
668                                            new Object[] {
669                                                    Long.valueOf(ddmStructure.getGroupId()),
670                                                    
671                                            ddmStructure.getStructureKey()
672                                            }, ddmStructure);
673                            }
674                    }
675    
676                    return ddmStructure;
677            }
678    
679            protected DDMStructure toUnwrappedModel(DDMStructure ddmStructure) {
680                    if (ddmStructure instanceof DDMStructureImpl) {
681                            return ddmStructure;
682                    }
683    
684                    DDMStructureImpl ddmStructureImpl = new DDMStructureImpl();
685    
686                    ddmStructureImpl.setNew(ddmStructure.isNew());
687                    ddmStructureImpl.setPrimaryKey(ddmStructure.getPrimaryKey());
688    
689                    ddmStructureImpl.setUuid(ddmStructure.getUuid());
690                    ddmStructureImpl.setStructureId(ddmStructure.getStructureId());
691                    ddmStructureImpl.setGroupId(ddmStructure.getGroupId());
692                    ddmStructureImpl.setCompanyId(ddmStructure.getCompanyId());
693                    ddmStructureImpl.setUserId(ddmStructure.getUserId());
694                    ddmStructureImpl.setUserName(ddmStructure.getUserName());
695                    ddmStructureImpl.setCreateDate(ddmStructure.getCreateDate());
696                    ddmStructureImpl.setModifiedDate(ddmStructure.getModifiedDate());
697                    ddmStructureImpl.setParentStructureId(ddmStructure.getParentStructureId());
698                    ddmStructureImpl.setClassNameId(ddmStructure.getClassNameId());
699                    ddmStructureImpl.setStructureKey(ddmStructure.getStructureKey());
700                    ddmStructureImpl.setName(ddmStructure.getName());
701                    ddmStructureImpl.setDescription(ddmStructure.getDescription());
702                    ddmStructureImpl.setXsd(ddmStructure.getXsd());
703                    ddmStructureImpl.setStorageType(ddmStructure.getStorageType());
704                    ddmStructureImpl.setType(ddmStructure.getType());
705    
706                    return ddmStructureImpl;
707            }
708    
709            /**
710             * Returns the d d m structure with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
711             *
712             * @param primaryKey the primary key of the d d m structure
713             * @return the d d m structure
714             * @throws com.liferay.portal.NoSuchModelException if a d d m structure with the primary key could not be found
715             * @throws SystemException if a system exception occurred
716             */
717            @Override
718            public DDMStructure findByPrimaryKey(Serializable primaryKey)
719                    throws NoSuchModelException, SystemException {
720                    return findByPrimaryKey(((Long)primaryKey).longValue());
721            }
722    
723            /**
724             * Returns the d d m structure with the primary key or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStructureException} if it could not be found.
725             *
726             * @param structureId the primary key of the d d m structure
727             * @return the d d m structure
728             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
729             * @throws SystemException if a system exception occurred
730             */
731            public DDMStructure findByPrimaryKey(long structureId)
732                    throws NoSuchStructureException, SystemException {
733                    DDMStructure ddmStructure = fetchByPrimaryKey(structureId);
734    
735                    if (ddmStructure == null) {
736                            if (_log.isWarnEnabled()) {
737                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + structureId);
738                            }
739    
740                            throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
741                                    structureId);
742                    }
743    
744                    return ddmStructure;
745            }
746    
747            /**
748             * Returns the d d m structure with the primary key or returns <code>null</code> if it could not be found.
749             *
750             * @param primaryKey the primary key of the d d m structure
751             * @return the d d m structure, or <code>null</code> if a d d m structure with the primary key could not be found
752             * @throws SystemException if a system exception occurred
753             */
754            @Override
755            public DDMStructure fetchByPrimaryKey(Serializable primaryKey)
756                    throws SystemException {
757                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
758            }
759    
760            /**
761             * Returns the d d m structure with the primary key or returns <code>null</code> if it could not be found.
762             *
763             * @param structureId the primary key of the d d m structure
764             * @return the d d m structure, or <code>null</code> if a d d m structure with the primary key could not be found
765             * @throws SystemException if a system exception occurred
766             */
767            public DDMStructure fetchByPrimaryKey(long structureId)
768                    throws SystemException {
769                    DDMStructure ddmStructure = (DDMStructure)EntityCacheUtil.getResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
770                                    DDMStructureImpl.class, structureId);
771    
772                    if (ddmStructure == _nullDDMStructure) {
773                            return null;
774                    }
775    
776                    if (ddmStructure == null) {
777                            Session session = null;
778    
779                            boolean hasException = false;
780    
781                            try {
782                                    session = openSession();
783    
784                                    ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
785                                                    Long.valueOf(structureId));
786                            }
787                            catch (Exception e) {
788                                    hasException = true;
789    
790                                    throw processException(e);
791                            }
792                            finally {
793                                    if (ddmStructure != null) {
794                                            cacheResult(ddmStructure);
795                                    }
796                                    else if (!hasException) {
797                                            EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
798                                                    DDMStructureImpl.class, structureId, _nullDDMStructure);
799                                    }
800    
801                                    closeSession(session);
802                            }
803                    }
804    
805                    return ddmStructure;
806            }
807    
808            /**
809             * Returns all the d d m structures where uuid = &#63;.
810             *
811             * @param uuid the uuid
812             * @return the matching d d m structures
813             * @throws SystemException if a system exception occurred
814             */
815            public List<DDMStructure> findByUuid(String uuid) throws SystemException {
816                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
817            }
818    
819            /**
820             * Returns a range of all the d d m structures where uuid = &#63;.
821             *
822             * <p>
823             * 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.
824             * </p>
825             *
826             * @param uuid the uuid
827             * @param start the lower bound of the range of d d m structures
828             * @param end the upper bound of the range of d d m structures (not inclusive)
829             * @return the range of matching d d m structures
830             * @throws SystemException if a system exception occurred
831             */
832            public List<DDMStructure> findByUuid(String uuid, int start, int end)
833                    throws SystemException {
834                    return findByUuid(uuid, start, end, null);
835            }
836    
837            /**
838             * Returns an ordered range of all the d d m structures where uuid = &#63;.
839             *
840             * <p>
841             * 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.
842             * </p>
843             *
844             * @param uuid the uuid
845             * @param start the lower bound of the range of d d m structures
846             * @param end the upper bound of the range of d d m structures (not inclusive)
847             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
848             * @return the ordered range of matching d d m structures
849             * @throws SystemException if a system exception occurred
850             */
851            public List<DDMStructure> findByUuid(String uuid, int start, int end,
852                    OrderByComparator orderByComparator) throws SystemException {
853                    FinderPath finderPath = null;
854                    Object[] finderArgs = null;
855    
856                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
857                                    (orderByComparator == null)) {
858                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
859                            finderArgs = new Object[] { uuid };
860                    }
861                    else {
862                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
863                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
864                    }
865    
866                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
867                                    finderArgs, this);
868    
869                    if ((list != null) && !list.isEmpty()) {
870                            for (DDMStructure ddmStructure : list) {
871                                    if (!Validator.equals(uuid, ddmStructure.getUuid())) {
872                                            list = null;
873    
874                                            break;
875                                    }
876                            }
877                    }
878    
879                    if (list == null) {
880                            StringBundler query = null;
881    
882                            if (orderByComparator != null) {
883                                    query = new StringBundler(3 +
884                                                    (orderByComparator.getOrderByFields().length * 3));
885                            }
886                            else {
887                                    query = new StringBundler(2);
888                            }
889    
890                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
891    
892                            if (uuid == null) {
893                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
894                            }
895                            else {
896                                    if (uuid.equals(StringPool.BLANK)) {
897                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
898                                    }
899                                    else {
900                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
901                                    }
902                            }
903    
904                            if (orderByComparator != null) {
905                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
906                                            orderByComparator);
907                            }
908    
909                            String sql = query.toString();
910    
911                            Session session = null;
912    
913                            try {
914                                    session = openSession();
915    
916                                    Query q = session.createQuery(sql);
917    
918                                    QueryPos qPos = QueryPos.getInstance(q);
919    
920                                    if (uuid != null) {
921                                            qPos.add(uuid);
922                                    }
923    
924                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
925                                                    start, end);
926                            }
927                            catch (Exception e) {
928                                    throw processException(e);
929                            }
930                            finally {
931                                    if (list == null) {
932                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
933                                    }
934                                    else {
935                                            cacheResult(list);
936    
937                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
938                                    }
939    
940                                    closeSession(session);
941                            }
942                    }
943    
944                    return list;
945            }
946    
947            /**
948             * Returns the first d d m structure in the ordered set where uuid = &#63;.
949             *
950             * @param uuid the uuid
951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
952             * @return the first matching d d m structure
953             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
954             * @throws SystemException if a system exception occurred
955             */
956            public DDMStructure findByUuid_First(String uuid,
957                    OrderByComparator orderByComparator)
958                    throws NoSuchStructureException, SystemException {
959                    DDMStructure ddmStructure = fetchByUuid_First(uuid, orderByComparator);
960    
961                    if (ddmStructure != null) {
962                            return ddmStructure;
963                    }
964    
965                    StringBundler msg = new StringBundler(4);
966    
967                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
968    
969                    msg.append("uuid=");
970                    msg.append(uuid);
971    
972                    msg.append(StringPool.CLOSE_CURLY_BRACE);
973    
974                    throw new NoSuchStructureException(msg.toString());
975            }
976    
977            /**
978             * Returns the first d d m structure in the ordered set where uuid = &#63;.
979             *
980             * @param uuid the uuid
981             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
982             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
983             * @throws SystemException if a system exception occurred
984             */
985            public DDMStructure fetchByUuid_First(String uuid,
986                    OrderByComparator orderByComparator) throws SystemException {
987                    List<DDMStructure> list = findByUuid(uuid, 0, 1, orderByComparator);
988    
989                    if (!list.isEmpty()) {
990                            return list.get(0);
991                    }
992    
993                    return null;
994            }
995    
996            /**
997             * Returns the last d d m structure in the ordered set where uuid = &#63;.
998             *
999             * @param uuid the uuid
1000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1001             * @return the last matching d d m structure
1002             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1003             * @throws SystemException if a system exception occurred
1004             */
1005            public DDMStructure findByUuid_Last(String uuid,
1006                    OrderByComparator orderByComparator)
1007                    throws NoSuchStructureException, SystemException {
1008                    DDMStructure ddmStructure = fetchByUuid_Last(uuid, orderByComparator);
1009    
1010                    if (ddmStructure != null) {
1011                            return ddmStructure;
1012                    }
1013    
1014                    StringBundler msg = new StringBundler(4);
1015    
1016                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1017    
1018                    msg.append("uuid=");
1019                    msg.append(uuid);
1020    
1021                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1022    
1023                    throw new NoSuchStructureException(msg.toString());
1024            }
1025    
1026            /**
1027             * Returns the last d d m structure in the ordered set where uuid = &#63;.
1028             *
1029             * @param uuid the uuid
1030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1031             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1032             * @throws SystemException if a system exception occurred
1033             */
1034            public DDMStructure fetchByUuid_Last(String uuid,
1035                    OrderByComparator orderByComparator) throws SystemException {
1036                    int count = countByUuid(uuid);
1037    
1038                    List<DDMStructure> list = findByUuid(uuid, count - 1, count,
1039                                    orderByComparator);
1040    
1041                    if (!list.isEmpty()) {
1042                            return list.get(0);
1043                    }
1044    
1045                    return null;
1046            }
1047    
1048            /**
1049             * Returns the d d m structures before and after the current d d m structure in the ordered set where uuid = &#63;.
1050             *
1051             * @param structureId the primary key of the current d d m structure
1052             * @param uuid the uuid
1053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1054             * @return the previous, current, and next d d m structure
1055             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
1056             * @throws SystemException if a system exception occurred
1057             */
1058            public DDMStructure[] findByUuid_PrevAndNext(long structureId, String uuid,
1059                    OrderByComparator orderByComparator)
1060                    throws NoSuchStructureException, SystemException {
1061                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
1062    
1063                    Session session = null;
1064    
1065                    try {
1066                            session = openSession();
1067    
1068                            DDMStructure[] array = new DDMStructureImpl[3];
1069    
1070                            array[0] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
1071                                            orderByComparator, true);
1072    
1073                            array[1] = ddmStructure;
1074    
1075                            array[2] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
1076                                            orderByComparator, false);
1077    
1078                            return array;
1079                    }
1080                    catch (Exception e) {
1081                            throw processException(e);
1082                    }
1083                    finally {
1084                            closeSession(session);
1085                    }
1086            }
1087    
1088            protected DDMStructure getByUuid_PrevAndNext(Session session,
1089                    DDMStructure ddmStructure, String uuid,
1090                    OrderByComparator orderByComparator, boolean previous) {
1091                    StringBundler query = null;
1092    
1093                    if (orderByComparator != null) {
1094                            query = new StringBundler(6 +
1095                                            (orderByComparator.getOrderByFields().length * 6));
1096                    }
1097                    else {
1098                            query = new StringBundler(3);
1099                    }
1100    
1101                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1102    
1103                    if (uuid == null) {
1104                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1105                    }
1106                    else {
1107                            if (uuid.equals(StringPool.BLANK)) {
1108                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1109                            }
1110                            else {
1111                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1112                            }
1113                    }
1114    
1115                    if (orderByComparator != null) {
1116                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1117    
1118                            if (orderByConditionFields.length > 0) {
1119                                    query.append(WHERE_AND);
1120                            }
1121    
1122                            for (int i = 0; i < orderByConditionFields.length; i++) {
1123                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1124                                    query.append(orderByConditionFields[i]);
1125    
1126                                    if ((i + 1) < orderByConditionFields.length) {
1127                                            if (orderByComparator.isAscending() ^ previous) {
1128                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1129                                            }
1130                                            else {
1131                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1132                                            }
1133                                    }
1134                                    else {
1135                                            if (orderByComparator.isAscending() ^ previous) {
1136                                                    query.append(WHERE_GREATER_THAN);
1137                                            }
1138                                            else {
1139                                                    query.append(WHERE_LESSER_THAN);
1140                                            }
1141                                    }
1142                            }
1143    
1144                            query.append(ORDER_BY_CLAUSE);
1145    
1146                            String[] orderByFields = orderByComparator.getOrderByFields();
1147    
1148                            for (int i = 0; i < orderByFields.length; i++) {
1149                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1150                                    query.append(orderByFields[i]);
1151    
1152                                    if ((i + 1) < orderByFields.length) {
1153                                            if (orderByComparator.isAscending() ^ previous) {
1154                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1155                                            }
1156                                            else {
1157                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1158                                            }
1159                                    }
1160                                    else {
1161                                            if (orderByComparator.isAscending() ^ previous) {
1162                                                    query.append(ORDER_BY_ASC);
1163                                            }
1164                                            else {
1165                                                    query.append(ORDER_BY_DESC);
1166                                            }
1167                                    }
1168                            }
1169                    }
1170    
1171                    String sql = query.toString();
1172    
1173                    Query q = session.createQuery(sql);
1174    
1175                    q.setFirstResult(0);
1176                    q.setMaxResults(2);
1177    
1178                    QueryPos qPos = QueryPos.getInstance(q);
1179    
1180                    if (uuid != null) {
1181                            qPos.add(uuid);
1182                    }
1183    
1184                    if (orderByComparator != null) {
1185                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1186    
1187                            for (Object value : values) {
1188                                    qPos.add(value);
1189                            }
1190                    }
1191    
1192                    List<DDMStructure> list = q.list();
1193    
1194                    if (list.size() == 2) {
1195                            return list.get(1);
1196                    }
1197                    else {
1198                            return null;
1199                    }
1200            }
1201    
1202            /**
1203             * Returns the d d m structure where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStructureException} if it could not be found.
1204             *
1205             * @param uuid the uuid
1206             * @param groupId the group ID
1207             * @return the matching d d m structure
1208             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1209             * @throws SystemException if a system exception occurred
1210             */
1211            public DDMStructure findByUUID_G(String uuid, long groupId)
1212                    throws NoSuchStructureException, SystemException {
1213                    DDMStructure ddmStructure = fetchByUUID_G(uuid, groupId);
1214    
1215                    if (ddmStructure == null) {
1216                            StringBundler msg = new StringBundler(6);
1217    
1218                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1219    
1220                            msg.append("uuid=");
1221                            msg.append(uuid);
1222    
1223                            msg.append(", groupId=");
1224                            msg.append(groupId);
1225    
1226                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1227    
1228                            if (_log.isWarnEnabled()) {
1229                                    _log.warn(msg.toString());
1230                            }
1231    
1232                            throw new NoSuchStructureException(msg.toString());
1233                    }
1234    
1235                    return ddmStructure;
1236            }
1237    
1238            /**
1239             * Returns the d d m structure where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1240             *
1241             * @param uuid the uuid
1242             * @param groupId the group ID
1243             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1244             * @throws SystemException if a system exception occurred
1245             */
1246            public DDMStructure fetchByUUID_G(String uuid, long groupId)
1247                    throws SystemException {
1248                    return fetchByUUID_G(uuid, groupId, true);
1249            }
1250    
1251            /**
1252             * Returns the d d m structure where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1253             *
1254             * @param uuid the uuid
1255             * @param groupId the group ID
1256             * @param retrieveFromCache whether to use the finder cache
1257             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1258             * @throws SystemException if a system exception occurred
1259             */
1260            public DDMStructure fetchByUUID_G(String uuid, long groupId,
1261                    boolean retrieveFromCache) throws SystemException {
1262                    Object[] finderArgs = new Object[] { uuid, groupId };
1263    
1264                    Object result = null;
1265    
1266                    if (retrieveFromCache) {
1267                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1268                                            finderArgs, this);
1269                    }
1270    
1271                    if (result instanceof DDMStructure) {
1272                            DDMStructure ddmStructure = (DDMStructure)result;
1273    
1274                            if (!Validator.equals(uuid, ddmStructure.getUuid()) ||
1275                                            (groupId != ddmStructure.getGroupId())) {
1276                                    result = null;
1277                            }
1278                    }
1279    
1280                    if (result == null) {
1281                            StringBundler query = new StringBundler(3);
1282    
1283                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1284    
1285                            if (uuid == null) {
1286                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1287                            }
1288                            else {
1289                                    if (uuid.equals(StringPool.BLANK)) {
1290                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1291                                    }
1292                                    else {
1293                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1294                                    }
1295                            }
1296    
1297                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1298    
1299                            String sql = query.toString();
1300    
1301                            Session session = null;
1302    
1303                            try {
1304                                    session = openSession();
1305    
1306                                    Query q = session.createQuery(sql);
1307    
1308                                    QueryPos qPos = QueryPos.getInstance(q);
1309    
1310                                    if (uuid != null) {
1311                                            qPos.add(uuid);
1312                                    }
1313    
1314                                    qPos.add(groupId);
1315    
1316                                    List<DDMStructure> list = q.list();
1317    
1318                                    result = list;
1319    
1320                                    DDMStructure ddmStructure = null;
1321    
1322                                    if (list.isEmpty()) {
1323                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1324                                                    finderArgs, list);
1325                                    }
1326                                    else {
1327                                            ddmStructure = list.get(0);
1328    
1329                                            cacheResult(ddmStructure);
1330    
1331                                            if ((ddmStructure.getUuid() == null) ||
1332                                                            !ddmStructure.getUuid().equals(uuid) ||
1333                                                            (ddmStructure.getGroupId() != groupId)) {
1334                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1335                                                            finderArgs, ddmStructure);
1336                                            }
1337                                    }
1338    
1339                                    return ddmStructure;
1340                            }
1341                            catch (Exception e) {
1342                                    throw processException(e);
1343                            }
1344                            finally {
1345                                    if (result == null) {
1346                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1347                                                    finderArgs);
1348                                    }
1349    
1350                                    closeSession(session);
1351                            }
1352                    }
1353                    else {
1354                            if (result instanceof List<?>) {
1355                                    return null;
1356                            }
1357                            else {
1358                                    return (DDMStructure)result;
1359                            }
1360                    }
1361            }
1362    
1363            /**
1364             * Returns all the d d m structures where uuid = &#63; and companyId = &#63;.
1365             *
1366             * @param uuid the uuid
1367             * @param companyId the company ID
1368             * @return the matching d d m structures
1369             * @throws SystemException if a system exception occurred
1370             */
1371            public List<DDMStructure> findByUuid_C(String uuid, long companyId)
1372                    throws SystemException {
1373                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1374                            QueryUtil.ALL_POS, null);
1375            }
1376    
1377            /**
1378             * Returns a range of all the d d m structures where uuid = &#63; and companyId = &#63;.
1379             *
1380             * <p>
1381             * 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.
1382             * </p>
1383             *
1384             * @param uuid the uuid
1385             * @param companyId the company ID
1386             * @param start the lower bound of the range of d d m structures
1387             * @param end the upper bound of the range of d d m structures (not inclusive)
1388             * @return the range of matching d d m structures
1389             * @throws SystemException if a system exception occurred
1390             */
1391            public List<DDMStructure> findByUuid_C(String uuid, long companyId,
1392                    int start, int end) throws SystemException {
1393                    return findByUuid_C(uuid, companyId, start, end, null);
1394            }
1395    
1396            /**
1397             * Returns an ordered range of all the d d m structures where uuid = &#63; and companyId = &#63;.
1398             *
1399             * <p>
1400             * 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.
1401             * </p>
1402             *
1403             * @param uuid the uuid
1404             * @param companyId the company ID
1405             * @param start the lower bound of the range of d d m structures
1406             * @param end the upper bound of the range of d d m structures (not inclusive)
1407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1408             * @return the ordered range of matching d d m structures
1409             * @throws SystemException if a system exception occurred
1410             */
1411            public List<DDMStructure> findByUuid_C(String uuid, long companyId,
1412                    int start, int end, OrderByComparator orderByComparator)
1413                    throws SystemException {
1414                    FinderPath finderPath = null;
1415                    Object[] finderArgs = null;
1416    
1417                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1418                                    (orderByComparator == null)) {
1419                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1420                            finderArgs = new Object[] { uuid, companyId };
1421                    }
1422                    else {
1423                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1424                            finderArgs = new Object[] {
1425                                            uuid, companyId,
1426                                            
1427                                            start, end, orderByComparator
1428                                    };
1429                    }
1430    
1431                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
1432                                    finderArgs, this);
1433    
1434                    if ((list != null) && !list.isEmpty()) {
1435                            for (DDMStructure ddmStructure : list) {
1436                                    if (!Validator.equals(uuid, ddmStructure.getUuid()) ||
1437                                                    (companyId != ddmStructure.getCompanyId())) {
1438                                            list = null;
1439    
1440                                            break;
1441                                    }
1442                            }
1443                    }
1444    
1445                    if (list == null) {
1446                            StringBundler query = null;
1447    
1448                            if (orderByComparator != null) {
1449                                    query = new StringBundler(4 +
1450                                                    (orderByComparator.getOrderByFields().length * 3));
1451                            }
1452                            else {
1453                                    query = new StringBundler(3);
1454                            }
1455    
1456                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1457    
1458                            if (uuid == null) {
1459                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1460                            }
1461                            else {
1462                                    if (uuid.equals(StringPool.BLANK)) {
1463                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1464                                    }
1465                                    else {
1466                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1467                                    }
1468                            }
1469    
1470                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1471    
1472                            if (orderByComparator != null) {
1473                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1474                                            orderByComparator);
1475                            }
1476    
1477                            String sql = query.toString();
1478    
1479                            Session session = null;
1480    
1481                            try {
1482                                    session = openSession();
1483    
1484                                    Query q = session.createQuery(sql);
1485    
1486                                    QueryPos qPos = QueryPos.getInstance(q);
1487    
1488                                    if (uuid != null) {
1489                                            qPos.add(uuid);
1490                                    }
1491    
1492                                    qPos.add(companyId);
1493    
1494                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1495                                                    start, end);
1496                            }
1497                            catch (Exception e) {
1498                                    throw processException(e);
1499                            }
1500                            finally {
1501                                    if (list == null) {
1502                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1503                                    }
1504                                    else {
1505                                            cacheResult(list);
1506    
1507                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1508                                    }
1509    
1510                                    closeSession(session);
1511                            }
1512                    }
1513    
1514                    return list;
1515            }
1516    
1517            /**
1518             * Returns the first d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1519             *
1520             * @param uuid the uuid
1521             * @param companyId the company ID
1522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1523             * @return the first matching d d m structure
1524             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1525             * @throws SystemException if a system exception occurred
1526             */
1527            public DDMStructure findByUuid_C_First(String uuid, long companyId,
1528                    OrderByComparator orderByComparator)
1529                    throws NoSuchStructureException, SystemException {
1530                    DDMStructure ddmStructure = fetchByUuid_C_First(uuid, companyId,
1531                                    orderByComparator);
1532    
1533                    if (ddmStructure != null) {
1534                            return ddmStructure;
1535                    }
1536    
1537                    StringBundler msg = new StringBundler(6);
1538    
1539                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1540    
1541                    msg.append("uuid=");
1542                    msg.append(uuid);
1543    
1544                    msg.append(", companyId=");
1545                    msg.append(companyId);
1546    
1547                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1548    
1549                    throw new NoSuchStructureException(msg.toString());
1550            }
1551    
1552            /**
1553             * Returns the first d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1554             *
1555             * @param uuid the uuid
1556             * @param companyId the company ID
1557             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1558             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1559             * @throws SystemException if a system exception occurred
1560             */
1561            public DDMStructure fetchByUuid_C_First(String uuid, long companyId,
1562                    OrderByComparator orderByComparator) throws SystemException {
1563                    List<DDMStructure> list = findByUuid_C(uuid, companyId, 0, 1,
1564                                    orderByComparator);
1565    
1566                    if (!list.isEmpty()) {
1567                            return list.get(0);
1568                    }
1569    
1570                    return null;
1571            }
1572    
1573            /**
1574             * Returns the last d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1575             *
1576             * @param uuid the uuid
1577             * @param companyId the company ID
1578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1579             * @return the last matching d d m structure
1580             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1581             * @throws SystemException if a system exception occurred
1582             */
1583            public DDMStructure findByUuid_C_Last(String uuid, long companyId,
1584                    OrderByComparator orderByComparator)
1585                    throws NoSuchStructureException, SystemException {
1586                    DDMStructure ddmStructure = fetchByUuid_C_Last(uuid, companyId,
1587                                    orderByComparator);
1588    
1589                    if (ddmStructure != null) {
1590                            return ddmStructure;
1591                    }
1592    
1593                    StringBundler msg = new StringBundler(6);
1594    
1595                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1596    
1597                    msg.append("uuid=");
1598                    msg.append(uuid);
1599    
1600                    msg.append(", companyId=");
1601                    msg.append(companyId);
1602    
1603                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1604    
1605                    throw new NoSuchStructureException(msg.toString());
1606            }
1607    
1608            /**
1609             * Returns the last d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1610             *
1611             * @param uuid the uuid
1612             * @param companyId the company ID
1613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1614             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1615             * @throws SystemException if a system exception occurred
1616             */
1617            public DDMStructure fetchByUuid_C_Last(String uuid, long companyId,
1618                    OrderByComparator orderByComparator) throws SystemException {
1619                    int count = countByUuid_C(uuid, companyId);
1620    
1621                    List<DDMStructure> list = findByUuid_C(uuid, companyId, count - 1,
1622                                    count, orderByComparator);
1623    
1624                    if (!list.isEmpty()) {
1625                            return list.get(0);
1626                    }
1627    
1628                    return null;
1629            }
1630    
1631            /**
1632             * Returns the d d m structures before and after the current d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1633             *
1634             * @param structureId the primary key of the current d d m structure
1635             * @param uuid the uuid
1636             * @param companyId the company ID
1637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1638             * @return the previous, current, and next d d m structure
1639             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
1640             * @throws SystemException if a system exception occurred
1641             */
1642            public DDMStructure[] findByUuid_C_PrevAndNext(long structureId,
1643                    String uuid, long companyId, OrderByComparator orderByComparator)
1644                    throws NoSuchStructureException, SystemException {
1645                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
1646    
1647                    Session session = null;
1648    
1649                    try {
1650                            session = openSession();
1651    
1652                            DDMStructure[] array = new DDMStructureImpl[3];
1653    
1654                            array[0] = getByUuid_C_PrevAndNext(session, ddmStructure, uuid,
1655                                            companyId, orderByComparator, true);
1656    
1657                            array[1] = ddmStructure;
1658    
1659                            array[2] = getByUuid_C_PrevAndNext(session, ddmStructure, uuid,
1660                                            companyId, orderByComparator, false);
1661    
1662                            return array;
1663                    }
1664                    catch (Exception e) {
1665                            throw processException(e);
1666                    }
1667                    finally {
1668                            closeSession(session);
1669                    }
1670            }
1671    
1672            protected DDMStructure getByUuid_C_PrevAndNext(Session session,
1673                    DDMStructure ddmStructure, String uuid, long companyId,
1674                    OrderByComparator orderByComparator, boolean previous) {
1675                    StringBundler query = null;
1676    
1677                    if (orderByComparator != null) {
1678                            query = new StringBundler(6 +
1679                                            (orderByComparator.getOrderByFields().length * 6));
1680                    }
1681                    else {
1682                            query = new StringBundler(3);
1683                    }
1684    
1685                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1686    
1687                    if (uuid == null) {
1688                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1689                    }
1690                    else {
1691                            if (uuid.equals(StringPool.BLANK)) {
1692                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1693                            }
1694                            else {
1695                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1696                            }
1697                    }
1698    
1699                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1700    
1701                    if (orderByComparator != null) {
1702                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1703    
1704                            if (orderByConditionFields.length > 0) {
1705                                    query.append(WHERE_AND);
1706                            }
1707    
1708                            for (int i = 0; i < orderByConditionFields.length; i++) {
1709                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1710                                    query.append(orderByConditionFields[i]);
1711    
1712                                    if ((i + 1) < orderByConditionFields.length) {
1713                                            if (orderByComparator.isAscending() ^ previous) {
1714                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1715                                            }
1716                                            else {
1717                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1718                                            }
1719                                    }
1720                                    else {
1721                                            if (orderByComparator.isAscending() ^ previous) {
1722                                                    query.append(WHERE_GREATER_THAN);
1723                                            }
1724                                            else {
1725                                                    query.append(WHERE_LESSER_THAN);
1726                                            }
1727                                    }
1728                            }
1729    
1730                            query.append(ORDER_BY_CLAUSE);
1731    
1732                            String[] orderByFields = orderByComparator.getOrderByFields();
1733    
1734                            for (int i = 0; i < orderByFields.length; i++) {
1735                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1736                                    query.append(orderByFields[i]);
1737    
1738                                    if ((i + 1) < orderByFields.length) {
1739                                            if (orderByComparator.isAscending() ^ previous) {
1740                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1741                                            }
1742                                            else {
1743                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1744                                            }
1745                                    }
1746                                    else {
1747                                            if (orderByComparator.isAscending() ^ previous) {
1748                                                    query.append(ORDER_BY_ASC);
1749                                            }
1750                                            else {
1751                                                    query.append(ORDER_BY_DESC);
1752                                            }
1753                                    }
1754                            }
1755                    }
1756    
1757                    String sql = query.toString();
1758    
1759                    Query q = session.createQuery(sql);
1760    
1761                    q.setFirstResult(0);
1762                    q.setMaxResults(2);
1763    
1764                    QueryPos qPos = QueryPos.getInstance(q);
1765    
1766                    if (uuid != null) {
1767                            qPos.add(uuid);
1768                    }
1769    
1770                    qPos.add(companyId);
1771    
1772                    if (orderByComparator != null) {
1773                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1774    
1775                            for (Object value : values) {
1776                                    qPos.add(value);
1777                            }
1778                    }
1779    
1780                    List<DDMStructure> list = q.list();
1781    
1782                    if (list.size() == 2) {
1783                            return list.get(1);
1784                    }
1785                    else {
1786                            return null;
1787                    }
1788            }
1789    
1790            /**
1791             * Returns all the d d m structures where groupId = &#63;.
1792             *
1793             * @param groupId the group ID
1794             * @return the matching d d m structures
1795             * @throws SystemException if a system exception occurred
1796             */
1797            public List<DDMStructure> findByGroupId(long groupId)
1798                    throws SystemException {
1799                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1800            }
1801    
1802            /**
1803             * Returns a range of all the d d m structures where groupId = &#63;.
1804             *
1805             * <p>
1806             * 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.
1807             * </p>
1808             *
1809             * @param groupId the group ID
1810             * @param start the lower bound of the range of d d m structures
1811             * @param end the upper bound of the range of d d m structures (not inclusive)
1812             * @return the range of matching d d m structures
1813             * @throws SystemException if a system exception occurred
1814             */
1815            public List<DDMStructure> findByGroupId(long groupId, int start, int end)
1816                    throws SystemException {
1817                    return findByGroupId(groupId, start, end, null);
1818            }
1819    
1820            /**
1821             * Returns an ordered range of all the d d m structures where groupId = &#63;.
1822             *
1823             * <p>
1824             * 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.
1825             * </p>
1826             *
1827             * @param groupId the group ID
1828             * @param start the lower bound of the range of d d m structures
1829             * @param end the upper bound of the range of d d m structures (not inclusive)
1830             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1831             * @return the ordered range of matching d d m structures
1832             * @throws SystemException if a system exception occurred
1833             */
1834            public List<DDMStructure> findByGroupId(long groupId, int start, int end,
1835                    OrderByComparator orderByComparator) throws SystemException {
1836                    FinderPath finderPath = null;
1837                    Object[] finderArgs = null;
1838    
1839                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1840                                    (orderByComparator == null)) {
1841                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1842                            finderArgs = new Object[] { groupId };
1843                    }
1844                    else {
1845                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1846                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1847                    }
1848    
1849                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
1850                                    finderArgs, this);
1851    
1852                    if ((list != null) && !list.isEmpty()) {
1853                            for (DDMStructure ddmStructure : list) {
1854                                    if ((groupId != ddmStructure.getGroupId())) {
1855                                            list = null;
1856    
1857                                            break;
1858                                    }
1859                            }
1860                    }
1861    
1862                    if (list == null) {
1863                            StringBundler query = null;
1864    
1865                            if (orderByComparator != null) {
1866                                    query = new StringBundler(3 +
1867                                                    (orderByComparator.getOrderByFields().length * 3));
1868                            }
1869                            else {
1870                                    query = new StringBundler(2);
1871                            }
1872    
1873                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1874    
1875                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1876    
1877                            if (orderByComparator != null) {
1878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1879                                            orderByComparator);
1880                            }
1881    
1882                            String sql = query.toString();
1883    
1884                            Session session = null;
1885    
1886                            try {
1887                                    session = openSession();
1888    
1889                                    Query q = session.createQuery(sql);
1890    
1891                                    QueryPos qPos = QueryPos.getInstance(q);
1892    
1893                                    qPos.add(groupId);
1894    
1895                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1896                                                    start, end);
1897                            }
1898                            catch (Exception e) {
1899                                    throw processException(e);
1900                            }
1901                            finally {
1902                                    if (list == null) {
1903                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1904                                    }
1905                                    else {
1906                                            cacheResult(list);
1907    
1908                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1909                                    }
1910    
1911                                    closeSession(session);
1912                            }
1913                    }
1914    
1915                    return list;
1916            }
1917    
1918            /**
1919             * Returns the first d d m structure in the ordered set where groupId = &#63;.
1920             *
1921             * @param groupId the group ID
1922             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1923             * @return the first matching d d m structure
1924             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1925             * @throws SystemException if a system exception occurred
1926             */
1927            public DDMStructure findByGroupId_First(long groupId,
1928                    OrderByComparator orderByComparator)
1929                    throws NoSuchStructureException, SystemException {
1930                    DDMStructure ddmStructure = fetchByGroupId_First(groupId,
1931                                    orderByComparator);
1932    
1933                    if (ddmStructure != null) {
1934                            return ddmStructure;
1935                    }
1936    
1937                    StringBundler msg = new StringBundler(4);
1938    
1939                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1940    
1941                    msg.append("groupId=");
1942                    msg.append(groupId);
1943    
1944                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1945    
1946                    throw new NoSuchStructureException(msg.toString());
1947            }
1948    
1949            /**
1950             * Returns the first d d m structure in the ordered set where groupId = &#63;.
1951             *
1952             * @param groupId the group ID
1953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1954             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1955             * @throws SystemException if a system exception occurred
1956             */
1957            public DDMStructure fetchByGroupId_First(long groupId,
1958                    OrderByComparator orderByComparator) throws SystemException {
1959                    List<DDMStructure> list = findByGroupId(groupId, 0, 1, orderByComparator);
1960    
1961                    if (!list.isEmpty()) {
1962                            return list.get(0);
1963                    }
1964    
1965                    return null;
1966            }
1967    
1968            /**
1969             * Returns the last d d m structure in the ordered set where groupId = &#63;.
1970             *
1971             * @param groupId the group ID
1972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1973             * @return the last matching d d m structure
1974             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1975             * @throws SystemException if a system exception occurred
1976             */
1977            public DDMStructure findByGroupId_Last(long groupId,
1978                    OrderByComparator orderByComparator)
1979                    throws NoSuchStructureException, SystemException {
1980                    DDMStructure ddmStructure = fetchByGroupId_Last(groupId,
1981                                    orderByComparator);
1982    
1983                    if (ddmStructure != null) {
1984                            return ddmStructure;
1985                    }
1986    
1987                    StringBundler msg = new StringBundler(4);
1988    
1989                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1990    
1991                    msg.append("groupId=");
1992                    msg.append(groupId);
1993    
1994                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1995    
1996                    throw new NoSuchStructureException(msg.toString());
1997            }
1998    
1999            /**
2000             * Returns the last d d m structure in the ordered set where groupId = &#63;.
2001             *
2002             * @param groupId the group ID
2003             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2004             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
2005             * @throws SystemException if a system exception occurred
2006             */
2007            public DDMStructure fetchByGroupId_Last(long groupId,
2008                    OrderByComparator orderByComparator) throws SystemException {
2009                    int count = countByGroupId(groupId);
2010    
2011                    List<DDMStructure> list = findByGroupId(groupId, count - 1, count,
2012                                    orderByComparator);
2013    
2014                    if (!list.isEmpty()) {
2015                            return list.get(0);
2016                    }
2017    
2018                    return null;
2019            }
2020    
2021            /**
2022             * Returns the d d m structures before and after the current d d m structure in the ordered set where groupId = &#63;.
2023             *
2024             * @param structureId the primary key of the current d d m structure
2025             * @param groupId the group ID
2026             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2027             * @return the previous, current, and next d d m structure
2028             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
2029             * @throws SystemException if a system exception occurred
2030             */
2031            public DDMStructure[] findByGroupId_PrevAndNext(long structureId,
2032                    long groupId, OrderByComparator orderByComparator)
2033                    throws NoSuchStructureException, SystemException {
2034                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
2035    
2036                    Session session = null;
2037    
2038                    try {
2039                            session = openSession();
2040    
2041                            DDMStructure[] array = new DDMStructureImpl[3];
2042    
2043                            array[0] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
2044                                            orderByComparator, true);
2045    
2046                            array[1] = ddmStructure;
2047    
2048                            array[2] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
2049                                            orderByComparator, false);
2050    
2051                            return array;
2052                    }
2053                    catch (Exception e) {
2054                            throw processException(e);
2055                    }
2056                    finally {
2057                            closeSession(session);
2058                    }
2059            }
2060    
2061            protected DDMStructure getByGroupId_PrevAndNext(Session session,
2062                    DDMStructure ddmStructure, long groupId,
2063                    OrderByComparator orderByComparator, boolean previous) {
2064                    StringBundler query = null;
2065    
2066                    if (orderByComparator != null) {
2067                            query = new StringBundler(6 +
2068                                            (orderByComparator.getOrderByFields().length * 6));
2069                    }
2070                    else {
2071                            query = new StringBundler(3);
2072                    }
2073    
2074                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2075    
2076                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2077    
2078                    if (orderByComparator != null) {
2079                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2080    
2081                            if (orderByConditionFields.length > 0) {
2082                                    query.append(WHERE_AND);
2083                            }
2084    
2085                            for (int i = 0; i < orderByConditionFields.length; i++) {
2086                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2087                                    query.append(orderByConditionFields[i]);
2088    
2089                                    if ((i + 1) < orderByConditionFields.length) {
2090                                            if (orderByComparator.isAscending() ^ previous) {
2091                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2092                                            }
2093                                            else {
2094                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2095                                            }
2096                                    }
2097                                    else {
2098                                            if (orderByComparator.isAscending() ^ previous) {
2099                                                    query.append(WHERE_GREATER_THAN);
2100                                            }
2101                                            else {
2102                                                    query.append(WHERE_LESSER_THAN);
2103                                            }
2104                                    }
2105                            }
2106    
2107                            query.append(ORDER_BY_CLAUSE);
2108    
2109                            String[] orderByFields = orderByComparator.getOrderByFields();
2110    
2111                            for (int i = 0; i < orderByFields.length; i++) {
2112                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2113                                    query.append(orderByFields[i]);
2114    
2115                                    if ((i + 1) < orderByFields.length) {
2116                                            if (orderByComparator.isAscending() ^ previous) {
2117                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2118                                            }
2119                                            else {
2120                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2121                                            }
2122                                    }
2123                                    else {
2124                                            if (orderByComparator.isAscending() ^ previous) {
2125                                                    query.append(ORDER_BY_ASC);
2126                                            }
2127                                            else {
2128                                                    query.append(ORDER_BY_DESC);
2129                                            }
2130                                    }
2131                            }
2132                    }
2133    
2134                    String sql = query.toString();
2135    
2136                    Query q = session.createQuery(sql);
2137    
2138                    q.setFirstResult(0);
2139                    q.setMaxResults(2);
2140    
2141                    QueryPos qPos = QueryPos.getInstance(q);
2142    
2143                    qPos.add(groupId);
2144    
2145                    if (orderByComparator != null) {
2146                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2147    
2148                            for (Object value : values) {
2149                                    qPos.add(value);
2150                            }
2151                    }
2152    
2153                    List<DDMStructure> list = q.list();
2154    
2155                    if (list.size() == 2) {
2156                            return list.get(1);
2157                    }
2158                    else {
2159                            return null;
2160                    }
2161            }
2162    
2163            /**
2164             * Returns all the d d m structures where groupId = any &#63;.
2165             *
2166             * <p>
2167             * 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.
2168             * </p>
2169             *
2170             * @param groupIds the group IDs
2171             * @return the matching d d m structures
2172             * @throws SystemException if a system exception occurred
2173             */
2174            public List<DDMStructure> findByGroupId(long[] groupIds)
2175                    throws SystemException {
2176                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2177                            null);
2178            }
2179    
2180            /**
2181             * Returns a range of all the d d m structures where groupId = any &#63;.
2182             *
2183             * <p>
2184             * 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.
2185             * </p>
2186             *
2187             * @param groupIds the group IDs
2188             * @param start the lower bound of the range of d d m structures
2189             * @param end the upper bound of the range of d d m structures (not inclusive)
2190             * @return the range of matching d d m structures
2191             * @throws SystemException if a system exception occurred
2192             */
2193            public List<DDMStructure> findByGroupId(long[] groupIds, int start, int end)
2194                    throws SystemException {
2195                    return findByGroupId(groupIds, start, end, null);
2196            }
2197    
2198            /**
2199             * Returns an ordered range of all the d d m structures where groupId = any &#63;.
2200             *
2201             * <p>
2202             * 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.
2203             * </p>
2204             *
2205             * @param groupIds the group IDs
2206             * @param start the lower bound of the range of d d m structures
2207             * @param end the upper bound of the range of d d m structures (not inclusive)
2208             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2209             * @return the ordered range of matching d d m structures
2210             * @throws SystemException if a system exception occurred
2211             */
2212            public List<DDMStructure> findByGroupId(long[] groupIds, int start,
2213                    int end, OrderByComparator orderByComparator) throws SystemException {
2214                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2215                    Object[] finderArgs = null;
2216    
2217                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2218                                    (orderByComparator == null)) {
2219                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
2220                    }
2221                    else {
2222                            finderArgs = new Object[] {
2223                                            StringUtil.merge(groupIds),
2224                                            
2225                                            start, end, orderByComparator
2226                                    };
2227                    }
2228    
2229                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
2230                                    finderArgs, this);
2231    
2232                    if ((list != null) && !list.isEmpty()) {
2233                            for (DDMStructure ddmStructure : list) {
2234                                    if (!ArrayUtil.contains(groupIds, ddmStructure.getGroupId())) {
2235                                            list = null;
2236    
2237                                            break;
2238                                    }
2239                            }
2240                    }
2241    
2242                    if (list == null) {
2243                            StringBundler query = new StringBundler();
2244    
2245                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2246    
2247                            boolean conjunctionable = false;
2248    
2249                            if ((groupIds == null) || (groupIds.length > 0)) {
2250                                    if (conjunctionable) {
2251                                            query.append(WHERE_AND);
2252                                    }
2253    
2254                                    query.append(StringPool.OPEN_PARENTHESIS);
2255    
2256                                    for (int i = 0; i < groupIds.length; i++) {
2257                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2258    
2259                                            if ((i + 1) < groupIds.length) {
2260                                                    query.append(WHERE_OR);
2261                                            }
2262                                    }
2263    
2264                                    query.append(StringPool.CLOSE_PARENTHESIS);
2265    
2266                                    conjunctionable = true;
2267                            }
2268    
2269                            if (orderByComparator != null) {
2270                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2271                                            orderByComparator);
2272                            }
2273    
2274                            String sql = query.toString();
2275    
2276                            Session session = null;
2277    
2278                            try {
2279                                    session = openSession();
2280    
2281                                    Query q = session.createQuery(sql);
2282    
2283                                    QueryPos qPos = QueryPos.getInstance(q);
2284    
2285                                    if (groupIds != null) {
2286                                            qPos.add(groupIds);
2287                                    }
2288    
2289                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2290                                                    start, end);
2291                            }
2292                            catch (Exception e) {
2293                                    throw processException(e);
2294                            }
2295                            finally {
2296                                    if (list == null) {
2297                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2298                                    }
2299                                    else {
2300                                            cacheResult(list);
2301    
2302                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2303                                    }
2304    
2305                                    closeSession(session);
2306                            }
2307                    }
2308    
2309                    return list;
2310            }
2311    
2312            /**
2313             * Returns all the d d m structures that the user has permission to view where groupId = &#63;.
2314             *
2315             * @param groupId the group ID
2316             * @return the matching d d m structures that the user has permission to view
2317             * @throws SystemException if a system exception occurred
2318             */
2319            public List<DDMStructure> filterFindByGroupId(long groupId)
2320                    throws SystemException {
2321                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2322                            QueryUtil.ALL_POS, null);
2323            }
2324    
2325            /**
2326             * Returns a range of all the d d m structures that the user has permission to view where groupId = &#63;.
2327             *
2328             * <p>
2329             * 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.
2330             * </p>
2331             *
2332             * @param groupId the group ID
2333             * @param start the lower bound of the range of d d m structures
2334             * @param end the upper bound of the range of d d m structures (not inclusive)
2335             * @return the range of matching d d m structures that the user has permission to view
2336             * @throws SystemException if a system exception occurred
2337             */
2338            public List<DDMStructure> filterFindByGroupId(long groupId, int start,
2339                    int end) throws SystemException {
2340                    return filterFindByGroupId(groupId, start, end, null);
2341            }
2342    
2343            /**
2344             * Returns an ordered range of all the d d m structures that the user has permissions to view where groupId = &#63;.
2345             *
2346             * <p>
2347             * 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.
2348             * </p>
2349             *
2350             * @param groupId the group ID
2351             * @param start the lower bound of the range of d d m structures
2352             * @param end the upper bound of the range of d d m structures (not inclusive)
2353             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2354             * @return the ordered range of matching d d m structures that the user has permission to view
2355             * @throws SystemException if a system exception occurred
2356             */
2357            public List<DDMStructure> filterFindByGroupId(long groupId, int start,
2358                    int end, OrderByComparator orderByComparator) throws SystemException {
2359                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2360                            return findByGroupId(groupId, start, end, orderByComparator);
2361                    }
2362    
2363                    StringBundler query = null;
2364    
2365                    if (orderByComparator != null) {
2366                            query = new StringBundler(3 +
2367                                            (orderByComparator.getOrderByFields().length * 3));
2368                    }
2369                    else {
2370                            query = new StringBundler(2);
2371                    }
2372    
2373                    if (getDB().isSupportsInlineDistinct()) {
2374                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
2375                    }
2376                    else {
2377                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
2378                    }
2379    
2380                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2381    
2382                    if (!getDB().isSupportsInlineDistinct()) {
2383                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
2384                    }
2385    
2386                    if (orderByComparator != null) {
2387                            if (getDB().isSupportsInlineDistinct()) {
2388                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2389                                            orderByComparator);
2390                            }
2391                            else {
2392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2393                                            orderByComparator);
2394                            }
2395                    }
2396    
2397                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2398                                    DDMStructure.class.getName(),
2399                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2400    
2401                    Session session = null;
2402    
2403                    try {
2404                            session = openSession();
2405    
2406                            SQLQuery q = session.createSQLQuery(sql);
2407    
2408                            if (getDB().isSupportsInlineDistinct()) {
2409                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
2410                            }
2411                            else {
2412                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2413                            }
2414    
2415                            QueryPos qPos = QueryPos.getInstance(q);
2416    
2417                            qPos.add(groupId);
2418    
2419                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
2420                                    end);
2421                    }
2422                    catch (Exception e) {
2423                            throw processException(e);
2424                    }
2425                    finally {
2426                            closeSession(session);
2427                    }
2428            }
2429    
2430            /**
2431             * Returns the d d m structures before and after the current d d m structure in the ordered set of d d m structures that the user has permission to view where groupId = &#63;.
2432             *
2433             * @param structureId the primary key of the current d d m structure
2434             * @param groupId the group ID
2435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2436             * @return the previous, current, and next d d m structure
2437             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
2438             * @throws SystemException if a system exception occurred
2439             */
2440            public DDMStructure[] filterFindByGroupId_PrevAndNext(long structureId,
2441                    long groupId, OrderByComparator orderByComparator)
2442                    throws NoSuchStructureException, SystemException {
2443                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2444                            return findByGroupId_PrevAndNext(structureId, groupId,
2445                                    orderByComparator);
2446                    }
2447    
2448                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
2449    
2450                    Session session = null;
2451    
2452                    try {
2453                            session = openSession();
2454    
2455                            DDMStructure[] array = new DDMStructureImpl[3];
2456    
2457                            array[0] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
2458                                            groupId, orderByComparator, true);
2459    
2460                            array[1] = ddmStructure;
2461    
2462                            array[2] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
2463                                            groupId, orderByComparator, false);
2464    
2465                            return array;
2466                    }
2467                    catch (Exception e) {
2468                            throw processException(e);
2469                    }
2470                    finally {
2471                            closeSession(session);
2472                    }
2473            }
2474    
2475            protected DDMStructure filterGetByGroupId_PrevAndNext(Session session,
2476                    DDMStructure ddmStructure, long groupId,
2477                    OrderByComparator orderByComparator, boolean previous) {
2478                    StringBundler query = null;
2479    
2480                    if (orderByComparator != null) {
2481                            query = new StringBundler(6 +
2482                                            (orderByComparator.getOrderByFields().length * 6));
2483                    }
2484                    else {
2485                            query = new StringBundler(3);
2486                    }
2487    
2488                    if (getDB().isSupportsInlineDistinct()) {
2489                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
2490                    }
2491                    else {
2492                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
2493                    }
2494    
2495                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2496    
2497                    if (!getDB().isSupportsInlineDistinct()) {
2498                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
2499                    }
2500    
2501                    if (orderByComparator != null) {
2502                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2503    
2504                            if (orderByConditionFields.length > 0) {
2505                                    query.append(WHERE_AND);
2506                            }
2507    
2508                            for (int i = 0; i < orderByConditionFields.length; i++) {
2509                                    if (getDB().isSupportsInlineDistinct()) {
2510                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2511                                    }
2512                                    else {
2513                                            query.append(_ORDER_BY_ENTITY_TABLE);
2514                                    }
2515    
2516                                    query.append(orderByConditionFields[i]);
2517    
2518                                    if ((i + 1) < orderByConditionFields.length) {
2519                                            if (orderByComparator.isAscending() ^ previous) {
2520                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2521                                            }
2522                                            else {
2523                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2524                                            }
2525                                    }
2526                                    else {
2527                                            if (orderByComparator.isAscending() ^ previous) {
2528                                                    query.append(WHERE_GREATER_THAN);
2529                                            }
2530                                            else {
2531                                                    query.append(WHERE_LESSER_THAN);
2532                                            }
2533                                    }
2534                            }
2535    
2536                            query.append(ORDER_BY_CLAUSE);
2537    
2538                            String[] orderByFields = orderByComparator.getOrderByFields();
2539    
2540                            for (int i = 0; i < orderByFields.length; i++) {
2541                                    if (getDB().isSupportsInlineDistinct()) {
2542                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2543                                    }
2544                                    else {
2545                                            query.append(_ORDER_BY_ENTITY_TABLE);
2546                                    }
2547    
2548                                    query.append(orderByFields[i]);
2549    
2550                                    if ((i + 1) < orderByFields.length) {
2551                                            if (orderByComparator.isAscending() ^ previous) {
2552                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2553                                            }
2554                                            else {
2555                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2556                                            }
2557                                    }
2558                                    else {
2559                                            if (orderByComparator.isAscending() ^ previous) {
2560                                                    query.append(ORDER_BY_ASC);
2561                                            }
2562                                            else {
2563                                                    query.append(ORDER_BY_DESC);
2564                                            }
2565                                    }
2566                            }
2567                    }
2568    
2569                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2570                                    DDMStructure.class.getName(),
2571                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2572    
2573                    SQLQuery q = session.createSQLQuery(sql);
2574    
2575                    q.setFirstResult(0);
2576                    q.setMaxResults(2);
2577    
2578                    if (getDB().isSupportsInlineDistinct()) {
2579                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
2580                    }
2581                    else {
2582                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2583                    }
2584    
2585                    QueryPos qPos = QueryPos.getInstance(q);
2586    
2587                    qPos.add(groupId);
2588    
2589                    if (orderByComparator != null) {
2590                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2591    
2592                            for (Object value : values) {
2593                                    qPos.add(value);
2594                            }
2595                    }
2596    
2597                    List<DDMStructure> list = q.list();
2598    
2599                    if (list.size() == 2) {
2600                            return list.get(1);
2601                    }
2602                    else {
2603                            return null;
2604                    }
2605            }
2606    
2607            /**
2608             * Returns all the d d m structures that the user has permission to view where groupId = any &#63;.
2609             *
2610             * @param groupIds the group IDs
2611             * @return the matching d d m structures that the user has permission to view
2612             * @throws SystemException if a system exception occurred
2613             */
2614            public List<DDMStructure> filterFindByGroupId(long[] groupIds)
2615                    throws SystemException {
2616                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2617                            QueryUtil.ALL_POS, null);
2618            }
2619    
2620            /**
2621             * Returns a range of all the d d m structures that the user has permission to view where groupId = any &#63;.
2622             *
2623             * <p>
2624             * 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.
2625             * </p>
2626             *
2627             * @param groupIds the group IDs
2628             * @param start the lower bound of the range of d d m structures
2629             * @param end the upper bound of the range of d d m structures (not inclusive)
2630             * @return the range of matching d d m structures that the user has permission to view
2631             * @throws SystemException if a system exception occurred
2632             */
2633            public List<DDMStructure> filterFindByGroupId(long[] groupIds, int start,
2634                    int end) throws SystemException {
2635                    return filterFindByGroupId(groupIds, start, end, null);
2636            }
2637    
2638            /**
2639             * Returns an ordered range of all the d d m structures that the user has permission to view where groupId = any &#63;.
2640             *
2641             * <p>
2642             * 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.
2643             * </p>
2644             *
2645             * @param groupIds the group IDs
2646             * @param start the lower bound of the range of d d m structures
2647             * @param end the upper bound of the range of d d m structures (not inclusive)
2648             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2649             * @return the ordered range of matching d d m structures that the user has permission to view
2650             * @throws SystemException if a system exception occurred
2651             */
2652            public List<DDMStructure> filterFindByGroupId(long[] groupIds, int start,
2653                    int end, OrderByComparator orderByComparator) throws SystemException {
2654                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2655                            return findByGroupId(groupIds, start, end, orderByComparator);
2656                    }
2657    
2658                    StringBundler query = new StringBundler();
2659    
2660                    if (getDB().isSupportsInlineDistinct()) {
2661                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
2662                    }
2663                    else {
2664                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
2665                    }
2666    
2667                    boolean conjunctionable = false;
2668    
2669                    if ((groupIds == null) || (groupIds.length > 0)) {
2670                            if (conjunctionable) {
2671                                    query.append(WHERE_AND);
2672                            }
2673    
2674                            query.append(StringPool.OPEN_PARENTHESIS);
2675    
2676                            for (int i = 0; i < groupIds.length; i++) {
2677                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2678    
2679                                    if ((i + 1) < groupIds.length) {
2680                                            query.append(WHERE_OR);
2681                                    }
2682                            }
2683    
2684                            query.append(StringPool.CLOSE_PARENTHESIS);
2685    
2686                            conjunctionable = true;
2687                    }
2688    
2689                    if (!getDB().isSupportsInlineDistinct()) {
2690                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
2691                    }
2692    
2693                    if (orderByComparator != null) {
2694                            if (getDB().isSupportsInlineDistinct()) {
2695                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2696                                            orderByComparator);
2697                            }
2698                            else {
2699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2700                                            orderByComparator);
2701                            }
2702                    }
2703    
2704                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2705                                    DDMStructure.class.getName(),
2706                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2707    
2708                    Session session = null;
2709    
2710                    try {
2711                            session = openSession();
2712    
2713                            SQLQuery q = session.createSQLQuery(sql);
2714    
2715                            if (getDB().isSupportsInlineDistinct()) {
2716                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
2717                            }
2718                            else {
2719                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2720                            }
2721    
2722                            QueryPos qPos = QueryPos.getInstance(q);
2723    
2724                            if (groupIds != null) {
2725                                    qPos.add(groupIds);
2726                            }
2727    
2728                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
2729                                    end);
2730                    }
2731                    catch (Exception e) {
2732                            throw processException(e);
2733                    }
2734                    finally {
2735                            closeSession(session);
2736                    }
2737            }
2738    
2739            /**
2740             * Returns all the d d m structures where classNameId = &#63;.
2741             *
2742             * @param classNameId the class name ID
2743             * @return the matching d d m structures
2744             * @throws SystemException if a system exception occurred
2745             */
2746            public List<DDMStructure> findByClassNameId(long classNameId)
2747                    throws SystemException {
2748                    return findByClassNameId(classNameId, QueryUtil.ALL_POS,
2749                            QueryUtil.ALL_POS, null);
2750            }
2751    
2752            /**
2753             * Returns a range of all the d d m structures where classNameId = &#63;.
2754             *
2755             * <p>
2756             * 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.
2757             * </p>
2758             *
2759             * @param classNameId the class name ID
2760             * @param start the lower bound of the range of d d m structures
2761             * @param end the upper bound of the range of d d m structures (not inclusive)
2762             * @return the range of matching d d m structures
2763             * @throws SystemException if a system exception occurred
2764             */
2765            public List<DDMStructure> findByClassNameId(long classNameId, int start,
2766                    int end) throws SystemException {
2767                    return findByClassNameId(classNameId, start, end, null);
2768            }
2769    
2770            /**
2771             * Returns an ordered range of all the d d m structures where classNameId = &#63;.
2772             *
2773             * <p>
2774             * 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.
2775             * </p>
2776             *
2777             * @param classNameId the class name ID
2778             * @param start the lower bound of the range of d d m structures
2779             * @param end the upper bound of the range of d d m structures (not inclusive)
2780             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2781             * @return the ordered range of matching d d m structures
2782             * @throws SystemException if a system exception occurred
2783             */
2784            public List<DDMStructure> findByClassNameId(long classNameId, int start,
2785                    int end, OrderByComparator orderByComparator) throws SystemException {
2786                    FinderPath finderPath = null;
2787                    Object[] finderArgs = null;
2788    
2789                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2790                                    (orderByComparator == null)) {
2791                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
2792                            finderArgs = new Object[] { classNameId };
2793                    }
2794                    else {
2795                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
2796                            finderArgs = new Object[] { classNameId, start, end, orderByComparator };
2797                    }
2798    
2799                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
2800                                    finderArgs, this);
2801    
2802                    if ((list != null) && !list.isEmpty()) {
2803                            for (DDMStructure ddmStructure : list) {
2804                                    if ((classNameId != ddmStructure.getClassNameId())) {
2805                                            list = null;
2806    
2807                                            break;
2808                                    }
2809                            }
2810                    }
2811    
2812                    if (list == null) {
2813                            StringBundler query = null;
2814    
2815                            if (orderByComparator != null) {
2816                                    query = new StringBundler(3 +
2817                                                    (orderByComparator.getOrderByFields().length * 3));
2818                            }
2819                            else {
2820                                    query = new StringBundler(2);
2821                            }
2822    
2823                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2824    
2825                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
2826    
2827                            if (orderByComparator != null) {
2828                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2829                                            orderByComparator);
2830                            }
2831    
2832                            String sql = query.toString();
2833    
2834                            Session session = null;
2835    
2836                            try {
2837                                    session = openSession();
2838    
2839                                    Query q = session.createQuery(sql);
2840    
2841                                    QueryPos qPos = QueryPos.getInstance(q);
2842    
2843                                    qPos.add(classNameId);
2844    
2845                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2846                                                    start, end);
2847                            }
2848                            catch (Exception e) {
2849                                    throw processException(e);
2850                            }
2851                            finally {
2852                                    if (list == null) {
2853                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2854                                    }
2855                                    else {
2856                                            cacheResult(list);
2857    
2858                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2859                                    }
2860    
2861                                    closeSession(session);
2862                            }
2863                    }
2864    
2865                    return list;
2866            }
2867    
2868            /**
2869             * Returns the first d d m structure in the ordered set where classNameId = &#63;.
2870             *
2871             * @param classNameId the class name ID
2872             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2873             * @return the first matching d d m structure
2874             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
2875             * @throws SystemException if a system exception occurred
2876             */
2877            public DDMStructure findByClassNameId_First(long classNameId,
2878                    OrderByComparator orderByComparator)
2879                    throws NoSuchStructureException, SystemException {
2880                    DDMStructure ddmStructure = fetchByClassNameId_First(classNameId,
2881                                    orderByComparator);
2882    
2883                    if (ddmStructure != null) {
2884                            return ddmStructure;
2885                    }
2886    
2887                    StringBundler msg = new StringBundler(4);
2888    
2889                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2890    
2891                    msg.append("classNameId=");
2892                    msg.append(classNameId);
2893    
2894                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2895    
2896                    throw new NoSuchStructureException(msg.toString());
2897            }
2898    
2899            /**
2900             * Returns the first d d m structure in the ordered set where classNameId = &#63;.
2901             *
2902             * @param classNameId the class name ID
2903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2904             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
2905             * @throws SystemException if a system exception occurred
2906             */
2907            public DDMStructure fetchByClassNameId_First(long classNameId,
2908                    OrderByComparator orderByComparator) throws SystemException {
2909                    List<DDMStructure> list = findByClassNameId(classNameId, 0, 1,
2910                                    orderByComparator);
2911    
2912                    if (!list.isEmpty()) {
2913                            return list.get(0);
2914                    }
2915    
2916                    return null;
2917            }
2918    
2919            /**
2920             * Returns the last d d m structure in the ordered set where classNameId = &#63;.
2921             *
2922             * @param classNameId the class name ID
2923             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2924             * @return the last matching d d m structure
2925             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
2926             * @throws SystemException if a system exception occurred
2927             */
2928            public DDMStructure findByClassNameId_Last(long classNameId,
2929                    OrderByComparator orderByComparator)
2930                    throws NoSuchStructureException, SystemException {
2931                    DDMStructure ddmStructure = fetchByClassNameId_Last(classNameId,
2932                                    orderByComparator);
2933    
2934                    if (ddmStructure != null) {
2935                            return ddmStructure;
2936                    }
2937    
2938                    StringBundler msg = new StringBundler(4);
2939    
2940                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2941    
2942                    msg.append("classNameId=");
2943                    msg.append(classNameId);
2944    
2945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2946    
2947                    throw new NoSuchStructureException(msg.toString());
2948            }
2949    
2950            /**
2951             * Returns the last d d m structure in the ordered set where classNameId = &#63;.
2952             *
2953             * @param classNameId the class name ID
2954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2955             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
2956             * @throws SystemException if a system exception occurred
2957             */
2958            public DDMStructure fetchByClassNameId_Last(long classNameId,
2959                    OrderByComparator orderByComparator) throws SystemException {
2960                    int count = countByClassNameId(classNameId);
2961    
2962                    List<DDMStructure> list = findByClassNameId(classNameId, count - 1,
2963                                    count, orderByComparator);
2964    
2965                    if (!list.isEmpty()) {
2966                            return list.get(0);
2967                    }
2968    
2969                    return null;
2970            }
2971    
2972            /**
2973             * Returns the d d m structures before and after the current d d m structure in the ordered set where classNameId = &#63;.
2974             *
2975             * @param structureId the primary key of the current d d m structure
2976             * @param classNameId the class name ID
2977             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2978             * @return the previous, current, and next d d m structure
2979             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
2980             * @throws SystemException if a system exception occurred
2981             */
2982            public DDMStructure[] findByClassNameId_PrevAndNext(long structureId,
2983                    long classNameId, OrderByComparator orderByComparator)
2984                    throws NoSuchStructureException, SystemException {
2985                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
2986    
2987                    Session session = null;
2988    
2989                    try {
2990                            session = openSession();
2991    
2992                            DDMStructure[] array = new DDMStructureImpl[3];
2993    
2994                            array[0] = getByClassNameId_PrevAndNext(session, ddmStructure,
2995                                            classNameId, orderByComparator, true);
2996    
2997                            array[1] = ddmStructure;
2998    
2999                            array[2] = getByClassNameId_PrevAndNext(session, ddmStructure,
3000                                            classNameId, orderByComparator, false);
3001    
3002                            return array;
3003                    }
3004                    catch (Exception e) {
3005                            throw processException(e);
3006                    }
3007                    finally {
3008                            closeSession(session);
3009                    }
3010            }
3011    
3012            protected DDMStructure getByClassNameId_PrevAndNext(Session session,
3013                    DDMStructure ddmStructure, long classNameId,
3014                    OrderByComparator orderByComparator, boolean previous) {
3015                    StringBundler query = null;
3016    
3017                    if (orderByComparator != null) {
3018                            query = new StringBundler(6 +
3019                                            (orderByComparator.getOrderByFields().length * 6));
3020                    }
3021                    else {
3022                            query = new StringBundler(3);
3023                    }
3024    
3025                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3026    
3027                    query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
3028    
3029                    if (orderByComparator != null) {
3030                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3031    
3032                            if (orderByConditionFields.length > 0) {
3033                                    query.append(WHERE_AND);
3034                            }
3035    
3036                            for (int i = 0; i < orderByConditionFields.length; i++) {
3037                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3038                                    query.append(orderByConditionFields[i]);
3039    
3040                                    if ((i + 1) < orderByConditionFields.length) {
3041                                            if (orderByComparator.isAscending() ^ previous) {
3042                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3043                                            }
3044                                            else {
3045                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3046                                            }
3047                                    }
3048                                    else {
3049                                            if (orderByComparator.isAscending() ^ previous) {
3050                                                    query.append(WHERE_GREATER_THAN);
3051                                            }
3052                                            else {
3053                                                    query.append(WHERE_LESSER_THAN);
3054                                            }
3055                                    }
3056                            }
3057    
3058                            query.append(ORDER_BY_CLAUSE);
3059    
3060                            String[] orderByFields = orderByComparator.getOrderByFields();
3061    
3062                            for (int i = 0; i < orderByFields.length; i++) {
3063                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3064                                    query.append(orderByFields[i]);
3065    
3066                                    if ((i + 1) < orderByFields.length) {
3067                                            if (orderByComparator.isAscending() ^ previous) {
3068                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3069                                            }
3070                                            else {
3071                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3072                                            }
3073                                    }
3074                                    else {
3075                                            if (orderByComparator.isAscending() ^ previous) {
3076                                                    query.append(ORDER_BY_ASC);
3077                                            }
3078                                            else {
3079                                                    query.append(ORDER_BY_DESC);
3080                                            }
3081                                    }
3082                            }
3083                    }
3084    
3085                    String sql = query.toString();
3086    
3087                    Query q = session.createQuery(sql);
3088    
3089                    q.setFirstResult(0);
3090                    q.setMaxResults(2);
3091    
3092                    QueryPos qPos = QueryPos.getInstance(q);
3093    
3094                    qPos.add(classNameId);
3095    
3096                    if (orderByComparator != null) {
3097                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3098    
3099                            for (Object value : values) {
3100                                    qPos.add(value);
3101                            }
3102                    }
3103    
3104                    List<DDMStructure> list = q.list();
3105    
3106                    if (list.size() == 2) {
3107                            return list.get(1);
3108                    }
3109                    else {
3110                            return null;
3111                    }
3112            }
3113    
3114            /**
3115             * Returns the d d m structure where groupId = &#63; and structureKey = &#63; or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStructureException} if it could not be found.
3116             *
3117             * @param groupId the group ID
3118             * @param structureKey the structure key
3119             * @return the matching d d m structure
3120             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3121             * @throws SystemException if a system exception occurred
3122             */
3123            public DDMStructure findByG_S(long groupId, String structureKey)
3124                    throws NoSuchStructureException, SystemException {
3125                    DDMStructure ddmStructure = fetchByG_S(groupId, structureKey);
3126    
3127                    if (ddmStructure == null) {
3128                            StringBundler msg = new StringBundler(6);
3129    
3130                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3131    
3132                            msg.append("groupId=");
3133                            msg.append(groupId);
3134    
3135                            msg.append(", structureKey=");
3136                            msg.append(structureKey);
3137    
3138                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3139    
3140                            if (_log.isWarnEnabled()) {
3141                                    _log.warn(msg.toString());
3142                            }
3143    
3144                            throw new NoSuchStructureException(msg.toString());
3145                    }
3146    
3147                    return ddmStructure;
3148            }
3149    
3150            /**
3151             * Returns the d d m structure where groupId = &#63; and structureKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3152             *
3153             * @param groupId the group ID
3154             * @param structureKey the structure key
3155             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3156             * @throws SystemException if a system exception occurred
3157             */
3158            public DDMStructure fetchByG_S(long groupId, String structureKey)
3159                    throws SystemException {
3160                    return fetchByG_S(groupId, structureKey, true);
3161            }
3162    
3163            /**
3164             * Returns the d d m structure where groupId = &#63; and structureKey = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3165             *
3166             * @param groupId the group ID
3167             * @param structureKey the structure key
3168             * @param retrieveFromCache whether to use the finder cache
3169             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3170             * @throws SystemException if a system exception occurred
3171             */
3172            public DDMStructure fetchByG_S(long groupId, String structureKey,
3173                    boolean retrieveFromCache) throws SystemException {
3174                    Object[] finderArgs = new Object[] { groupId, structureKey };
3175    
3176                    Object result = null;
3177    
3178                    if (retrieveFromCache) {
3179                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
3180                                            finderArgs, this);
3181                    }
3182    
3183                    if (result instanceof DDMStructure) {
3184                            DDMStructure ddmStructure = (DDMStructure)result;
3185    
3186                            if ((groupId != ddmStructure.getGroupId()) ||
3187                                            !Validator.equals(structureKey,
3188                                                    ddmStructure.getStructureKey())) {
3189                                    result = null;
3190                            }
3191                    }
3192    
3193                    if (result == null) {
3194                            StringBundler query = new StringBundler(3);
3195    
3196                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3197    
3198                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3199    
3200                            if (structureKey == null) {
3201                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_1);
3202                            }
3203                            else {
3204                                    if (structureKey.equals(StringPool.BLANK)) {
3205                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_3);
3206                                    }
3207                                    else {
3208                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_2);
3209                                    }
3210                            }
3211    
3212                            String sql = query.toString();
3213    
3214                            Session session = null;
3215    
3216                            try {
3217                                    session = openSession();
3218    
3219                                    Query q = session.createQuery(sql);
3220    
3221                                    QueryPos qPos = QueryPos.getInstance(q);
3222    
3223                                    qPos.add(groupId);
3224    
3225                                    if (structureKey != null) {
3226                                            qPos.add(structureKey);
3227                                    }
3228    
3229                                    List<DDMStructure> list = q.list();
3230    
3231                                    result = list;
3232    
3233                                    DDMStructure ddmStructure = null;
3234    
3235                                    if (list.isEmpty()) {
3236                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
3237                                                    finderArgs, list);
3238                                    }
3239                                    else {
3240                                            ddmStructure = list.get(0);
3241    
3242                                            cacheResult(ddmStructure);
3243    
3244                                            if ((ddmStructure.getGroupId() != groupId) ||
3245                                                            (ddmStructure.getStructureKey() == null) ||
3246                                                            !ddmStructure.getStructureKey().equals(structureKey)) {
3247                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
3248                                                            finderArgs, ddmStructure);
3249                                            }
3250                                    }
3251    
3252                                    return ddmStructure;
3253                            }
3254                            catch (Exception e) {
3255                                    throw processException(e);
3256                            }
3257                            finally {
3258                                    if (result == null) {
3259                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
3260                                                    finderArgs);
3261                                    }
3262    
3263                                    closeSession(session);
3264                            }
3265                    }
3266                    else {
3267                            if (result instanceof List<?>) {
3268                                    return null;
3269                            }
3270                            else {
3271                                    return (DDMStructure)result;
3272                            }
3273                    }
3274            }
3275    
3276            /**
3277             * Returns all the d d m structures where companyId = &#63; and classNameId = &#63;.
3278             *
3279             * @param companyId the company ID
3280             * @param classNameId the class name ID
3281             * @return the matching d d m structures
3282             * @throws SystemException if a system exception occurred
3283             */
3284            public List<DDMStructure> findByC_C(long companyId, long classNameId)
3285                    throws SystemException {
3286                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
3287                            QueryUtil.ALL_POS, null);
3288            }
3289    
3290            /**
3291             * Returns a range of all the d d m structures where companyId = &#63; and classNameId = &#63;.
3292             *
3293             * <p>
3294             * 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.
3295             * </p>
3296             *
3297             * @param companyId the company ID
3298             * @param classNameId the class name ID
3299             * @param start the lower bound of the range of d d m structures
3300             * @param end the upper bound of the range of d d m structures (not inclusive)
3301             * @return the range of matching d d m structures
3302             * @throws SystemException if a system exception occurred
3303             */
3304            public List<DDMStructure> findByC_C(long companyId, long classNameId,
3305                    int start, int end) throws SystemException {
3306                    return findByC_C(companyId, classNameId, start, end, null);
3307            }
3308    
3309            /**
3310             * Returns an ordered range of all the d d m structures where companyId = &#63; and classNameId = &#63;.
3311             *
3312             * <p>
3313             * 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.
3314             * </p>
3315             *
3316             * @param companyId the company ID
3317             * @param classNameId the class name ID
3318             * @param start the lower bound of the range of d d m structures
3319             * @param end the upper bound of the range of d d m structures (not inclusive)
3320             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3321             * @return the ordered range of matching d d m structures
3322             * @throws SystemException if a system exception occurred
3323             */
3324            public List<DDMStructure> findByC_C(long companyId, long classNameId,
3325                    int start, int end, OrderByComparator orderByComparator)
3326                    throws SystemException {
3327                    FinderPath finderPath = null;
3328                    Object[] finderArgs = null;
3329    
3330                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3331                                    (orderByComparator == null)) {
3332                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
3333                            finderArgs = new Object[] { companyId, classNameId };
3334                    }
3335                    else {
3336                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
3337                            finderArgs = new Object[] {
3338                                            companyId, classNameId,
3339                                            
3340                                            start, end, orderByComparator
3341                                    };
3342                    }
3343    
3344                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3345                                    finderArgs, this);
3346    
3347                    if ((list != null) && !list.isEmpty()) {
3348                            for (DDMStructure ddmStructure : list) {
3349                                    if ((companyId != ddmStructure.getCompanyId()) ||
3350                                                    (classNameId != ddmStructure.getClassNameId())) {
3351                                            list = null;
3352    
3353                                            break;
3354                                    }
3355                            }
3356                    }
3357    
3358                    if (list == null) {
3359                            StringBundler query = null;
3360    
3361                            if (orderByComparator != null) {
3362                                    query = new StringBundler(4 +
3363                                                    (orderByComparator.getOrderByFields().length * 3));
3364                            }
3365                            else {
3366                                    query = new StringBundler(3);
3367                            }
3368    
3369                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3370    
3371                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
3372    
3373                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3374    
3375                            if (orderByComparator != null) {
3376                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3377                                            orderByComparator);
3378                            }
3379    
3380                            String sql = query.toString();
3381    
3382                            Session session = null;
3383    
3384                            try {
3385                                    session = openSession();
3386    
3387                                    Query q = session.createQuery(sql);
3388    
3389                                    QueryPos qPos = QueryPos.getInstance(q);
3390    
3391                                    qPos.add(companyId);
3392    
3393                                    qPos.add(classNameId);
3394    
3395                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3396                                                    start, end);
3397                            }
3398                            catch (Exception e) {
3399                                    throw processException(e);
3400                            }
3401                            finally {
3402                                    if (list == null) {
3403                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3404                                    }
3405                                    else {
3406                                            cacheResult(list);
3407    
3408                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3409                                    }
3410    
3411                                    closeSession(session);
3412                            }
3413                    }
3414    
3415                    return list;
3416            }
3417    
3418            /**
3419             * Returns the first d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
3420             *
3421             * @param companyId the company ID
3422             * @param classNameId the class name ID
3423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3424             * @return the first matching d d m structure
3425             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3426             * @throws SystemException if a system exception occurred
3427             */
3428            public DDMStructure findByC_C_First(long companyId, long classNameId,
3429                    OrderByComparator orderByComparator)
3430                    throws NoSuchStructureException, SystemException {
3431                    DDMStructure ddmStructure = fetchByC_C_First(companyId, classNameId,
3432                                    orderByComparator);
3433    
3434                    if (ddmStructure != null) {
3435                            return ddmStructure;
3436                    }
3437    
3438                    StringBundler msg = new StringBundler(6);
3439    
3440                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3441    
3442                    msg.append("companyId=");
3443                    msg.append(companyId);
3444    
3445                    msg.append(", classNameId=");
3446                    msg.append(classNameId);
3447    
3448                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3449    
3450                    throw new NoSuchStructureException(msg.toString());
3451            }
3452    
3453            /**
3454             * Returns the first d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
3455             *
3456             * @param companyId the company ID
3457             * @param classNameId the class name ID
3458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3459             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3460             * @throws SystemException if a system exception occurred
3461             */
3462            public DDMStructure fetchByC_C_First(long companyId, long classNameId,
3463                    OrderByComparator orderByComparator) throws SystemException {
3464                    List<DDMStructure> list = findByC_C(companyId, classNameId, 0, 1,
3465                                    orderByComparator);
3466    
3467                    if (!list.isEmpty()) {
3468                            return list.get(0);
3469                    }
3470    
3471                    return null;
3472            }
3473    
3474            /**
3475             * Returns the last d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
3476             *
3477             * @param companyId the company ID
3478             * @param classNameId the class name ID
3479             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3480             * @return the last matching d d m structure
3481             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3482             * @throws SystemException if a system exception occurred
3483             */
3484            public DDMStructure findByC_C_Last(long companyId, long classNameId,
3485                    OrderByComparator orderByComparator)
3486                    throws NoSuchStructureException, SystemException {
3487                    DDMStructure ddmStructure = fetchByC_C_Last(companyId, classNameId,
3488                                    orderByComparator);
3489    
3490                    if (ddmStructure != null) {
3491                            return ddmStructure;
3492                    }
3493    
3494                    StringBundler msg = new StringBundler(6);
3495    
3496                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3497    
3498                    msg.append("companyId=");
3499                    msg.append(companyId);
3500    
3501                    msg.append(", classNameId=");
3502                    msg.append(classNameId);
3503    
3504                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3505    
3506                    throw new NoSuchStructureException(msg.toString());
3507            }
3508    
3509            /**
3510             * Returns the last d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
3511             *
3512             * @param companyId the company ID
3513             * @param classNameId the class name ID
3514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3515             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3516             * @throws SystemException if a system exception occurred
3517             */
3518            public DDMStructure fetchByC_C_Last(long companyId, long classNameId,
3519                    OrderByComparator orderByComparator) throws SystemException {
3520                    int count = countByC_C(companyId, classNameId);
3521    
3522                    List<DDMStructure> list = findByC_C(companyId, classNameId, count - 1,
3523                                    count, orderByComparator);
3524    
3525                    if (!list.isEmpty()) {
3526                            return list.get(0);
3527                    }
3528    
3529                    return null;
3530            }
3531    
3532            /**
3533             * Returns the d d m structures before and after the current d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
3534             *
3535             * @param structureId the primary key of the current d d m structure
3536             * @param companyId the company ID
3537             * @param classNameId the class name ID
3538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3539             * @return the previous, current, and next d d m structure
3540             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
3541             * @throws SystemException if a system exception occurred
3542             */
3543            public DDMStructure[] findByC_C_PrevAndNext(long structureId,
3544                    long companyId, long classNameId, OrderByComparator orderByComparator)
3545                    throws NoSuchStructureException, SystemException {
3546                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
3547    
3548                    Session session = null;
3549    
3550                    try {
3551                            session = openSession();
3552    
3553                            DDMStructure[] array = new DDMStructureImpl[3];
3554    
3555                            array[0] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
3556                                            classNameId, orderByComparator, true);
3557    
3558                            array[1] = ddmStructure;
3559    
3560                            array[2] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
3561                                            classNameId, orderByComparator, false);
3562    
3563                            return array;
3564                    }
3565                    catch (Exception e) {
3566                            throw processException(e);
3567                    }
3568                    finally {
3569                            closeSession(session);
3570                    }
3571            }
3572    
3573            protected DDMStructure getByC_C_PrevAndNext(Session session,
3574                    DDMStructure ddmStructure, long companyId, long classNameId,
3575                    OrderByComparator orderByComparator, boolean previous) {
3576                    StringBundler query = null;
3577    
3578                    if (orderByComparator != null) {
3579                            query = new StringBundler(6 +
3580                                            (orderByComparator.getOrderByFields().length * 6));
3581                    }
3582                    else {
3583                            query = new StringBundler(3);
3584                    }
3585    
3586                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3587    
3588                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
3589    
3590                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3591    
3592                    if (orderByComparator != null) {
3593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3594    
3595                            if (orderByConditionFields.length > 0) {
3596                                    query.append(WHERE_AND);
3597                            }
3598    
3599                            for (int i = 0; i < orderByConditionFields.length; i++) {
3600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3601                                    query.append(orderByConditionFields[i]);
3602    
3603                                    if ((i + 1) < orderByConditionFields.length) {
3604                                            if (orderByComparator.isAscending() ^ previous) {
3605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3606                                            }
3607                                            else {
3608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3609                                            }
3610                                    }
3611                                    else {
3612                                            if (orderByComparator.isAscending() ^ previous) {
3613                                                    query.append(WHERE_GREATER_THAN);
3614                                            }
3615                                            else {
3616                                                    query.append(WHERE_LESSER_THAN);
3617                                            }
3618                                    }
3619                            }
3620    
3621                            query.append(ORDER_BY_CLAUSE);
3622    
3623                            String[] orderByFields = orderByComparator.getOrderByFields();
3624    
3625                            for (int i = 0; i < orderByFields.length; i++) {
3626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3627                                    query.append(orderByFields[i]);
3628    
3629                                    if ((i + 1) < orderByFields.length) {
3630                                            if (orderByComparator.isAscending() ^ previous) {
3631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3632                                            }
3633                                            else {
3634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3635                                            }
3636                                    }
3637                                    else {
3638                                            if (orderByComparator.isAscending() ^ previous) {
3639                                                    query.append(ORDER_BY_ASC);
3640                                            }
3641                                            else {
3642                                                    query.append(ORDER_BY_DESC);
3643                                            }
3644                                    }
3645                            }
3646                    }
3647    
3648                    String sql = query.toString();
3649    
3650                    Query q = session.createQuery(sql);
3651    
3652                    q.setFirstResult(0);
3653                    q.setMaxResults(2);
3654    
3655                    QueryPos qPos = QueryPos.getInstance(q);
3656    
3657                    qPos.add(companyId);
3658    
3659                    qPos.add(classNameId);
3660    
3661                    if (orderByComparator != null) {
3662                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3663    
3664                            for (Object value : values) {
3665                                    qPos.add(value);
3666                            }
3667                    }
3668    
3669                    List<DDMStructure> list = q.list();
3670    
3671                    if (list.size() == 2) {
3672                            return list.get(1);
3673                    }
3674                    else {
3675                            return null;
3676                    }
3677            }
3678    
3679            /**
3680             * Returns all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
3681             *
3682             * @param groupId the group ID
3683             * @param name the name
3684             * @param description the description
3685             * @return the matching d d m structures
3686             * @throws SystemException if a system exception occurred
3687             */
3688            public List<DDMStructure> findByG_N_D(long groupId, String name,
3689                    String description) throws SystemException {
3690                    return findByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
3691                            QueryUtil.ALL_POS, null);
3692            }
3693    
3694            /**
3695             * Returns a range of all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
3696             *
3697             * <p>
3698             * 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.
3699             * </p>
3700             *
3701             * @param groupId the group ID
3702             * @param name the name
3703             * @param description the description
3704             * @param start the lower bound of the range of d d m structures
3705             * @param end the upper bound of the range of d d m structures (not inclusive)
3706             * @return the range of matching d d m structures
3707             * @throws SystemException if a system exception occurred
3708             */
3709            public List<DDMStructure> findByG_N_D(long groupId, String name,
3710                    String description, int start, int end) throws SystemException {
3711                    return findByG_N_D(groupId, name, description, start, end, null);
3712            }
3713    
3714            /**
3715             * Returns an ordered range of all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
3716             *
3717             * <p>
3718             * 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.
3719             * </p>
3720             *
3721             * @param groupId the group ID
3722             * @param name the name
3723             * @param description the description
3724             * @param start the lower bound of the range of d d m structures
3725             * @param end the upper bound of the range of d d m structures (not inclusive)
3726             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3727             * @return the ordered range of matching d d m structures
3728             * @throws SystemException if a system exception occurred
3729             */
3730            public List<DDMStructure> findByG_N_D(long groupId, String name,
3731                    String description, int start, int end,
3732                    OrderByComparator orderByComparator) throws SystemException {
3733                    FinderPath finderPath = null;
3734                    Object[] finderArgs = null;
3735    
3736                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3737                                    (orderByComparator == null)) {
3738                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D;
3739                            finderArgs = new Object[] { groupId, name, description };
3740                    }
3741                    else {
3742                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D;
3743                            finderArgs = new Object[] {
3744                                            groupId, name, description,
3745                                            
3746                                            start, end, orderByComparator
3747                                    };
3748                    }
3749    
3750                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3751                                    finderArgs, this);
3752    
3753                    if ((list != null) && !list.isEmpty()) {
3754                            for (DDMStructure ddmStructure : list) {
3755                                    if ((groupId != ddmStructure.getGroupId()) ||
3756                                                    !Validator.equals(name, ddmStructure.getName()) ||
3757                                                    !Validator.equals(description,
3758                                                            ddmStructure.getDescription())) {
3759                                            list = null;
3760    
3761                                            break;
3762                                    }
3763                            }
3764                    }
3765    
3766                    if (list == null) {
3767                            StringBundler query = null;
3768    
3769                            if (orderByComparator != null) {
3770                                    query = new StringBundler(5 +
3771                                                    (orderByComparator.getOrderByFields().length * 3));
3772                            }
3773                            else {
3774                                    query = new StringBundler(4);
3775                            }
3776    
3777                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3778    
3779                            query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
3780    
3781                            if (name == null) {
3782                                    query.append(_FINDER_COLUMN_G_N_D_NAME_1);
3783                            }
3784                            else {
3785                                    if (name.equals(StringPool.BLANK)) {
3786                                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
3787                                    }
3788                                    else {
3789                                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
3790                                    }
3791                            }
3792    
3793                            if (description == null) {
3794                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
3795                            }
3796                            else {
3797                                    if (description.equals(StringPool.BLANK)) {
3798                                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
3799                                    }
3800                                    else {
3801                                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
3802                                    }
3803                            }
3804    
3805                            if (orderByComparator != null) {
3806                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3807                                            orderByComparator);
3808                            }
3809    
3810                            String sql = query.toString();
3811    
3812                            Session session = null;
3813    
3814                            try {
3815                                    session = openSession();
3816    
3817                                    Query q = session.createQuery(sql);
3818    
3819                                    QueryPos qPos = QueryPos.getInstance(q);
3820    
3821                                    qPos.add(groupId);
3822    
3823                                    if (name != null) {
3824                                            qPos.add(name);
3825                                    }
3826    
3827                                    if (description != null) {
3828                                            qPos.add(description);
3829                                    }
3830    
3831                                    list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3832                                                    start, end);
3833                            }
3834                            catch (Exception e) {
3835                                    throw processException(e);
3836                            }
3837                            finally {
3838                                    if (list == null) {
3839                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3840                                    }
3841                                    else {
3842                                            cacheResult(list);
3843    
3844                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3845                                    }
3846    
3847                                    closeSession(session);
3848                            }
3849                    }
3850    
3851                    return list;
3852            }
3853    
3854            /**
3855             * Returns the first d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
3856             *
3857             * @param groupId the group ID
3858             * @param name the name
3859             * @param description the description
3860             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3861             * @return the first matching d d m structure
3862             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3863             * @throws SystemException if a system exception occurred
3864             */
3865            public DDMStructure findByG_N_D_First(long groupId, String name,
3866                    String description, OrderByComparator orderByComparator)
3867                    throws NoSuchStructureException, SystemException {
3868                    DDMStructure ddmStructure = fetchByG_N_D_First(groupId, name,
3869                                    description, orderByComparator);
3870    
3871                    if (ddmStructure != null) {
3872                            return ddmStructure;
3873                    }
3874    
3875                    StringBundler msg = new StringBundler(8);
3876    
3877                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3878    
3879                    msg.append("groupId=");
3880                    msg.append(groupId);
3881    
3882                    msg.append(", name=");
3883                    msg.append(name);
3884    
3885                    msg.append(", description=");
3886                    msg.append(description);
3887    
3888                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3889    
3890                    throw new NoSuchStructureException(msg.toString());
3891            }
3892    
3893            /**
3894             * Returns the first d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
3895             *
3896             * @param groupId the group ID
3897             * @param name the name
3898             * @param description the description
3899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3900             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3901             * @throws SystemException if a system exception occurred
3902             */
3903            public DDMStructure fetchByG_N_D_First(long groupId, String name,
3904                    String description, OrderByComparator orderByComparator)
3905                    throws SystemException {
3906                    List<DDMStructure> list = findByG_N_D(groupId, name, description, 0, 1,
3907                                    orderByComparator);
3908    
3909                    if (!list.isEmpty()) {
3910                            return list.get(0);
3911                    }
3912    
3913                    return null;
3914            }
3915    
3916            /**
3917             * Returns the last d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
3918             *
3919             * @param groupId the group ID
3920             * @param name the name
3921             * @param description the description
3922             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3923             * @return the last matching d d m structure
3924             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3925             * @throws SystemException if a system exception occurred
3926             */
3927            public DDMStructure findByG_N_D_Last(long groupId, String name,
3928                    String description, OrderByComparator orderByComparator)
3929                    throws NoSuchStructureException, SystemException {
3930                    DDMStructure ddmStructure = fetchByG_N_D_Last(groupId, name,
3931                                    description, orderByComparator);
3932    
3933                    if (ddmStructure != null) {
3934                            return ddmStructure;
3935                    }
3936    
3937                    StringBundler msg = new StringBundler(8);
3938    
3939                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3940    
3941                    msg.append("groupId=");
3942                    msg.append(groupId);
3943    
3944                    msg.append(", name=");
3945                    msg.append(name);
3946    
3947                    msg.append(", description=");
3948                    msg.append(description);
3949    
3950                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3951    
3952                    throw new NoSuchStructureException(msg.toString());
3953            }
3954    
3955            /**
3956             * Returns the last d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
3957             *
3958             * @param groupId the group ID
3959             * @param name the name
3960             * @param description the description
3961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3962             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3963             * @throws SystemException if a system exception occurred
3964             */
3965            public DDMStructure fetchByG_N_D_Last(long groupId, String name,
3966                    String description, OrderByComparator orderByComparator)
3967                    throws SystemException {
3968                    int count = countByG_N_D(groupId, name, description);
3969    
3970                    List<DDMStructure> list = findByG_N_D(groupId, name, description,
3971                                    count - 1, count, orderByComparator);
3972    
3973                    if (!list.isEmpty()) {
3974                            return list.get(0);
3975                    }
3976    
3977                    return null;
3978            }
3979    
3980            /**
3981             * Returns the d d m structures before and after the current d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
3982             *
3983             * @param structureId the primary key of the current d d m structure
3984             * @param groupId the group ID
3985             * @param name the name
3986             * @param description the description
3987             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3988             * @return the previous, current, and next d d m structure
3989             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
3990             * @throws SystemException if a system exception occurred
3991             */
3992            public DDMStructure[] findByG_N_D_PrevAndNext(long structureId,
3993                    long groupId, String name, String description,
3994                    OrderByComparator orderByComparator)
3995                    throws NoSuchStructureException, SystemException {
3996                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
3997    
3998                    Session session = null;
3999    
4000                    try {
4001                            session = openSession();
4002    
4003                            DDMStructure[] array = new DDMStructureImpl[3];
4004    
4005                            array[0] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
4006                                            name, description, orderByComparator, true);
4007    
4008                            array[1] = ddmStructure;
4009    
4010                            array[2] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
4011                                            name, description, orderByComparator, false);
4012    
4013                            return array;
4014                    }
4015                    catch (Exception e) {
4016                            throw processException(e);
4017                    }
4018                    finally {
4019                            closeSession(session);
4020                    }
4021            }
4022    
4023            protected DDMStructure getByG_N_D_PrevAndNext(Session session,
4024                    DDMStructure ddmStructure, long groupId, String name,
4025                    String description, OrderByComparator orderByComparator,
4026                    boolean previous) {
4027                    StringBundler query = null;
4028    
4029                    if (orderByComparator != null) {
4030                            query = new StringBundler(6 +
4031                                            (orderByComparator.getOrderByFields().length * 6));
4032                    }
4033                    else {
4034                            query = new StringBundler(3);
4035                    }
4036    
4037                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
4038    
4039                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
4040    
4041                    if (name == null) {
4042                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
4043                    }
4044                    else {
4045                            if (name.equals(StringPool.BLANK)) {
4046                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
4047                            }
4048                            else {
4049                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
4050                            }
4051                    }
4052    
4053                    if (description == null) {
4054                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
4055                    }
4056                    else {
4057                            if (description.equals(StringPool.BLANK)) {
4058                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
4059                            }
4060                            else {
4061                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
4062                            }
4063                    }
4064    
4065                    if (orderByComparator != null) {
4066                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4067    
4068                            if (orderByConditionFields.length > 0) {
4069                                    query.append(WHERE_AND);
4070                            }
4071    
4072                            for (int i = 0; i < orderByConditionFields.length; i++) {
4073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4074                                    query.append(orderByConditionFields[i]);
4075    
4076                                    if ((i + 1) < orderByConditionFields.length) {
4077                                            if (orderByComparator.isAscending() ^ previous) {
4078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4079                                            }
4080                                            else {
4081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4082                                            }
4083                                    }
4084                                    else {
4085                                            if (orderByComparator.isAscending() ^ previous) {
4086                                                    query.append(WHERE_GREATER_THAN);
4087                                            }
4088                                            else {
4089                                                    query.append(WHERE_LESSER_THAN);
4090                                            }
4091                                    }
4092                            }
4093    
4094                            query.append(ORDER_BY_CLAUSE);
4095    
4096                            String[] orderByFields = orderByComparator.getOrderByFields();
4097    
4098                            for (int i = 0; i < orderByFields.length; i++) {
4099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4100                                    query.append(orderByFields[i]);
4101    
4102                                    if ((i + 1) < orderByFields.length) {
4103                                            if (orderByComparator.isAscending() ^ previous) {
4104                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4105                                            }
4106                                            else {
4107                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4108                                            }
4109                                    }
4110                                    else {
4111                                            if (orderByComparator.isAscending() ^ previous) {
4112                                                    query.append(ORDER_BY_ASC);
4113                                            }
4114                                            else {
4115                                                    query.append(ORDER_BY_DESC);
4116                                            }
4117                                    }
4118                            }
4119                    }
4120    
4121                    String sql = query.toString();
4122    
4123                    Query q = session.createQuery(sql);
4124    
4125                    q.setFirstResult(0);
4126                    q.setMaxResults(2);
4127    
4128                    QueryPos qPos = QueryPos.getInstance(q);
4129    
4130                    qPos.add(groupId);
4131    
4132                    if (name != null) {
4133                            qPos.add(name);
4134                    }
4135    
4136                    if (description != null) {
4137                            qPos.add(description);
4138                    }
4139    
4140                    if (orderByComparator != null) {
4141                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
4142    
4143                            for (Object value : values) {
4144                                    qPos.add(value);
4145                            }
4146                    }
4147    
4148                    List<DDMStructure> list = q.list();
4149    
4150                    if (list.size() == 2) {
4151                            return list.get(1);
4152                    }
4153                    else {
4154                            return null;
4155                    }
4156            }
4157    
4158            /**
4159             * Returns all the d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
4160             *
4161             * @param groupId the group ID
4162             * @param name the name
4163             * @param description the description
4164             * @return the matching d d m structures that the user has permission to view
4165             * @throws SystemException if a system exception occurred
4166             */
4167            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
4168                    String description) throws SystemException {
4169                    return filterFindByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
4170                            QueryUtil.ALL_POS, null);
4171            }
4172    
4173            /**
4174             * Returns a range of all the d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
4175             *
4176             * <p>
4177             * 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.
4178             * </p>
4179             *
4180             * @param groupId the group ID
4181             * @param name the name
4182             * @param description the description
4183             * @param start the lower bound of the range of d d m structures
4184             * @param end the upper bound of the range of d d m structures (not inclusive)
4185             * @return the range of matching d d m structures that the user has permission to view
4186             * @throws SystemException if a system exception occurred
4187             */
4188            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
4189                    String description, int start, int end) throws SystemException {
4190                    return filterFindByG_N_D(groupId, name, description, start, end, null);
4191            }
4192    
4193            /**
4194             * Returns an ordered range of all the d d m structures that the user has permissions to view where groupId = &#63; and name = &#63; and description = &#63;.
4195             *
4196             * <p>
4197             * 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.
4198             * </p>
4199             *
4200             * @param groupId the group ID
4201             * @param name the name
4202             * @param description the description
4203             * @param start the lower bound of the range of d d m structures
4204             * @param end the upper bound of the range of d d m structures (not inclusive)
4205             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4206             * @return the ordered range of matching d d m structures that the user has permission to view
4207             * @throws SystemException if a system exception occurred
4208             */
4209            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
4210                    String description, int start, int end,
4211                    OrderByComparator orderByComparator) throws SystemException {
4212                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4213                            return findByG_N_D(groupId, name, description, start, end,
4214                                    orderByComparator);
4215                    }
4216    
4217                    StringBundler query = null;
4218    
4219                    if (orderByComparator != null) {
4220                            query = new StringBundler(5 +
4221                                            (orderByComparator.getOrderByFields().length * 3));
4222                    }
4223                    else {
4224                            query = new StringBundler(4);
4225                    }
4226    
4227                    if (getDB().isSupportsInlineDistinct()) {
4228                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
4229                    }
4230                    else {
4231                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
4232                    }
4233    
4234                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
4235    
4236                    if (name == null) {
4237                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
4238                    }
4239                    else {
4240                            if (name.equals(StringPool.BLANK)) {
4241                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
4242                            }
4243                            else {
4244                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
4245                            }
4246                    }
4247    
4248                    if (description == null) {
4249                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
4250                    }
4251                    else {
4252                            if (description.equals(StringPool.BLANK)) {
4253                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
4254                            }
4255                            else {
4256                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
4257                            }
4258                    }
4259    
4260                    if (!getDB().isSupportsInlineDistinct()) {
4261                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
4262                    }
4263    
4264                    if (orderByComparator != null) {
4265                            if (getDB().isSupportsInlineDistinct()) {
4266                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4267                                            orderByComparator);
4268                            }
4269                            else {
4270                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4271                                            orderByComparator);
4272                            }
4273                    }
4274    
4275                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4276                                    DDMStructure.class.getName(),
4277                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4278    
4279                    Session session = null;
4280    
4281                    try {
4282                            session = openSession();
4283    
4284                            SQLQuery q = session.createSQLQuery(sql);
4285    
4286                            if (getDB().isSupportsInlineDistinct()) {
4287                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
4288                            }
4289                            else {
4290                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
4291                            }
4292    
4293                            QueryPos qPos = QueryPos.getInstance(q);
4294    
4295                            qPos.add(groupId);
4296    
4297                            if (name != null) {
4298                                    qPos.add(name);
4299                            }
4300    
4301                            if (description != null) {
4302                                    qPos.add(description);
4303                            }
4304    
4305                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
4306                                    end);
4307                    }
4308                    catch (Exception e) {
4309                            throw processException(e);
4310                    }
4311                    finally {
4312                            closeSession(session);
4313                    }
4314            }
4315    
4316            /**
4317             * Returns the d d m structures before and after the current d d m structure in the ordered set of d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
4318             *
4319             * @param structureId the primary key of the current d d m structure
4320             * @param groupId the group ID
4321             * @param name the name
4322             * @param description the description
4323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4324             * @return the previous, current, and next d d m structure
4325             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
4326             * @throws SystemException if a system exception occurred
4327             */
4328            public DDMStructure[] filterFindByG_N_D_PrevAndNext(long structureId,
4329                    long groupId, String name, String description,
4330                    OrderByComparator orderByComparator)
4331                    throws NoSuchStructureException, SystemException {
4332                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4333                            return findByG_N_D_PrevAndNext(structureId, groupId, name,
4334                                    description, orderByComparator);
4335                    }
4336    
4337                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
4338    
4339                    Session session = null;
4340    
4341                    try {
4342                            session = openSession();
4343    
4344                            DDMStructure[] array = new DDMStructureImpl[3];
4345    
4346                            array[0] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
4347                                            groupId, name, description, orderByComparator, true);
4348    
4349                            array[1] = ddmStructure;
4350    
4351                            array[2] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
4352                                            groupId, name, description, orderByComparator, false);
4353    
4354                            return array;
4355                    }
4356                    catch (Exception e) {
4357                            throw processException(e);
4358                    }
4359                    finally {
4360                            closeSession(session);
4361                    }
4362            }
4363    
4364            protected DDMStructure filterGetByG_N_D_PrevAndNext(Session session,
4365                    DDMStructure ddmStructure, long groupId, String name,
4366                    String description, OrderByComparator orderByComparator,
4367                    boolean previous) {
4368                    StringBundler query = null;
4369    
4370                    if (orderByComparator != null) {
4371                            query = new StringBundler(6 +
4372                                            (orderByComparator.getOrderByFields().length * 6));
4373                    }
4374                    else {
4375                            query = new StringBundler(3);
4376                    }
4377    
4378                    if (getDB().isSupportsInlineDistinct()) {
4379                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
4380                    }
4381                    else {
4382                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
4383                    }
4384    
4385                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
4386    
4387                    if (name == null) {
4388                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
4389                    }
4390                    else {
4391                            if (name.equals(StringPool.BLANK)) {
4392                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
4393                            }
4394                            else {
4395                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
4396                            }
4397                    }
4398    
4399                    if (description == null) {
4400                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
4401                    }
4402                    else {
4403                            if (description.equals(StringPool.BLANK)) {
4404                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
4405                            }
4406                            else {
4407                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
4408                            }
4409                    }
4410    
4411                    if (!getDB().isSupportsInlineDistinct()) {
4412                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
4413                    }
4414    
4415                    if (orderByComparator != null) {
4416                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4417    
4418                            if (orderByConditionFields.length > 0) {
4419                                    query.append(WHERE_AND);
4420                            }
4421    
4422                            for (int i = 0; i < orderByConditionFields.length; i++) {
4423                                    if (getDB().isSupportsInlineDistinct()) {
4424                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4425                                    }
4426                                    else {
4427                                            query.append(_ORDER_BY_ENTITY_TABLE);
4428                                    }
4429    
4430                                    query.append(orderByConditionFields[i]);
4431    
4432                                    if ((i + 1) < orderByConditionFields.length) {
4433                                            if (orderByComparator.isAscending() ^ previous) {
4434                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4435                                            }
4436                                            else {
4437                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4438                                            }
4439                                    }
4440                                    else {
4441                                            if (orderByComparator.isAscending() ^ previous) {
4442                                                    query.append(WHERE_GREATER_THAN);
4443                                            }
4444                                            else {
4445                                                    query.append(WHERE_LESSER_THAN);
4446                                            }
4447                                    }
4448                            }
4449    
4450                            query.append(ORDER_BY_CLAUSE);
4451    
4452                            String[] orderByFields = orderByComparator.getOrderByFields();
4453    
4454                            for (int i = 0; i < orderByFields.length; i++) {
4455                                    if (getDB().isSupportsInlineDistinct()) {
4456                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4457                                    }
4458                                    else {
4459                                            query.append(_ORDER_BY_ENTITY_TABLE);
4460                                    }
4461    
4462                                    query.append(orderByFields[i]);
4463    
4464                                    if ((i + 1) < orderByFields.length) {
4465                                            if (orderByComparator.isAscending() ^ previous) {
4466                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4467                                            }
4468                                            else {
4469                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4470                                            }
4471                                    }
4472                                    else {
4473                                            if (orderByComparator.isAscending() ^ previous) {
4474                                                    query.append(ORDER_BY_ASC);
4475                                            }
4476                                            else {
4477                                                    query.append(ORDER_BY_DESC);
4478                                            }
4479                                    }
4480                            }
4481                    }
4482    
4483                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4484                                    DDMStructure.class.getName(),
4485                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4486    
4487                    SQLQuery q = session.createSQLQuery(sql);
4488    
4489                    q.setFirstResult(0);
4490                    q.setMaxResults(2);
4491    
4492                    if (getDB().isSupportsInlineDistinct()) {
4493                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
4494                    }
4495                    else {
4496                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
4497                    }
4498    
4499                    QueryPos qPos = QueryPos.getInstance(q);
4500    
4501                    qPos.add(groupId);
4502    
4503                    if (name != null) {
4504                            qPos.add(name);
4505                    }
4506    
4507                    if (description != null) {
4508                            qPos.add(description);
4509                    }
4510    
4511                    if (orderByComparator != null) {
4512                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
4513    
4514                            for (Object value : values) {
4515                                    qPos.add(value);
4516                            }
4517                    }
4518    
4519                    List<DDMStructure> list = q.list();
4520    
4521                    if (list.size() == 2) {
4522                            return list.get(1);
4523                    }
4524                    else {
4525                            return null;
4526                    }
4527            }
4528    
4529            /**
4530             * Returns all the d d m structures.
4531             *
4532             * @return the d d m structures
4533             * @throws SystemException if a system exception occurred
4534             */
4535            public List<DDMStructure> findAll() throws SystemException {
4536                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4537            }
4538    
4539            /**
4540             * Returns a range of all the d d m structures.
4541             *
4542             * <p>
4543             * 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.
4544             * </p>
4545             *
4546             * @param start the lower bound of the range of d d m structures
4547             * @param end the upper bound of the range of d d m structures (not inclusive)
4548             * @return the range of d d m structures
4549             * @throws SystemException if a system exception occurred
4550             */
4551            public List<DDMStructure> findAll(int start, int end)
4552                    throws SystemException {
4553                    return findAll(start, end, null);
4554            }
4555    
4556            /**
4557             * Returns an ordered range of all the d d m structures.
4558             *
4559             * <p>
4560             * 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.
4561             * </p>
4562             *
4563             * @param start the lower bound of the range of d d m structures
4564             * @param end the upper bound of the range of d d m structures (not inclusive)
4565             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4566             * @return the ordered range of d d m structures
4567             * @throws SystemException if a system exception occurred
4568             */
4569            public List<DDMStructure> findAll(int start, int end,
4570                    OrderByComparator orderByComparator) throws SystemException {
4571                    FinderPath finderPath = null;
4572                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4573    
4574                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4575                                    (orderByComparator == null)) {
4576                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4577                            finderArgs = FINDER_ARGS_EMPTY;
4578                    }
4579                    else {
4580                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4581                            finderArgs = new Object[] { start, end, orderByComparator };
4582                    }
4583    
4584                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
4585                                    finderArgs, this);
4586    
4587                    if (list == null) {
4588                            StringBundler query = null;
4589                            String sql = null;
4590    
4591                            if (orderByComparator != null) {
4592                                    query = new StringBundler(2 +
4593                                                    (orderByComparator.getOrderByFields().length * 3));
4594    
4595                                    query.append(_SQL_SELECT_DDMSTRUCTURE);
4596    
4597                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4598                                            orderByComparator);
4599    
4600                                    sql = query.toString();
4601                            }
4602                            else {
4603                                    sql = _SQL_SELECT_DDMSTRUCTURE;
4604                            }
4605    
4606                            Session session = null;
4607    
4608                            try {
4609                                    session = openSession();
4610    
4611                                    Query q = session.createQuery(sql);
4612    
4613                                    if (orderByComparator == null) {
4614                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
4615                                                            start, end, false);
4616    
4617                                            Collections.sort(list);
4618                                    }
4619                                    else {
4620                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
4621                                                            start, end);
4622                                    }
4623                            }
4624                            catch (Exception e) {
4625                                    throw processException(e);
4626                            }
4627                            finally {
4628                                    if (list == null) {
4629                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4630                                    }
4631                                    else {
4632                                            cacheResult(list);
4633    
4634                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4635                                    }
4636    
4637                                    closeSession(session);
4638                            }
4639                    }
4640    
4641                    return list;
4642            }
4643    
4644            /**
4645             * Removes all the d d m structures where uuid = &#63; from the database.
4646             *
4647             * @param uuid the uuid
4648             * @throws SystemException if a system exception occurred
4649             */
4650            public void removeByUuid(String uuid) throws SystemException {
4651                    for (DDMStructure ddmStructure : findByUuid(uuid)) {
4652                            remove(ddmStructure);
4653                    }
4654            }
4655    
4656            /**
4657             * Removes the d d m structure where uuid = &#63; and groupId = &#63; from the database.
4658             *
4659             * @param uuid the uuid
4660             * @param groupId the group ID
4661             * @return the d d m structure that was removed
4662             * @throws SystemException if a system exception occurred
4663             */
4664            public DDMStructure removeByUUID_G(String uuid, long groupId)
4665                    throws NoSuchStructureException, SystemException {
4666                    DDMStructure ddmStructure = findByUUID_G(uuid, groupId);
4667    
4668                    return remove(ddmStructure);
4669            }
4670    
4671            /**
4672             * Removes all the d d m structures where uuid = &#63; and companyId = &#63; from the database.
4673             *
4674             * @param uuid the uuid
4675             * @param companyId the company ID
4676             * @throws SystemException if a system exception occurred
4677             */
4678            public void removeByUuid_C(String uuid, long companyId)
4679                    throws SystemException {
4680                    for (DDMStructure ddmStructure : findByUuid_C(uuid, companyId)) {
4681                            remove(ddmStructure);
4682                    }
4683            }
4684    
4685            /**
4686             * Removes all the d d m structures where groupId = &#63; from the database.
4687             *
4688             * @param groupId the group ID
4689             * @throws SystemException if a system exception occurred
4690             */
4691            public void removeByGroupId(long groupId) throws SystemException {
4692                    for (DDMStructure ddmStructure : findByGroupId(groupId)) {
4693                            remove(ddmStructure);
4694                    }
4695            }
4696    
4697            /**
4698             * Removes all the d d m structures where classNameId = &#63; from the database.
4699             *
4700             * @param classNameId the class name ID
4701             * @throws SystemException if a system exception occurred
4702             */
4703            public void removeByClassNameId(long classNameId) throws SystemException {
4704                    for (DDMStructure ddmStructure : findByClassNameId(classNameId)) {
4705                            remove(ddmStructure);
4706                    }
4707            }
4708    
4709            /**
4710             * Removes the d d m structure where groupId = &#63; and structureKey = &#63; from the database.
4711             *
4712             * @param groupId the group ID
4713             * @param structureKey the structure key
4714             * @return the d d m structure that was removed
4715             * @throws SystemException if a system exception occurred
4716             */
4717            public DDMStructure removeByG_S(long groupId, String structureKey)
4718                    throws NoSuchStructureException, SystemException {
4719                    DDMStructure ddmStructure = findByG_S(groupId, structureKey);
4720    
4721                    return remove(ddmStructure);
4722            }
4723    
4724            /**
4725             * Removes all the d d m structures where companyId = &#63; and classNameId = &#63; from the database.
4726             *
4727             * @param companyId the company ID
4728             * @param classNameId the class name ID
4729             * @throws SystemException if a system exception occurred
4730             */
4731            public void removeByC_C(long companyId, long classNameId)
4732                    throws SystemException {
4733                    for (DDMStructure ddmStructure : findByC_C(companyId, classNameId)) {
4734                            remove(ddmStructure);
4735                    }
4736            }
4737    
4738            /**
4739             * Removes all the d d m structures where groupId = &#63; and name = &#63; and description = &#63; from the database.
4740             *
4741             * @param groupId the group ID
4742             * @param name the name
4743             * @param description the description
4744             * @throws SystemException if a system exception occurred
4745             */
4746            public void removeByG_N_D(long groupId, String name, String description)
4747                    throws SystemException {
4748                    for (DDMStructure ddmStructure : findByG_N_D(groupId, name, description)) {
4749                            remove(ddmStructure);
4750                    }
4751            }
4752    
4753            /**
4754             * Removes all the d d m structures from the database.
4755             *
4756             * @throws SystemException if a system exception occurred
4757             */
4758            public void removeAll() throws SystemException {
4759                    for (DDMStructure ddmStructure : findAll()) {
4760                            remove(ddmStructure);
4761                    }
4762            }
4763    
4764            /**
4765             * Returns the number of d d m structures where uuid = &#63;.
4766             *
4767             * @param uuid the uuid
4768             * @return the number of matching d d m structures
4769             * @throws SystemException if a system exception occurred
4770             */
4771            public int countByUuid(String uuid) throws SystemException {
4772                    Object[] finderArgs = new Object[] { uuid };
4773    
4774                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4775                                    finderArgs, this);
4776    
4777                    if (count == null) {
4778                            StringBundler query = new StringBundler(2);
4779    
4780                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4781    
4782                            if (uuid == null) {
4783                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
4784                            }
4785                            else {
4786                                    if (uuid.equals(StringPool.BLANK)) {
4787                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
4788                                    }
4789                                    else {
4790                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
4791                                    }
4792                            }
4793    
4794                            String sql = query.toString();
4795    
4796                            Session session = null;
4797    
4798                            try {
4799                                    session = openSession();
4800    
4801                                    Query q = session.createQuery(sql);
4802    
4803                                    QueryPos qPos = QueryPos.getInstance(q);
4804    
4805                                    if (uuid != null) {
4806                                            qPos.add(uuid);
4807                                    }
4808    
4809                                    count = (Long)q.uniqueResult();
4810                            }
4811                            catch (Exception e) {
4812                                    throw processException(e);
4813                            }
4814                            finally {
4815                                    if (count == null) {
4816                                            count = Long.valueOf(0);
4817                                    }
4818    
4819                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4820                                            finderArgs, count);
4821    
4822                                    closeSession(session);
4823                            }
4824                    }
4825    
4826                    return count.intValue();
4827            }
4828    
4829            /**
4830             * Returns the number of d d m structures where uuid = &#63; and groupId = &#63;.
4831             *
4832             * @param uuid the uuid
4833             * @param groupId the group ID
4834             * @return the number of matching d d m structures
4835             * @throws SystemException if a system exception occurred
4836             */
4837            public int countByUUID_G(String uuid, long groupId)
4838                    throws SystemException {
4839                    Object[] finderArgs = new Object[] { uuid, groupId };
4840    
4841                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4842                                    finderArgs, this);
4843    
4844                    if (count == null) {
4845                            StringBundler query = new StringBundler(3);
4846    
4847                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4848    
4849                            if (uuid == null) {
4850                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4851                            }
4852                            else {
4853                                    if (uuid.equals(StringPool.BLANK)) {
4854                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4855                                    }
4856                                    else {
4857                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4858                                    }
4859                            }
4860    
4861                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4862    
4863                            String sql = query.toString();
4864    
4865                            Session session = null;
4866    
4867                            try {
4868                                    session = openSession();
4869    
4870                                    Query q = session.createQuery(sql);
4871    
4872                                    QueryPos qPos = QueryPos.getInstance(q);
4873    
4874                                    if (uuid != null) {
4875                                            qPos.add(uuid);
4876                                    }
4877    
4878                                    qPos.add(groupId);
4879    
4880                                    count = (Long)q.uniqueResult();
4881                            }
4882                            catch (Exception e) {
4883                                    throw processException(e);
4884                            }
4885                            finally {
4886                                    if (count == null) {
4887                                            count = Long.valueOf(0);
4888                                    }
4889    
4890                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4891                                            finderArgs, count);
4892    
4893                                    closeSession(session);
4894                            }
4895                    }
4896    
4897                    return count.intValue();
4898            }
4899    
4900            /**
4901             * Returns the number of d d m structures where uuid = &#63; and companyId = &#63;.
4902             *
4903             * @param uuid the uuid
4904             * @param companyId the company ID
4905             * @return the number of matching d d m structures
4906             * @throws SystemException if a system exception occurred
4907             */
4908            public int countByUuid_C(String uuid, long companyId)
4909                    throws SystemException {
4910                    Object[] finderArgs = new Object[] { uuid, companyId };
4911    
4912                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4913                                    finderArgs, this);
4914    
4915                    if (count == null) {
4916                            StringBundler query = new StringBundler(3);
4917    
4918                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4919    
4920                            if (uuid == null) {
4921                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4922                            }
4923                            else {
4924                                    if (uuid.equals(StringPool.BLANK)) {
4925                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4926                                    }
4927                                    else {
4928                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4929                                    }
4930                            }
4931    
4932                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4933    
4934                            String sql = query.toString();
4935    
4936                            Session session = null;
4937    
4938                            try {
4939                                    session = openSession();
4940    
4941                                    Query q = session.createQuery(sql);
4942    
4943                                    QueryPos qPos = QueryPos.getInstance(q);
4944    
4945                                    if (uuid != null) {
4946                                            qPos.add(uuid);
4947                                    }
4948    
4949                                    qPos.add(companyId);
4950    
4951                                    count = (Long)q.uniqueResult();
4952                            }
4953                            catch (Exception e) {
4954                                    throw processException(e);
4955                            }
4956                            finally {
4957                                    if (count == null) {
4958                                            count = Long.valueOf(0);
4959                                    }
4960    
4961                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4962                                            finderArgs, count);
4963    
4964                                    closeSession(session);
4965                            }
4966                    }
4967    
4968                    return count.intValue();
4969            }
4970    
4971            /**
4972             * Returns the number of d d m structures where groupId = &#63;.
4973             *
4974             * @param groupId the group ID
4975             * @return the number of matching d d m structures
4976             * @throws SystemException if a system exception occurred
4977             */
4978            public int countByGroupId(long groupId) throws SystemException {
4979                    Object[] finderArgs = new Object[] { groupId };
4980    
4981                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4982                                    finderArgs, this);
4983    
4984                    if (count == null) {
4985                            StringBundler query = new StringBundler(2);
4986    
4987                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4988    
4989                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4990    
4991                            String sql = query.toString();
4992    
4993                            Session session = null;
4994    
4995                            try {
4996                                    session = openSession();
4997    
4998                                    Query q = session.createQuery(sql);
4999    
5000                                    QueryPos qPos = QueryPos.getInstance(q);
5001    
5002                                    qPos.add(groupId);
5003    
5004                                    count = (Long)q.uniqueResult();
5005                            }
5006                            catch (Exception e) {
5007                                    throw processException(e);
5008                            }
5009                            finally {
5010                                    if (count == null) {
5011                                            count = Long.valueOf(0);
5012                                    }
5013    
5014                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5015                                            finderArgs, count);
5016    
5017                                    closeSession(session);
5018                            }
5019                    }
5020    
5021                    return count.intValue();
5022            }
5023    
5024            /**
5025             * Returns the number of d d m structures where groupId = any &#63;.
5026             *
5027             * @param groupIds the group IDs
5028             * @return the number of matching d d m structures
5029             * @throws SystemException if a system exception occurred
5030             */
5031            public int countByGroupId(long[] groupIds) throws SystemException {
5032                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
5033    
5034                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
5035                                    finderArgs, this);
5036    
5037                    if (count == null) {
5038                            StringBundler query = new StringBundler();
5039    
5040                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5041    
5042                            boolean conjunctionable = false;
5043    
5044                            if ((groupIds == null) || (groupIds.length > 0)) {
5045                                    if (conjunctionable) {
5046                                            query.append(WHERE_AND);
5047                                    }
5048    
5049                                    query.append(StringPool.OPEN_PARENTHESIS);
5050    
5051                                    for (int i = 0; i < groupIds.length; i++) {
5052                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
5053    
5054                                            if ((i + 1) < groupIds.length) {
5055                                                    query.append(WHERE_OR);
5056                                            }
5057                                    }
5058    
5059                                    query.append(StringPool.CLOSE_PARENTHESIS);
5060    
5061                                    conjunctionable = true;
5062                            }
5063    
5064                            String sql = query.toString();
5065    
5066                            Session session = null;
5067    
5068                            try {
5069                                    session = openSession();
5070    
5071                                    Query q = session.createQuery(sql);
5072    
5073                                    QueryPos qPos = QueryPos.getInstance(q);
5074    
5075                                    if (groupIds != null) {
5076                                            qPos.add(groupIds);
5077                                    }
5078    
5079                                    count = (Long)q.uniqueResult();
5080                            }
5081                            catch (Exception e) {
5082                                    throw processException(e);
5083                            }
5084                            finally {
5085                                    if (count == null) {
5086                                            count = Long.valueOf(0);
5087                                    }
5088    
5089                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
5090                                            finderArgs, count);
5091    
5092                                    closeSession(session);
5093                            }
5094                    }
5095    
5096                    return count.intValue();
5097            }
5098    
5099            /**
5100             * Returns the number of d d m structures that the user has permission to view where groupId = &#63;.
5101             *
5102             * @param groupId the group ID
5103             * @return the number of matching d d m structures that the user has permission to view
5104             * @throws SystemException if a system exception occurred
5105             */
5106            public int filterCountByGroupId(long groupId) throws SystemException {
5107                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5108                            return countByGroupId(groupId);
5109                    }
5110    
5111                    StringBundler query = new StringBundler(2);
5112    
5113                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
5114    
5115                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5116    
5117                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5118                                    DDMStructure.class.getName(),
5119                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5120    
5121                    Session session = null;
5122    
5123                    try {
5124                            session = openSession();
5125    
5126                            SQLQuery q = session.createSQLQuery(sql);
5127    
5128                            q.addScalar(COUNT_COLUMN_NAME,
5129                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5130    
5131                            QueryPos qPos = QueryPos.getInstance(q);
5132    
5133                            qPos.add(groupId);
5134    
5135                            Long count = (Long)q.uniqueResult();
5136    
5137                            return count.intValue();
5138                    }
5139                    catch (Exception e) {
5140                            throw processException(e);
5141                    }
5142                    finally {
5143                            closeSession(session);
5144                    }
5145            }
5146    
5147            /**
5148             * Returns the number of d d m structures that the user has permission to view where groupId = any &#63;.
5149             *
5150             * @param groupIds the group IDs
5151             * @return the number of matching d d m structures that the user has permission to view
5152             * @throws SystemException if a system exception occurred
5153             */
5154            public int filterCountByGroupId(long[] groupIds) throws SystemException {
5155                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
5156                            return countByGroupId(groupIds);
5157                    }
5158    
5159                    StringBundler query = new StringBundler();
5160    
5161                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
5162    
5163                    boolean conjunctionable = false;
5164    
5165                    if ((groupIds == null) || (groupIds.length > 0)) {
5166                            if (conjunctionable) {
5167                                    query.append(WHERE_AND);
5168                            }
5169    
5170                            query.append(StringPool.OPEN_PARENTHESIS);
5171    
5172                            for (int i = 0; i < groupIds.length; i++) {
5173                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
5174    
5175                                    if ((i + 1) < groupIds.length) {
5176                                            query.append(WHERE_OR);
5177                                    }
5178                            }
5179    
5180                            query.append(StringPool.CLOSE_PARENTHESIS);
5181    
5182                            conjunctionable = true;
5183                    }
5184    
5185                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5186                                    DDMStructure.class.getName(),
5187                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
5188    
5189                    Session session = null;
5190    
5191                    try {
5192                            session = openSession();
5193    
5194                            SQLQuery q = session.createSQLQuery(sql);
5195    
5196                            q.addScalar(COUNT_COLUMN_NAME,
5197                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5198    
5199                            QueryPos qPos = QueryPos.getInstance(q);
5200    
5201                            if (groupIds != null) {
5202                                    qPos.add(groupIds);
5203                            }
5204    
5205                            Long count = (Long)q.uniqueResult();
5206    
5207                            return count.intValue();
5208                    }
5209                    catch (Exception e) {
5210                            throw processException(e);
5211                    }
5212                    finally {
5213                            closeSession(session);
5214                    }
5215            }
5216    
5217            /**
5218             * Returns the number of d d m structures where classNameId = &#63;.
5219             *
5220             * @param classNameId the class name ID
5221             * @return the number of matching d d m structures
5222             * @throws SystemException if a system exception occurred
5223             */
5224            public int countByClassNameId(long classNameId) throws SystemException {
5225                    Object[] finderArgs = new Object[] { classNameId };
5226    
5227                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
5228                                    finderArgs, this);
5229    
5230                    if (count == null) {
5231                            StringBundler query = new StringBundler(2);
5232    
5233                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5234    
5235                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
5236    
5237                            String sql = query.toString();
5238    
5239                            Session session = null;
5240    
5241                            try {
5242                                    session = openSession();
5243    
5244                                    Query q = session.createQuery(sql);
5245    
5246                                    QueryPos qPos = QueryPos.getInstance(q);
5247    
5248                                    qPos.add(classNameId);
5249    
5250                                    count = (Long)q.uniqueResult();
5251                            }
5252                            catch (Exception e) {
5253                                    throw processException(e);
5254                            }
5255                            finally {
5256                                    if (count == null) {
5257                                            count = Long.valueOf(0);
5258                                    }
5259    
5260                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
5261                                            finderArgs, count);
5262    
5263                                    closeSession(session);
5264                            }
5265                    }
5266    
5267                    return count.intValue();
5268            }
5269    
5270            /**
5271             * Returns the number of d d m structures where groupId = &#63; and structureKey = &#63;.
5272             *
5273             * @param groupId the group ID
5274             * @param structureKey the structure key
5275             * @return the number of matching d d m structures
5276             * @throws SystemException if a system exception occurred
5277             */
5278            public int countByG_S(long groupId, String structureKey)
5279                    throws SystemException {
5280                    Object[] finderArgs = new Object[] { groupId, structureKey };
5281    
5282                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
5283                                    finderArgs, this);
5284    
5285                    if (count == null) {
5286                            StringBundler query = new StringBundler(3);
5287    
5288                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5289    
5290                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5291    
5292                            if (structureKey == null) {
5293                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_1);
5294                            }
5295                            else {
5296                                    if (structureKey.equals(StringPool.BLANK)) {
5297                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_3);
5298                                    }
5299                                    else {
5300                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_2);
5301                                    }
5302                            }
5303    
5304                            String sql = query.toString();
5305    
5306                            Session session = null;
5307    
5308                            try {
5309                                    session = openSession();
5310    
5311                                    Query q = session.createQuery(sql);
5312    
5313                                    QueryPos qPos = QueryPos.getInstance(q);
5314    
5315                                    qPos.add(groupId);
5316    
5317                                    if (structureKey != null) {
5318                                            qPos.add(structureKey);
5319                                    }
5320    
5321                                    count = (Long)q.uniqueResult();
5322                            }
5323                            catch (Exception e) {
5324                                    throw processException(e);
5325                            }
5326                            finally {
5327                                    if (count == null) {
5328                                            count = Long.valueOf(0);
5329                                    }
5330    
5331                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
5332                                            count);
5333    
5334                                    closeSession(session);
5335                            }
5336                    }
5337    
5338                    return count.intValue();
5339            }
5340    
5341            /**
5342             * Returns the number of d d m structures where companyId = &#63; and classNameId = &#63;.
5343             *
5344             * @param companyId the company ID
5345             * @param classNameId the class name ID
5346             * @return the number of matching d d m structures
5347             * @throws SystemException if a system exception occurred
5348             */
5349            public int countByC_C(long companyId, long classNameId)
5350                    throws SystemException {
5351                    Object[] finderArgs = new Object[] { companyId, classNameId };
5352    
5353                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
5354                                    finderArgs, this);
5355    
5356                    if (count == null) {
5357                            StringBundler query = new StringBundler(3);
5358    
5359                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5360    
5361                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
5362    
5363                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
5364    
5365                            String sql = query.toString();
5366    
5367                            Session session = null;
5368    
5369                            try {
5370                                    session = openSession();
5371    
5372                                    Query q = session.createQuery(sql);
5373    
5374                                    QueryPos qPos = QueryPos.getInstance(q);
5375    
5376                                    qPos.add(companyId);
5377    
5378                                    qPos.add(classNameId);
5379    
5380                                    count = (Long)q.uniqueResult();
5381                            }
5382                            catch (Exception e) {
5383                                    throw processException(e);
5384                            }
5385                            finally {
5386                                    if (count == null) {
5387                                            count = Long.valueOf(0);
5388                                    }
5389    
5390                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
5391                                            count);
5392    
5393                                    closeSession(session);
5394                            }
5395                    }
5396    
5397                    return count.intValue();
5398            }
5399    
5400            /**
5401             * Returns the number of d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
5402             *
5403             * @param groupId the group ID
5404             * @param name the name
5405             * @param description the description
5406             * @return the number of matching d d m structures
5407             * @throws SystemException if a system exception occurred
5408             */
5409            public int countByG_N_D(long groupId, String name, String description)
5410                    throws SystemException {
5411                    Object[] finderArgs = new Object[] { groupId, name, description };
5412    
5413                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_D,
5414                                    finderArgs, this);
5415    
5416                    if (count == null) {
5417                            StringBundler query = new StringBundler(4);
5418    
5419                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5420    
5421                            query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
5422    
5423                            if (name == null) {
5424                                    query.append(_FINDER_COLUMN_G_N_D_NAME_1);
5425                            }
5426                            else {
5427                                    if (name.equals(StringPool.BLANK)) {
5428                                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
5429                                    }
5430                                    else {
5431                                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
5432                                    }
5433                            }
5434    
5435                            if (description == null) {
5436                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
5437                            }
5438                            else {
5439                                    if (description.equals(StringPool.BLANK)) {
5440                                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
5441                                    }
5442                                    else {
5443                                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
5444                                    }
5445                            }
5446    
5447                            String sql = query.toString();
5448    
5449                            Session session = null;
5450    
5451                            try {
5452                                    session = openSession();
5453    
5454                                    Query q = session.createQuery(sql);
5455    
5456                                    QueryPos qPos = QueryPos.getInstance(q);
5457    
5458                                    qPos.add(groupId);
5459    
5460                                    if (name != null) {
5461                                            qPos.add(name);
5462                                    }
5463    
5464                                    if (description != null) {
5465                                            qPos.add(description);
5466                                    }
5467    
5468                                    count = (Long)q.uniqueResult();
5469                            }
5470                            catch (Exception e) {
5471                                    throw processException(e);
5472                            }
5473                            finally {
5474                                    if (count == null) {
5475                                            count = Long.valueOf(0);
5476                                    }
5477    
5478                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_D,
5479                                            finderArgs, count);
5480    
5481                                    closeSession(session);
5482                            }
5483                    }
5484    
5485                    return count.intValue();
5486            }
5487    
5488            /**
5489             * Returns the number of d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
5490             *
5491             * @param groupId the group ID
5492             * @param name the name
5493             * @param description the description
5494             * @return the number of matching d d m structures that the user has permission to view
5495             * @throws SystemException if a system exception occurred
5496             */
5497            public int filterCountByG_N_D(long groupId, String name, String description)
5498                    throws SystemException {
5499                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5500                            return countByG_N_D(groupId, name, description);
5501                    }
5502    
5503                    StringBundler query = new StringBundler(4);
5504    
5505                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
5506    
5507                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
5508    
5509                    if (name == null) {
5510                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
5511                    }
5512                    else {
5513                            if (name.equals(StringPool.BLANK)) {
5514                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
5515                            }
5516                            else {
5517                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
5518                            }
5519                    }
5520    
5521                    if (description == null) {
5522                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
5523                    }
5524                    else {
5525                            if (description.equals(StringPool.BLANK)) {
5526                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
5527                            }
5528                            else {
5529                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
5530                            }
5531                    }
5532    
5533                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5534                                    DDMStructure.class.getName(),
5535                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5536    
5537                    Session session = null;
5538    
5539                    try {
5540                            session = openSession();
5541    
5542                            SQLQuery q = session.createSQLQuery(sql);
5543    
5544                            q.addScalar(COUNT_COLUMN_NAME,
5545                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5546    
5547                            QueryPos qPos = QueryPos.getInstance(q);
5548    
5549                            qPos.add(groupId);
5550    
5551                            if (name != null) {
5552                                    qPos.add(name);
5553                            }
5554    
5555                            if (description != null) {
5556                                    qPos.add(description);
5557                            }
5558    
5559                            Long count = (Long)q.uniqueResult();
5560    
5561                            return count.intValue();
5562                    }
5563                    catch (Exception e) {
5564                            throw processException(e);
5565                    }
5566                    finally {
5567                            closeSession(session);
5568                    }
5569            }
5570    
5571            /**
5572             * Returns the number of d d m structures.
5573             *
5574             * @return the number of d d m structures
5575             * @throws SystemException if a system exception occurred
5576             */
5577            public int countAll() throws SystemException {
5578                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5579                                    FINDER_ARGS_EMPTY, this);
5580    
5581                    if (count == null) {
5582                            Session session = null;
5583    
5584                            try {
5585                                    session = openSession();
5586    
5587                                    Query q = session.createQuery(_SQL_COUNT_DDMSTRUCTURE);
5588    
5589                                    count = (Long)q.uniqueResult();
5590                            }
5591                            catch (Exception e) {
5592                                    throw processException(e);
5593                            }
5594                            finally {
5595                                    if (count == null) {
5596                                            count = Long.valueOf(0);
5597                                    }
5598    
5599                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5600                                            FINDER_ARGS_EMPTY, count);
5601    
5602                                    closeSession(session);
5603                            }
5604                    }
5605    
5606                    return count.intValue();
5607            }
5608    
5609            /**
5610             * Initializes the d d m structure persistence.
5611             */
5612            public void afterPropertiesSet() {
5613                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5614                                            com.liferay.portal.util.PropsUtil.get(
5615                                                    "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStructure")));
5616    
5617                    if (listenerClassNames.length > 0) {
5618                            try {
5619                                    List<ModelListener<DDMStructure>> listenersList = new ArrayList<ModelListener<DDMStructure>>();
5620    
5621                                    for (String listenerClassName : listenerClassNames) {
5622                                            listenersList.add((ModelListener<DDMStructure>)InstanceFactory.newInstance(
5623                                                            listenerClassName));
5624                                    }
5625    
5626                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5627                            }
5628                            catch (Exception e) {
5629                                    _log.error(e);
5630                            }
5631                    }
5632            }
5633    
5634            public void destroy() {
5635                    EntityCacheUtil.removeCache(DDMStructureImpl.class.getName());
5636                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5637                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5638            }
5639    
5640            @BeanReference(type = DDMContentPersistence.class)
5641            protected DDMContentPersistence ddmContentPersistence;
5642            @BeanReference(type = DDMStorageLinkPersistence.class)
5643            protected DDMStorageLinkPersistence ddmStorageLinkPersistence;
5644            @BeanReference(type = DDMStructurePersistence.class)
5645            protected DDMStructurePersistence ddmStructurePersistence;
5646            @BeanReference(type = DDMStructureLinkPersistence.class)
5647            protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
5648            @BeanReference(type = DDMTemplatePersistence.class)
5649            protected DDMTemplatePersistence ddmTemplatePersistence;
5650            @BeanReference(type = UserPersistence.class)
5651            protected UserPersistence userPersistence;
5652            @BeanReference(type = DLFileEntryTypePersistence.class)
5653            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
5654            private static final String _SQL_SELECT_DDMSTRUCTURE = "SELECT ddmStructure FROM DDMStructure ddmStructure";
5655            private static final String _SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT ddmStructure FROM DDMStructure ddmStructure WHERE ";
5656            private static final String _SQL_COUNT_DDMSTRUCTURE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure";
5657            private static final String _SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure WHERE ";
5658            private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmStructure.uuid IS NULL";
5659            private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmStructure.uuid = ?";
5660            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = ?)";
5661            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddmStructure.uuid IS NULL AND ";
5662            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddmStructure.uuid = ? AND ";
5663            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = ?) AND ";
5664            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddmStructure.groupId = ?";
5665            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "ddmStructure.uuid IS NULL AND ";
5666            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ddmStructure.uuid = ? AND ";
5667            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = ?) AND ";
5668            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ddmStructure.companyId = ?";
5669            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddmStructure.groupId = ?";
5670            private static final String _FINDER_COLUMN_GROUPID_GROUPID_5 = "(" +
5671                    _removeConjunction(_FINDER_COLUMN_GROUPID_GROUPID_2) + ")";
5672            private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
5673            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "ddmStructure.groupId = ? AND ";
5674            private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_1 = "ddmStructure.structureKey IS NULL";
5675            private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_2 = "ddmStructure.structureKey = ?";
5676            private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_3 = "(ddmStructure.structureKey IS NULL OR ddmStructure.structureKey = ?)";
5677            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "ddmStructure.companyId = ? AND ";
5678            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
5679            private static final String _FINDER_COLUMN_G_N_D_GROUPID_2 = "ddmStructure.groupId = ? AND ";
5680            private static final String _FINDER_COLUMN_G_N_D_NAME_1 = "ddmStructure.name IS NULL AND ";
5681            private static final String _FINDER_COLUMN_G_N_D_NAME_2 = "ddmStructure.name = ? AND ";
5682            private static final String _FINDER_COLUMN_G_N_D_NAME_3 = "(ddmStructure.name IS NULL OR ddmStructure.name = ?) AND ";
5683            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_1 = "ddmStructure.description IS NULL";
5684            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_2 = "ddmStructure.description = ?";
5685            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_3 = "(ddmStructure.description IS NULL OR ddmStructure.description = ?)";
5686    
5687            private static String _removeConjunction(String sql) {
5688                    int pos = sql.indexOf(" AND ");
5689    
5690                    if (pos != -1) {
5691                            sql = sql.substring(0, pos);
5692                    }
5693    
5694                    return sql;
5695            }
5696    
5697            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ddmStructure.structureId";
5698            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT DISTINCT {ddmStructure.*} FROM DDMStructure ddmStructure WHERE ";
5699            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1 =
5700                    "SELECT {DDMStructure.*} FROM (SELECT DISTINCT ddmStructure.structureId FROM DDMStructure ddmStructure WHERE ";
5701            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2 =
5702                    ") TEMP_TABLE INNER JOIN DDMStructure ON TEMP_TABLE.structureId = DDMStructure.structureId";
5703            private static final String _FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(DISTINCT ddmStructure.structureId) AS COUNT_VALUE FROM DDMStructure ddmStructure WHERE ";
5704            private static final String _FILTER_ENTITY_ALIAS = "ddmStructure";
5705            private static final String _FILTER_ENTITY_TABLE = "DDMStructure";
5706            private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStructure.";
5707            private static final String _ORDER_BY_ENTITY_TABLE = "DDMStructure.";
5708            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStructure exists with the primary key ";
5709            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStructure exists with the key {";
5710            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5711            private static Log _log = LogFactoryUtil.getLog(DDMStructurePersistenceImpl.class);
5712            private static DDMStructure _nullDDMStructure = new DDMStructureImpl() {
5713                            @Override
5714                            public Object clone() {
5715                                    return this;
5716                            }
5717    
5718                            @Override
5719                            public CacheModel<DDMStructure> toCacheModel() {
5720                                    return _nullDDMStructureCacheModel;
5721                            }
5722                    };
5723    
5724            private static CacheModel<DDMStructure> _nullDDMStructureCacheModel = new CacheModel<DDMStructure>() {
5725                            public DDMStructure toEntityModel() {
5726                                    return _nullDDMStructure;
5727                            }
5728                    };
5729    }