001    /**
002     * Copyright (c) 2000-2013 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.kernel.bean.BeanReference;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.ArrayUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
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.UnmodifiableList;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041    import com.liferay.portal.model.CacheModel;
042    import com.liferay.portal.model.ModelListener;
043    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    import com.liferay.portal.service.persistence.impl.TableMapper;
046    import com.liferay.portal.service.persistence.impl.TableMapperFactory;
047    
048    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
049    import com.liferay.portlet.dynamicdatamapping.NoSuchStructureException;
050    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
051    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl;
052    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    import java.util.Set;
060    
061    /**
062     * The persistence implementation for the d d m structure service.
063     *
064     * <p>
065     * Caching information and settings can be found in <code>portal.properties</code>
066     * </p>
067     *
068     * @author Brian Wing Shun Chan
069     * @see DDMStructurePersistence
070     * @see DDMStructureUtil
071     * @generated
072     */
073    public class DDMStructurePersistenceImpl extends BasePersistenceImpl<DDMStructure>
074            implements DDMStructurePersistence {
075            /*
076             * NOTE FOR DEVELOPERS:
077             *
078             * 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.
079             */
080            public static final String FINDER_CLASS_NAME_ENTITY = DDMStructureImpl.class.getName();
081            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List1";
083            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List2";
085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
086                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
089                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
092                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
095                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
097                            new String[] {
098                                    String.class.getName(),
099                                    
100                            Integer.class.getName(), Integer.class.getName(),
101                                    OrderByComparator.class.getName()
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
104                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106                            new String[] { String.class.getName() },
107                            DDMStructureModelImpl.UUID_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
109                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111                            new String[] { String.class.getName() });
112    
113            /**
114             * Returns all the d d m structures where uuid = &#63;.
115             *
116             * @param uuid the uuid
117             * @return the matching d d m structures
118             * @throws SystemException if a system exception occurred
119             */
120            @Override
121            public List<DDMStructure> findByUuid(String uuid) throws SystemException {
122                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123            }
124    
125            /**
126             * Returns a range of all the d d m structures where uuid = &#63;.
127             *
128             * <p>
129             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
130             * </p>
131             *
132             * @param uuid the uuid
133             * @param start the lower bound of the range of d d m structures
134             * @param end the upper bound of the range of d d m structures (not inclusive)
135             * @return the range of matching d d m structures
136             * @throws SystemException if a system exception occurred
137             */
138            @Override
139            public List<DDMStructure> findByUuid(String uuid, int start, int end)
140                    throws SystemException {
141                    return findByUuid(uuid, start, end, null);
142            }
143    
144            /**
145             * Returns an ordered range of all the d d m structures where uuid = &#63;.
146             *
147             * <p>
148             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
149             * </p>
150             *
151             * @param uuid the uuid
152             * @param start the lower bound of the range of d d m structures
153             * @param end the upper bound of the range of d d m structures (not inclusive)
154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
155             * @return the ordered range of matching d d m structures
156             * @throws SystemException if a system exception occurred
157             */
158            @Override
159            public List<DDMStructure> findByUuid(String uuid, int start, int end,
160                    OrderByComparator orderByComparator) throws SystemException {
161                    boolean pagination = true;
162                    FinderPath finderPath = null;
163                    Object[] finderArgs = null;
164    
165                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166                                    (orderByComparator == null)) {
167                            pagination = false;
168                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
169                            finderArgs = new Object[] { uuid };
170                    }
171                    else {
172                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
173                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
174                    }
175    
176                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
177                                    finderArgs, this);
178    
179                    if ((list != null) && !list.isEmpty()) {
180                            for (DDMStructure ddmStructure : list) {
181                                    if (!Validator.equals(uuid, ddmStructure.getUuid())) {
182                                            list = null;
183    
184                                            break;
185                                    }
186                            }
187                    }
188    
189                    if (list == null) {
190                            StringBundler query = null;
191    
192                            if (orderByComparator != null) {
193                                    query = new StringBundler(3 +
194                                                    (orderByComparator.getOrderByFields().length * 3));
195                            }
196                            else {
197                                    query = new StringBundler(3);
198                            }
199    
200                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
201    
202                            boolean bindUuid = false;
203    
204                            if (uuid == null) {
205                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
206                            }
207                            else if (uuid.equals(StringPool.BLANK)) {
208                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
209                            }
210                            else {
211                                    bindUuid = true;
212    
213                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
214                            }
215    
216                            if (orderByComparator != null) {
217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
218                                            orderByComparator);
219                            }
220                            else
221                             if (pagination) {
222                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
223                            }
224    
225                            String sql = query.toString();
226    
227                            Session session = null;
228    
229                            try {
230                                    session = openSession();
231    
232                                    Query q = session.createQuery(sql);
233    
234                                    QueryPos qPos = QueryPos.getInstance(q);
235    
236                                    if (bindUuid) {
237                                            qPos.add(uuid);
238                                    }
239    
240                                    if (!pagination) {
241                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
242                                                            start, end, false);
243    
244                                            Collections.sort(list);
245    
246                                            list = new UnmodifiableList<DDMStructure>(list);
247                                    }
248                                    else {
249                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
250                                                            start, end);
251                                    }
252    
253                                    cacheResult(list);
254    
255                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
256                            }
257                            catch (Exception e) {
258                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
259    
260                                    throw processException(e);
261                            }
262                            finally {
263                                    closeSession(session);
264                            }
265                    }
266    
267                    return list;
268            }
269    
270            /**
271             * Returns the first d d m structure in the ordered set where uuid = &#63;.
272             *
273             * @param uuid the uuid
274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
275             * @return the first matching d d m structure
276             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
277             * @throws SystemException if a system exception occurred
278             */
279            @Override
280            public DDMStructure findByUuid_First(String uuid,
281                    OrderByComparator orderByComparator)
282                    throws NoSuchStructureException, SystemException {
283                    DDMStructure ddmStructure = fetchByUuid_First(uuid, orderByComparator);
284    
285                    if (ddmStructure != null) {
286                            return ddmStructure;
287                    }
288    
289                    StringBundler msg = new StringBundler(4);
290    
291                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
292    
293                    msg.append("uuid=");
294                    msg.append(uuid);
295    
296                    msg.append(StringPool.CLOSE_CURLY_BRACE);
297    
298                    throw new NoSuchStructureException(msg.toString());
299            }
300    
301            /**
302             * Returns the first d d m structure in the ordered set where uuid = &#63;.
303             *
304             * @param uuid the uuid
305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
306             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
307             * @throws SystemException if a system exception occurred
308             */
309            @Override
310            public DDMStructure fetchByUuid_First(String uuid,
311                    OrderByComparator orderByComparator) throws SystemException {
312                    List<DDMStructure> list = findByUuid(uuid, 0, 1, orderByComparator);
313    
314                    if (!list.isEmpty()) {
315                            return list.get(0);
316                    }
317    
318                    return null;
319            }
320    
321            /**
322             * Returns the last d d m structure in the ordered set where uuid = &#63;.
323             *
324             * @param uuid the uuid
325             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
326             * @return the last matching d d m structure
327             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
328             * @throws SystemException if a system exception occurred
329             */
330            @Override
331            public DDMStructure findByUuid_Last(String uuid,
332                    OrderByComparator orderByComparator)
333                    throws NoSuchStructureException, SystemException {
334                    DDMStructure ddmStructure = fetchByUuid_Last(uuid, orderByComparator);
335    
336                    if (ddmStructure != null) {
337                            return ddmStructure;
338                    }
339    
340                    StringBundler msg = new StringBundler(4);
341    
342                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
343    
344                    msg.append("uuid=");
345                    msg.append(uuid);
346    
347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
348    
349                    throw new NoSuchStructureException(msg.toString());
350            }
351    
352            /**
353             * Returns the last d d m structure in the ordered set where uuid = &#63;.
354             *
355             * @param uuid the uuid
356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
357             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
358             * @throws SystemException if a system exception occurred
359             */
360            @Override
361            public DDMStructure fetchByUuid_Last(String uuid,
362                    OrderByComparator orderByComparator) throws SystemException {
363                    int count = countByUuid(uuid);
364    
365                    if (count == 0) {
366                            return null;
367                    }
368    
369                    List<DDMStructure> list = findByUuid(uuid, count - 1, count,
370                                    orderByComparator);
371    
372                    if (!list.isEmpty()) {
373                            return list.get(0);
374                    }
375    
376                    return null;
377            }
378    
379            /**
380             * Returns the d d m structures before and after the current d d m structure in the ordered set where uuid = &#63;.
381             *
382             * @param structureId the primary key of the current d d m structure
383             * @param uuid the uuid
384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
385             * @return the previous, current, and next d d m structure
386             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
387             * @throws SystemException if a system exception occurred
388             */
389            @Override
390            public DDMStructure[] findByUuid_PrevAndNext(long structureId, String uuid,
391                    OrderByComparator orderByComparator)
392                    throws NoSuchStructureException, SystemException {
393                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
394    
395                    Session session = null;
396    
397                    try {
398                            session = openSession();
399    
400                            DDMStructure[] array = new DDMStructureImpl[3];
401    
402                            array[0] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
403                                            orderByComparator, true);
404    
405                            array[1] = ddmStructure;
406    
407                            array[2] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
408                                            orderByComparator, false);
409    
410                            return array;
411                    }
412                    catch (Exception e) {
413                            throw processException(e);
414                    }
415                    finally {
416                            closeSession(session);
417                    }
418            }
419    
420            protected DDMStructure getByUuid_PrevAndNext(Session session,
421                    DDMStructure ddmStructure, String uuid,
422                    OrderByComparator orderByComparator, boolean previous) {
423                    StringBundler query = null;
424    
425                    if (orderByComparator != null) {
426                            query = new StringBundler(6 +
427                                            (orderByComparator.getOrderByFields().length * 6));
428                    }
429                    else {
430                            query = new StringBundler(3);
431                    }
432    
433                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
434    
435                    boolean bindUuid = false;
436    
437                    if (uuid == null) {
438                            query.append(_FINDER_COLUMN_UUID_UUID_1);
439                    }
440                    else if (uuid.equals(StringPool.BLANK)) {
441                            query.append(_FINDER_COLUMN_UUID_UUID_3);
442                    }
443                    else {
444                            bindUuid = true;
445    
446                            query.append(_FINDER_COLUMN_UUID_UUID_2);
447                    }
448    
449                    if (orderByComparator != null) {
450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
451    
452                            if (orderByConditionFields.length > 0) {
453                                    query.append(WHERE_AND);
454                            }
455    
456                            for (int i = 0; i < orderByConditionFields.length; i++) {
457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
458                                    query.append(orderByConditionFields[i]);
459    
460                                    if ((i + 1) < orderByConditionFields.length) {
461                                            if (orderByComparator.isAscending() ^ previous) {
462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
463                                            }
464                                            else {
465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
466                                            }
467                                    }
468                                    else {
469                                            if (orderByComparator.isAscending() ^ previous) {
470                                                    query.append(WHERE_GREATER_THAN);
471                                            }
472                                            else {
473                                                    query.append(WHERE_LESSER_THAN);
474                                            }
475                                    }
476                            }
477    
478                            query.append(ORDER_BY_CLAUSE);
479    
480                            String[] orderByFields = orderByComparator.getOrderByFields();
481    
482                            for (int i = 0; i < orderByFields.length; i++) {
483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
484                                    query.append(orderByFields[i]);
485    
486                                    if ((i + 1) < orderByFields.length) {
487                                            if (orderByComparator.isAscending() ^ previous) {
488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
489                                            }
490                                            else {
491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
492                                            }
493                                    }
494                                    else {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(ORDER_BY_ASC);
497                                            }
498                                            else {
499                                                    query.append(ORDER_BY_DESC);
500                                            }
501                                    }
502                            }
503                    }
504                    else {
505                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
506                    }
507    
508                    String sql = query.toString();
509    
510                    Query q = session.createQuery(sql);
511    
512                    q.setFirstResult(0);
513                    q.setMaxResults(2);
514    
515                    QueryPos qPos = QueryPos.getInstance(q);
516    
517                    if (bindUuid) {
518                            qPos.add(uuid);
519                    }
520    
521                    if (orderByComparator != null) {
522                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
523    
524                            for (Object value : values) {
525                                    qPos.add(value);
526                            }
527                    }
528    
529                    List<DDMStructure> list = q.list();
530    
531                    if (list.size() == 2) {
532                            return list.get(1);
533                    }
534                    else {
535                            return null;
536                    }
537            }
538    
539            /**
540             * Removes all the d d m structures where uuid = &#63; from the database.
541             *
542             * @param uuid the uuid
543             * @throws SystemException if a system exception occurred
544             */
545            @Override
546            public void removeByUuid(String uuid) throws SystemException {
547                    for (DDMStructure ddmStructure : findByUuid(uuid, QueryUtil.ALL_POS,
548                                    QueryUtil.ALL_POS, null)) {
549                            remove(ddmStructure);
550                    }
551            }
552    
553            /**
554             * Returns the number of d d m structures where uuid = &#63;.
555             *
556             * @param uuid the uuid
557             * @return the number of matching d d m structures
558             * @throws SystemException if a system exception occurred
559             */
560            @Override
561            public int countByUuid(String uuid) throws SystemException {
562                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
563    
564                    Object[] finderArgs = new Object[] { uuid };
565    
566                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
567                                    this);
568    
569                    if (count == null) {
570                            StringBundler query = new StringBundler(2);
571    
572                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
573    
574                            boolean bindUuid = false;
575    
576                            if (uuid == null) {
577                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
578                            }
579                            else if (uuid.equals(StringPool.BLANK)) {
580                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
581                            }
582                            else {
583                                    bindUuid = true;
584    
585                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
586                            }
587    
588                            String sql = query.toString();
589    
590                            Session session = null;
591    
592                            try {
593                                    session = openSession();
594    
595                                    Query q = session.createQuery(sql);
596    
597                                    QueryPos qPos = QueryPos.getInstance(q);
598    
599                                    if (bindUuid) {
600                                            qPos.add(uuid);
601                                    }
602    
603                                    count = (Long)q.uniqueResult();
604    
605                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
606                            }
607                            catch (Exception e) {
608                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
609    
610                                    throw processException(e);
611                            }
612                            finally {
613                                    closeSession(session);
614                            }
615                    }
616    
617                    return count.intValue();
618            }
619    
620            private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmStructure.uuid IS NULL";
621            private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmStructure.uuid = ?";
622            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = '')";
623            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
624                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
625                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
626                            new String[] { String.class.getName(), Long.class.getName() },
627                            DDMStructureModelImpl.UUID_COLUMN_BITMASK |
628                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
629            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
630                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
631                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
632                            new String[] { String.class.getName(), Long.class.getName() });
633    
634            /**
635             * 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.
636             *
637             * @param uuid the uuid
638             * @param groupId the group ID
639             * @return the matching d d m structure
640             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
641             * @throws SystemException if a system exception occurred
642             */
643            @Override
644            public DDMStructure findByUUID_G(String uuid, long groupId)
645                    throws NoSuchStructureException, SystemException {
646                    DDMStructure ddmStructure = fetchByUUID_G(uuid, groupId);
647    
648                    if (ddmStructure == null) {
649                            StringBundler msg = new StringBundler(6);
650    
651                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
652    
653                            msg.append("uuid=");
654                            msg.append(uuid);
655    
656                            msg.append(", groupId=");
657                            msg.append(groupId);
658    
659                            msg.append(StringPool.CLOSE_CURLY_BRACE);
660    
661                            if (_log.isWarnEnabled()) {
662                                    _log.warn(msg.toString());
663                            }
664    
665                            throw new NoSuchStructureException(msg.toString());
666                    }
667    
668                    return ddmStructure;
669            }
670    
671            /**
672             * 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.
673             *
674             * @param uuid the uuid
675             * @param groupId the group ID
676             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
677             * @throws SystemException if a system exception occurred
678             */
679            @Override
680            public DDMStructure fetchByUUID_G(String uuid, long groupId)
681                    throws SystemException {
682                    return fetchByUUID_G(uuid, groupId, true);
683            }
684    
685            /**
686             * 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.
687             *
688             * @param uuid the uuid
689             * @param groupId the group ID
690             * @param retrieveFromCache whether to use the finder cache
691             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
692             * @throws SystemException if a system exception occurred
693             */
694            @Override
695            public DDMStructure fetchByUUID_G(String uuid, long groupId,
696                    boolean retrieveFromCache) throws SystemException {
697                    Object[] finderArgs = new Object[] { uuid, groupId };
698    
699                    Object result = null;
700    
701                    if (retrieveFromCache) {
702                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
703                                            finderArgs, this);
704                    }
705    
706                    if (result instanceof DDMStructure) {
707                            DDMStructure ddmStructure = (DDMStructure)result;
708    
709                            if (!Validator.equals(uuid, ddmStructure.getUuid()) ||
710                                            (groupId != ddmStructure.getGroupId())) {
711                                    result = null;
712                            }
713                    }
714    
715                    if (result == null) {
716                            StringBundler query = new StringBundler(4);
717    
718                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
719    
720                            boolean bindUuid = false;
721    
722                            if (uuid == null) {
723                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
724                            }
725                            else if (uuid.equals(StringPool.BLANK)) {
726                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
727                            }
728                            else {
729                                    bindUuid = true;
730    
731                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
732                            }
733    
734                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
735    
736                            String sql = query.toString();
737    
738                            Session session = null;
739    
740                            try {
741                                    session = openSession();
742    
743                                    Query q = session.createQuery(sql);
744    
745                                    QueryPos qPos = QueryPos.getInstance(q);
746    
747                                    if (bindUuid) {
748                                            qPos.add(uuid);
749                                    }
750    
751                                    qPos.add(groupId);
752    
753                                    List<DDMStructure> list = q.list();
754    
755                                    if (list.isEmpty()) {
756                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                                    finderArgs, list);
758                                    }
759                                    else {
760                                            DDMStructure ddmStructure = list.get(0);
761    
762                                            result = ddmStructure;
763    
764                                            cacheResult(ddmStructure);
765    
766                                            if ((ddmStructure.getUuid() == null) ||
767                                                            !ddmStructure.getUuid().equals(uuid) ||
768                                                            (ddmStructure.getGroupId() != groupId)) {
769                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
770                                                            finderArgs, ddmStructure);
771                                            }
772                                    }
773                            }
774                            catch (Exception e) {
775                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
776                                            finderArgs);
777    
778                                    throw processException(e);
779                            }
780                            finally {
781                                    closeSession(session);
782                            }
783                    }
784    
785                    if (result instanceof List<?>) {
786                            return null;
787                    }
788                    else {
789                            return (DDMStructure)result;
790                    }
791            }
792    
793            /**
794             * Removes the d d m structure where uuid = &#63; and groupId = &#63; from the database.
795             *
796             * @param uuid the uuid
797             * @param groupId the group ID
798             * @return the d d m structure that was removed
799             * @throws SystemException if a system exception occurred
800             */
801            @Override
802            public DDMStructure removeByUUID_G(String uuid, long groupId)
803                    throws NoSuchStructureException, SystemException {
804                    DDMStructure ddmStructure = findByUUID_G(uuid, groupId);
805    
806                    return remove(ddmStructure);
807            }
808    
809            /**
810             * Returns the number of d d m structures where uuid = &#63; and groupId = &#63;.
811             *
812             * @param uuid the uuid
813             * @param groupId the group ID
814             * @return the number of matching d d m structures
815             * @throws SystemException if a system exception occurred
816             */
817            @Override
818            public int countByUUID_G(String uuid, long groupId)
819                    throws SystemException {
820                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
821    
822                    Object[] finderArgs = new Object[] { uuid, groupId };
823    
824                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
825                                    this);
826    
827                    if (count == null) {
828                            StringBundler query = new StringBundler(3);
829    
830                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
831    
832                            boolean bindUuid = false;
833    
834                            if (uuid == null) {
835                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
836                            }
837                            else if (uuid.equals(StringPool.BLANK)) {
838                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
839                            }
840                            else {
841                                    bindUuid = true;
842    
843                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
844                            }
845    
846                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
847    
848                            String sql = query.toString();
849    
850                            Session session = null;
851    
852                            try {
853                                    session = openSession();
854    
855                                    Query q = session.createQuery(sql);
856    
857                                    QueryPos qPos = QueryPos.getInstance(q);
858    
859                                    if (bindUuid) {
860                                            qPos.add(uuid);
861                                    }
862    
863                                    qPos.add(groupId);
864    
865                                    count = (Long)q.uniqueResult();
866    
867                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
868                            }
869                            catch (Exception e) {
870                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
871    
872                                    throw processException(e);
873                            }
874                            finally {
875                                    closeSession(session);
876                            }
877                    }
878    
879                    return count.intValue();
880            }
881    
882            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddmStructure.uuid IS NULL AND ";
883            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddmStructure.uuid = ? AND ";
884            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = '') AND ";
885            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddmStructure.groupId = ?";
886            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
887                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
888                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
889                            new String[] {
890                                    String.class.getName(), Long.class.getName(),
891                                    
892                            Integer.class.getName(), Integer.class.getName(),
893                                    OrderByComparator.class.getName()
894                            });
895            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
896                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
897                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
898                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
899                            new String[] { String.class.getName(), Long.class.getName() },
900                            DDMStructureModelImpl.UUID_COLUMN_BITMASK |
901                            DDMStructureModelImpl.COMPANYID_COLUMN_BITMASK);
902            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
903                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
904                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
905                            new String[] { String.class.getName(), Long.class.getName() });
906    
907            /**
908             * Returns all the d d m structures where uuid = &#63; and companyId = &#63;.
909             *
910             * @param uuid the uuid
911             * @param companyId the company ID
912             * @return the matching d d m structures
913             * @throws SystemException if a system exception occurred
914             */
915            @Override
916            public List<DDMStructure> findByUuid_C(String uuid, long companyId)
917                    throws SystemException {
918                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
919                            QueryUtil.ALL_POS, null);
920            }
921    
922            /**
923             * Returns a range of all the d d m structures where uuid = &#63; and companyId = &#63;.
924             *
925             * <p>
926             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
927             * </p>
928             *
929             * @param uuid the uuid
930             * @param companyId the company ID
931             * @param start the lower bound of the range of d d m structures
932             * @param end the upper bound of the range of d d m structures (not inclusive)
933             * @return the range of matching d d m structures
934             * @throws SystemException if a system exception occurred
935             */
936            @Override
937            public List<DDMStructure> findByUuid_C(String uuid, long companyId,
938                    int start, int end) throws SystemException {
939                    return findByUuid_C(uuid, companyId, start, end, null);
940            }
941    
942            /**
943             * Returns an ordered range of all the d d m structures where uuid = &#63; and companyId = &#63;.
944             *
945             * <p>
946             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
947             * </p>
948             *
949             * @param uuid the uuid
950             * @param companyId the company ID
951             * @param start the lower bound of the range of d d m structures
952             * @param end the upper bound of the range of d d m structures (not inclusive)
953             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
954             * @return the ordered range of matching d d m structures
955             * @throws SystemException if a system exception occurred
956             */
957            @Override
958            public List<DDMStructure> findByUuid_C(String uuid, long companyId,
959                    int start, int end, OrderByComparator orderByComparator)
960                    throws SystemException {
961                    boolean pagination = true;
962                    FinderPath finderPath = null;
963                    Object[] finderArgs = null;
964    
965                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
966                                    (orderByComparator == null)) {
967                            pagination = false;
968                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
969                            finderArgs = new Object[] { uuid, companyId };
970                    }
971                    else {
972                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
973                            finderArgs = new Object[] {
974                                            uuid, companyId,
975                                            
976                                            start, end, orderByComparator
977                                    };
978                    }
979    
980                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
981                                    finderArgs, this);
982    
983                    if ((list != null) && !list.isEmpty()) {
984                            for (DDMStructure ddmStructure : list) {
985                                    if (!Validator.equals(uuid, ddmStructure.getUuid()) ||
986                                                    (companyId != ddmStructure.getCompanyId())) {
987                                            list = null;
988    
989                                            break;
990                                    }
991                            }
992                    }
993    
994                    if (list == null) {
995                            StringBundler query = null;
996    
997                            if (orderByComparator != null) {
998                                    query = new StringBundler(4 +
999                                                    (orderByComparator.getOrderByFields().length * 3));
1000                            }
1001                            else {
1002                                    query = new StringBundler(4);
1003                            }
1004    
1005                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1006    
1007                            boolean bindUuid = false;
1008    
1009                            if (uuid == null) {
1010                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1011                            }
1012                            else if (uuid.equals(StringPool.BLANK)) {
1013                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1014                            }
1015                            else {
1016                                    bindUuid = true;
1017    
1018                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1019                            }
1020    
1021                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1022    
1023                            if (orderByComparator != null) {
1024                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1025                                            orderByComparator);
1026                            }
1027                            else
1028                             if (pagination) {
1029                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
1030                            }
1031    
1032                            String sql = query.toString();
1033    
1034                            Session session = null;
1035    
1036                            try {
1037                                    session = openSession();
1038    
1039                                    Query q = session.createQuery(sql);
1040    
1041                                    QueryPos qPos = QueryPos.getInstance(q);
1042    
1043                                    if (bindUuid) {
1044                                            qPos.add(uuid);
1045                                    }
1046    
1047                                    qPos.add(companyId);
1048    
1049                                    if (!pagination) {
1050                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1051                                                            start, end, false);
1052    
1053                                            Collections.sort(list);
1054    
1055                                            list = new UnmodifiableList<DDMStructure>(list);
1056                                    }
1057                                    else {
1058                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1059                                                            start, end);
1060                                    }
1061    
1062                                    cacheResult(list);
1063    
1064                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1065                            }
1066                            catch (Exception e) {
1067                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1068    
1069                                    throw processException(e);
1070                            }
1071                            finally {
1072                                    closeSession(session);
1073                            }
1074                    }
1075    
1076                    return list;
1077            }
1078    
1079            /**
1080             * Returns the first d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1081             *
1082             * @param uuid the uuid
1083             * @param companyId the company ID
1084             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1085             * @return the first matching d d m structure
1086             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1087             * @throws SystemException if a system exception occurred
1088             */
1089            @Override
1090            public DDMStructure findByUuid_C_First(String uuid, long companyId,
1091                    OrderByComparator orderByComparator)
1092                    throws NoSuchStructureException, SystemException {
1093                    DDMStructure ddmStructure = fetchByUuid_C_First(uuid, companyId,
1094                                    orderByComparator);
1095    
1096                    if (ddmStructure != null) {
1097                            return ddmStructure;
1098                    }
1099    
1100                    StringBundler msg = new StringBundler(6);
1101    
1102                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1103    
1104                    msg.append("uuid=");
1105                    msg.append(uuid);
1106    
1107                    msg.append(", companyId=");
1108                    msg.append(companyId);
1109    
1110                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1111    
1112                    throw new NoSuchStructureException(msg.toString());
1113            }
1114    
1115            /**
1116             * Returns the first d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1117             *
1118             * @param uuid the uuid
1119             * @param companyId the company ID
1120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1121             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1122             * @throws SystemException if a system exception occurred
1123             */
1124            @Override
1125            public DDMStructure fetchByUuid_C_First(String uuid, long companyId,
1126                    OrderByComparator orderByComparator) throws SystemException {
1127                    List<DDMStructure> list = findByUuid_C(uuid, companyId, 0, 1,
1128                                    orderByComparator);
1129    
1130                    if (!list.isEmpty()) {
1131                            return list.get(0);
1132                    }
1133    
1134                    return null;
1135            }
1136    
1137            /**
1138             * Returns the last d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1139             *
1140             * @param uuid the uuid
1141             * @param companyId the company ID
1142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1143             * @return the last matching d d m structure
1144             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1145             * @throws SystemException if a system exception occurred
1146             */
1147            @Override
1148            public DDMStructure findByUuid_C_Last(String uuid, long companyId,
1149                    OrderByComparator orderByComparator)
1150                    throws NoSuchStructureException, SystemException {
1151                    DDMStructure ddmStructure = fetchByUuid_C_Last(uuid, companyId,
1152                                    orderByComparator);
1153    
1154                    if (ddmStructure != null) {
1155                            return ddmStructure;
1156                    }
1157    
1158                    StringBundler msg = new StringBundler(6);
1159    
1160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1161    
1162                    msg.append("uuid=");
1163                    msg.append(uuid);
1164    
1165                    msg.append(", companyId=");
1166                    msg.append(companyId);
1167    
1168                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1169    
1170                    throw new NoSuchStructureException(msg.toString());
1171            }
1172    
1173            /**
1174             * Returns the last d d m structure in the ordered set where uuid = &#63; and companyId = &#63;.
1175             *
1176             * @param uuid the uuid
1177             * @param companyId the company ID
1178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1179             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1180             * @throws SystemException if a system exception occurred
1181             */
1182            @Override
1183            public DDMStructure fetchByUuid_C_Last(String uuid, long companyId,
1184                    OrderByComparator orderByComparator) throws SystemException {
1185                    int count = countByUuid_C(uuid, companyId);
1186    
1187                    if (count == 0) {
1188                            return null;
1189                    }
1190    
1191                    List<DDMStructure> list = findByUuid_C(uuid, companyId, count - 1,
1192                                    count, orderByComparator);
1193    
1194                    if (!list.isEmpty()) {
1195                            return list.get(0);
1196                    }
1197    
1198                    return null;
1199            }
1200    
1201            /**
1202             * 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;.
1203             *
1204             * @param structureId the primary key of the current d d m structure
1205             * @param uuid the uuid
1206             * @param companyId the company ID
1207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1208             * @return the previous, current, and next d d m structure
1209             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
1210             * @throws SystemException if a system exception occurred
1211             */
1212            @Override
1213            public DDMStructure[] findByUuid_C_PrevAndNext(long structureId,
1214                    String uuid, long companyId, OrderByComparator orderByComparator)
1215                    throws NoSuchStructureException, SystemException {
1216                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
1217    
1218                    Session session = null;
1219    
1220                    try {
1221                            session = openSession();
1222    
1223                            DDMStructure[] array = new DDMStructureImpl[3];
1224    
1225                            array[0] = getByUuid_C_PrevAndNext(session, ddmStructure, uuid,
1226                                            companyId, orderByComparator, true);
1227    
1228                            array[1] = ddmStructure;
1229    
1230                            array[2] = getByUuid_C_PrevAndNext(session, ddmStructure, uuid,
1231                                            companyId, orderByComparator, false);
1232    
1233                            return array;
1234                    }
1235                    catch (Exception e) {
1236                            throw processException(e);
1237                    }
1238                    finally {
1239                            closeSession(session);
1240                    }
1241            }
1242    
1243            protected DDMStructure getByUuid_C_PrevAndNext(Session session,
1244                    DDMStructure ddmStructure, String uuid, long companyId,
1245                    OrderByComparator orderByComparator, boolean previous) {
1246                    StringBundler query = null;
1247    
1248                    if (orderByComparator != null) {
1249                            query = new StringBundler(6 +
1250                                            (orderByComparator.getOrderByFields().length * 6));
1251                    }
1252                    else {
1253                            query = new StringBundler(3);
1254                    }
1255    
1256                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1257    
1258                    boolean bindUuid = false;
1259    
1260                    if (uuid == null) {
1261                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1262                    }
1263                    else if (uuid.equals(StringPool.BLANK)) {
1264                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1265                    }
1266                    else {
1267                            bindUuid = true;
1268    
1269                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1270                    }
1271    
1272                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1273    
1274                    if (orderByComparator != null) {
1275                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1276    
1277                            if (orderByConditionFields.length > 0) {
1278                                    query.append(WHERE_AND);
1279                            }
1280    
1281                            for (int i = 0; i < orderByConditionFields.length; i++) {
1282                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1283                                    query.append(orderByConditionFields[i]);
1284    
1285                                    if ((i + 1) < orderByConditionFields.length) {
1286                                            if (orderByComparator.isAscending() ^ previous) {
1287                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1288                                            }
1289                                            else {
1290                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1291                                            }
1292                                    }
1293                                    else {
1294                                            if (orderByComparator.isAscending() ^ previous) {
1295                                                    query.append(WHERE_GREATER_THAN);
1296                                            }
1297                                            else {
1298                                                    query.append(WHERE_LESSER_THAN);
1299                                            }
1300                                    }
1301                            }
1302    
1303                            query.append(ORDER_BY_CLAUSE);
1304    
1305                            String[] orderByFields = orderByComparator.getOrderByFields();
1306    
1307                            for (int i = 0; i < orderByFields.length; i++) {
1308                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1309                                    query.append(orderByFields[i]);
1310    
1311                                    if ((i + 1) < orderByFields.length) {
1312                                            if (orderByComparator.isAscending() ^ previous) {
1313                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1314                                            }
1315                                            else {
1316                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1317                                            }
1318                                    }
1319                                    else {
1320                                            if (orderByComparator.isAscending() ^ previous) {
1321                                                    query.append(ORDER_BY_ASC);
1322                                            }
1323                                            else {
1324                                                    query.append(ORDER_BY_DESC);
1325                                            }
1326                                    }
1327                            }
1328                    }
1329                    else {
1330                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
1331                    }
1332    
1333                    String sql = query.toString();
1334    
1335                    Query q = session.createQuery(sql);
1336    
1337                    q.setFirstResult(0);
1338                    q.setMaxResults(2);
1339    
1340                    QueryPos qPos = QueryPos.getInstance(q);
1341    
1342                    if (bindUuid) {
1343                            qPos.add(uuid);
1344                    }
1345    
1346                    qPos.add(companyId);
1347    
1348                    if (orderByComparator != null) {
1349                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1350    
1351                            for (Object value : values) {
1352                                    qPos.add(value);
1353                            }
1354                    }
1355    
1356                    List<DDMStructure> list = q.list();
1357    
1358                    if (list.size() == 2) {
1359                            return list.get(1);
1360                    }
1361                    else {
1362                            return null;
1363                    }
1364            }
1365    
1366            /**
1367             * Removes all the d d m structures where uuid = &#63; and companyId = &#63; from the database.
1368             *
1369             * @param uuid the uuid
1370             * @param companyId the company ID
1371             * @throws SystemException if a system exception occurred
1372             */
1373            @Override
1374            public void removeByUuid_C(String uuid, long companyId)
1375                    throws SystemException {
1376                    for (DDMStructure ddmStructure : findByUuid_C(uuid, companyId,
1377                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1378                            remove(ddmStructure);
1379                    }
1380            }
1381    
1382            /**
1383             * Returns the number of d d m structures where uuid = &#63; and companyId = &#63;.
1384             *
1385             * @param uuid the uuid
1386             * @param companyId the company ID
1387             * @return the number of matching d d m structures
1388             * @throws SystemException if a system exception occurred
1389             */
1390            @Override
1391            public int countByUuid_C(String uuid, long companyId)
1392                    throws SystemException {
1393                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1394    
1395                    Object[] finderArgs = new Object[] { uuid, companyId };
1396    
1397                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1398                                    this);
1399    
1400                    if (count == null) {
1401                            StringBundler query = new StringBundler(3);
1402    
1403                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
1404    
1405                            boolean bindUuid = false;
1406    
1407                            if (uuid == null) {
1408                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1409                            }
1410                            else if (uuid.equals(StringPool.BLANK)) {
1411                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1412                            }
1413                            else {
1414                                    bindUuid = true;
1415    
1416                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1417                            }
1418    
1419                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1420    
1421                            String sql = query.toString();
1422    
1423                            Session session = null;
1424    
1425                            try {
1426                                    session = openSession();
1427    
1428                                    Query q = session.createQuery(sql);
1429    
1430                                    QueryPos qPos = QueryPos.getInstance(q);
1431    
1432                                    if (bindUuid) {
1433                                            qPos.add(uuid);
1434                                    }
1435    
1436                                    qPos.add(companyId);
1437    
1438                                    count = (Long)q.uniqueResult();
1439    
1440                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1441                            }
1442                            catch (Exception e) {
1443                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1444    
1445                                    throw processException(e);
1446                            }
1447                            finally {
1448                                    closeSession(session);
1449                            }
1450                    }
1451    
1452                    return count.intValue();
1453            }
1454    
1455            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "ddmStructure.uuid IS NULL AND ";
1456            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ddmStructure.uuid = ? AND ";
1457            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = '') AND ";
1458            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ddmStructure.companyId = ?";
1459            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
1460                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
1461                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1462                            new String[] {
1463                                    Long.class.getName(),
1464                                    
1465                            Integer.class.getName(), Integer.class.getName(),
1466                                    OrderByComparator.class.getName()
1467                            });
1468            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1469                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
1470                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
1471                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1472                            new String[] { Long.class.getName() },
1473                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
1474            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
1475                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
1476                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1477                            new String[] { Long.class.getName() });
1478            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
1479                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
1480                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
1481                            new String[] { Long.class.getName() });
1482    
1483            /**
1484             * Returns all the d d m structures where groupId = &#63;.
1485             *
1486             * @param groupId the group ID
1487             * @return the matching d d m structures
1488             * @throws SystemException if a system exception occurred
1489             */
1490            @Override
1491            public List<DDMStructure> findByGroupId(long groupId)
1492                    throws SystemException {
1493                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1494            }
1495    
1496            /**
1497             * Returns a range of all the d d m structures where groupId = &#63;.
1498             *
1499             * <p>
1500             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1501             * </p>
1502             *
1503             * @param groupId the group ID
1504             * @param start the lower bound of the range of d d m structures
1505             * @param end the upper bound of the range of d d m structures (not inclusive)
1506             * @return the range of matching d d m structures
1507             * @throws SystemException if a system exception occurred
1508             */
1509            @Override
1510            public List<DDMStructure> findByGroupId(long groupId, int start, int end)
1511                    throws SystemException {
1512                    return findByGroupId(groupId, start, end, null);
1513            }
1514    
1515            /**
1516             * Returns an ordered range of all the d d m structures where groupId = &#63;.
1517             *
1518             * <p>
1519             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1520             * </p>
1521             *
1522             * @param groupId the group ID
1523             * @param start the lower bound of the range of d d m structures
1524             * @param end the upper bound of the range of d d m structures (not inclusive)
1525             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1526             * @return the ordered range of matching d d m structures
1527             * @throws SystemException if a system exception occurred
1528             */
1529            @Override
1530            public List<DDMStructure> findByGroupId(long groupId, int start, int end,
1531                    OrderByComparator orderByComparator) throws SystemException {
1532                    boolean pagination = true;
1533                    FinderPath finderPath = null;
1534                    Object[] finderArgs = null;
1535    
1536                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1537                                    (orderByComparator == null)) {
1538                            pagination = false;
1539                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1540                            finderArgs = new Object[] { groupId };
1541                    }
1542                    else {
1543                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1544                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1545                    }
1546    
1547                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
1548                                    finderArgs, this);
1549    
1550                    if ((list != null) && !list.isEmpty()) {
1551                            for (DDMStructure ddmStructure : list) {
1552                                    if ((groupId != ddmStructure.getGroupId())) {
1553                                            list = null;
1554    
1555                                            break;
1556                                    }
1557                            }
1558                    }
1559    
1560                    if (list == null) {
1561                            StringBundler query = null;
1562    
1563                            if (orderByComparator != null) {
1564                                    query = new StringBundler(3 +
1565                                                    (orderByComparator.getOrderByFields().length * 3));
1566                            }
1567                            else {
1568                                    query = new StringBundler(3);
1569                            }
1570    
1571                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1572    
1573                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1574    
1575                            if (orderByComparator != null) {
1576                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1577                                            orderByComparator);
1578                            }
1579                            else
1580                             if (pagination) {
1581                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
1582                            }
1583    
1584                            String sql = query.toString();
1585    
1586                            Session session = null;
1587    
1588                            try {
1589                                    session = openSession();
1590    
1591                                    Query q = session.createQuery(sql);
1592    
1593                                    QueryPos qPos = QueryPos.getInstance(q);
1594    
1595                                    qPos.add(groupId);
1596    
1597                                    if (!pagination) {
1598                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1599                                                            start, end, false);
1600    
1601                                            Collections.sort(list);
1602    
1603                                            list = new UnmodifiableList<DDMStructure>(list);
1604                                    }
1605                                    else {
1606                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1607                                                            start, end);
1608                                    }
1609    
1610                                    cacheResult(list);
1611    
1612                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1613                            }
1614                            catch (Exception e) {
1615                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1616    
1617                                    throw processException(e);
1618                            }
1619                            finally {
1620                                    closeSession(session);
1621                            }
1622                    }
1623    
1624                    return list;
1625            }
1626    
1627            /**
1628             * Returns the first d d m structure in the ordered set where groupId = &#63;.
1629             *
1630             * @param groupId the group ID
1631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1632             * @return the first matching d d m structure
1633             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1634             * @throws SystemException if a system exception occurred
1635             */
1636            @Override
1637            public DDMStructure findByGroupId_First(long groupId,
1638                    OrderByComparator orderByComparator)
1639                    throws NoSuchStructureException, SystemException {
1640                    DDMStructure ddmStructure = fetchByGroupId_First(groupId,
1641                                    orderByComparator);
1642    
1643                    if (ddmStructure != null) {
1644                            return ddmStructure;
1645                    }
1646    
1647                    StringBundler msg = new StringBundler(4);
1648    
1649                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1650    
1651                    msg.append("groupId=");
1652                    msg.append(groupId);
1653    
1654                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1655    
1656                    throw new NoSuchStructureException(msg.toString());
1657            }
1658    
1659            /**
1660             * Returns the first d d m structure in the ordered set where groupId = &#63;.
1661             *
1662             * @param groupId the group ID
1663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1664             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1665             * @throws SystemException if a system exception occurred
1666             */
1667            @Override
1668            public DDMStructure fetchByGroupId_First(long groupId,
1669                    OrderByComparator orderByComparator) throws SystemException {
1670                    List<DDMStructure> list = findByGroupId(groupId, 0, 1, orderByComparator);
1671    
1672                    if (!list.isEmpty()) {
1673                            return list.get(0);
1674                    }
1675    
1676                    return null;
1677            }
1678    
1679            /**
1680             * Returns the last d d m structure in the ordered set where groupId = &#63;.
1681             *
1682             * @param groupId the group ID
1683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1684             * @return the last matching d d m structure
1685             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
1686             * @throws SystemException if a system exception occurred
1687             */
1688            @Override
1689            public DDMStructure findByGroupId_Last(long groupId,
1690                    OrderByComparator orderByComparator)
1691                    throws NoSuchStructureException, SystemException {
1692                    DDMStructure ddmStructure = fetchByGroupId_Last(groupId,
1693                                    orderByComparator);
1694    
1695                    if (ddmStructure != null) {
1696                            return ddmStructure;
1697                    }
1698    
1699                    StringBundler msg = new StringBundler(4);
1700    
1701                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1702    
1703                    msg.append("groupId=");
1704                    msg.append(groupId);
1705    
1706                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1707    
1708                    throw new NoSuchStructureException(msg.toString());
1709            }
1710    
1711            /**
1712             * Returns the last d d m structure in the ordered set where groupId = &#63;.
1713             *
1714             * @param groupId the group ID
1715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1716             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
1717             * @throws SystemException if a system exception occurred
1718             */
1719            @Override
1720            public DDMStructure fetchByGroupId_Last(long groupId,
1721                    OrderByComparator orderByComparator) throws SystemException {
1722                    int count = countByGroupId(groupId);
1723    
1724                    if (count == 0) {
1725                            return null;
1726                    }
1727    
1728                    List<DDMStructure> list = findByGroupId(groupId, count - 1, count,
1729                                    orderByComparator);
1730    
1731                    if (!list.isEmpty()) {
1732                            return list.get(0);
1733                    }
1734    
1735                    return null;
1736            }
1737    
1738            /**
1739             * Returns the d d m structures before and after the current d d m structure in the ordered set where groupId = &#63;.
1740             *
1741             * @param structureId the primary key of the current d d m structure
1742             * @param groupId the group ID
1743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1744             * @return the previous, current, and next d d m structure
1745             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
1746             * @throws SystemException if a system exception occurred
1747             */
1748            @Override
1749            public DDMStructure[] findByGroupId_PrevAndNext(long structureId,
1750                    long groupId, OrderByComparator orderByComparator)
1751                    throws NoSuchStructureException, SystemException {
1752                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
1753    
1754                    Session session = null;
1755    
1756                    try {
1757                            session = openSession();
1758    
1759                            DDMStructure[] array = new DDMStructureImpl[3];
1760    
1761                            array[0] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
1762                                            orderByComparator, true);
1763    
1764                            array[1] = ddmStructure;
1765    
1766                            array[2] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
1767                                            orderByComparator, false);
1768    
1769                            return array;
1770                    }
1771                    catch (Exception e) {
1772                            throw processException(e);
1773                    }
1774                    finally {
1775                            closeSession(session);
1776                    }
1777            }
1778    
1779            protected DDMStructure getByGroupId_PrevAndNext(Session session,
1780                    DDMStructure ddmStructure, long groupId,
1781                    OrderByComparator orderByComparator, boolean previous) {
1782                    StringBundler query = null;
1783    
1784                    if (orderByComparator != null) {
1785                            query = new StringBundler(6 +
1786                                            (orderByComparator.getOrderByFields().length * 6));
1787                    }
1788                    else {
1789                            query = new StringBundler(3);
1790                    }
1791    
1792                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1793    
1794                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1795    
1796                    if (orderByComparator != null) {
1797                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1798    
1799                            if (orderByConditionFields.length > 0) {
1800                                    query.append(WHERE_AND);
1801                            }
1802    
1803                            for (int i = 0; i < orderByConditionFields.length; i++) {
1804                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1805                                    query.append(orderByConditionFields[i]);
1806    
1807                                    if ((i + 1) < orderByConditionFields.length) {
1808                                            if (orderByComparator.isAscending() ^ previous) {
1809                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1810                                            }
1811                                            else {
1812                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1813                                            }
1814                                    }
1815                                    else {
1816                                            if (orderByComparator.isAscending() ^ previous) {
1817                                                    query.append(WHERE_GREATER_THAN);
1818                                            }
1819                                            else {
1820                                                    query.append(WHERE_LESSER_THAN);
1821                                            }
1822                                    }
1823                            }
1824    
1825                            query.append(ORDER_BY_CLAUSE);
1826    
1827                            String[] orderByFields = orderByComparator.getOrderByFields();
1828    
1829                            for (int i = 0; i < orderByFields.length; i++) {
1830                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1831                                    query.append(orderByFields[i]);
1832    
1833                                    if ((i + 1) < orderByFields.length) {
1834                                            if (orderByComparator.isAscending() ^ previous) {
1835                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1836                                            }
1837                                            else {
1838                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1839                                            }
1840                                    }
1841                                    else {
1842                                            if (orderByComparator.isAscending() ^ previous) {
1843                                                    query.append(ORDER_BY_ASC);
1844                                            }
1845                                            else {
1846                                                    query.append(ORDER_BY_DESC);
1847                                            }
1848                                    }
1849                            }
1850                    }
1851                    else {
1852                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
1853                    }
1854    
1855                    String sql = query.toString();
1856    
1857                    Query q = session.createQuery(sql);
1858    
1859                    q.setFirstResult(0);
1860                    q.setMaxResults(2);
1861    
1862                    QueryPos qPos = QueryPos.getInstance(q);
1863    
1864                    qPos.add(groupId);
1865    
1866                    if (orderByComparator != null) {
1867                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1868    
1869                            for (Object value : values) {
1870                                    qPos.add(value);
1871                            }
1872                    }
1873    
1874                    List<DDMStructure> list = q.list();
1875    
1876                    if (list.size() == 2) {
1877                            return list.get(1);
1878                    }
1879                    else {
1880                            return null;
1881                    }
1882            }
1883    
1884            /**
1885             * Returns all the d d m structures that the user has permission to view where groupId = &#63;.
1886             *
1887             * @param groupId the group ID
1888             * @return the matching d d m structures that the user has permission to view
1889             * @throws SystemException if a system exception occurred
1890             */
1891            @Override
1892            public List<DDMStructure> filterFindByGroupId(long groupId)
1893                    throws SystemException {
1894                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1895                            QueryUtil.ALL_POS, null);
1896            }
1897    
1898            /**
1899             * Returns a range of all the d d m structures that the user has permission to view where groupId = &#63;.
1900             *
1901             * <p>
1902             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1903             * </p>
1904             *
1905             * @param groupId the group ID
1906             * @param start the lower bound of the range of d d m structures
1907             * @param end the upper bound of the range of d d m structures (not inclusive)
1908             * @return the range of matching d d m structures that the user has permission to view
1909             * @throws SystemException if a system exception occurred
1910             */
1911            @Override
1912            public List<DDMStructure> filterFindByGroupId(long groupId, int start,
1913                    int end) throws SystemException {
1914                    return filterFindByGroupId(groupId, start, end, null);
1915            }
1916    
1917            /**
1918             * Returns an ordered range of all the d d m structures that the user has permissions to view where groupId = &#63;.
1919             *
1920             * <p>
1921             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1922             * </p>
1923             *
1924             * @param groupId the group ID
1925             * @param start the lower bound of the range of d d m structures
1926             * @param end the upper bound of the range of d d m structures (not inclusive)
1927             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1928             * @return the ordered range of matching d d m structures that the user has permission to view
1929             * @throws SystemException if a system exception occurred
1930             */
1931            @Override
1932            public List<DDMStructure> filterFindByGroupId(long groupId, int start,
1933                    int end, OrderByComparator orderByComparator) throws SystemException {
1934                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1935                            return findByGroupId(groupId, start, end, orderByComparator);
1936                    }
1937    
1938                    StringBundler query = null;
1939    
1940                    if (orderByComparator != null) {
1941                            query = new StringBundler(3 +
1942                                            (orderByComparator.getOrderByFields().length * 3));
1943                    }
1944                    else {
1945                            query = new StringBundler(3);
1946                    }
1947    
1948                    if (getDB().isSupportsInlineDistinct()) {
1949                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
1950                    }
1951                    else {
1952                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
1953                    }
1954    
1955                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1956    
1957                    if (!getDB().isSupportsInlineDistinct()) {
1958                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
1959                    }
1960    
1961                    if (orderByComparator != null) {
1962                            if (getDB().isSupportsInlineDistinct()) {
1963                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1964                                            orderByComparator, true);
1965                            }
1966                            else {
1967                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1968                                            orderByComparator, true);
1969                            }
1970                    }
1971                    else {
1972                            if (getDB().isSupportsInlineDistinct()) {
1973                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
1974                            }
1975                            else {
1976                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
1977                            }
1978                    }
1979    
1980                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1981                                    DDMStructure.class.getName(),
1982                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1983    
1984                    Session session = null;
1985    
1986                    try {
1987                            session = openSession();
1988    
1989                            SQLQuery q = session.createSQLQuery(sql);
1990    
1991                            if (getDB().isSupportsInlineDistinct()) {
1992                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
1993                            }
1994                            else {
1995                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
1996                            }
1997    
1998                            QueryPos qPos = QueryPos.getInstance(q);
1999    
2000                            qPos.add(groupId);
2001    
2002                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
2003                                    end);
2004                    }
2005                    catch (Exception e) {
2006                            throw processException(e);
2007                    }
2008                    finally {
2009                            closeSession(session);
2010                    }
2011            }
2012    
2013            /**
2014             * 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;.
2015             *
2016             * @param structureId the primary key of the current d d m structure
2017             * @param groupId the group ID
2018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2019             * @return the previous, current, and next d d m structure
2020             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
2021             * @throws SystemException if a system exception occurred
2022             */
2023            @Override
2024            public DDMStructure[] filterFindByGroupId_PrevAndNext(long structureId,
2025                    long groupId, OrderByComparator orderByComparator)
2026                    throws NoSuchStructureException, SystemException {
2027                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2028                            return findByGroupId_PrevAndNext(structureId, groupId,
2029                                    orderByComparator);
2030                    }
2031    
2032                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
2033    
2034                    Session session = null;
2035    
2036                    try {
2037                            session = openSession();
2038    
2039                            DDMStructure[] array = new DDMStructureImpl[3];
2040    
2041                            array[0] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
2042                                            groupId, orderByComparator, true);
2043    
2044                            array[1] = ddmStructure;
2045    
2046                            array[2] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
2047                                            groupId, orderByComparator, false);
2048    
2049                            return array;
2050                    }
2051                    catch (Exception e) {
2052                            throw processException(e);
2053                    }
2054                    finally {
2055                            closeSession(session);
2056                    }
2057            }
2058    
2059            protected DDMStructure filterGetByGroupId_PrevAndNext(Session session,
2060                    DDMStructure ddmStructure, long groupId,
2061                    OrderByComparator orderByComparator, boolean previous) {
2062                    StringBundler query = null;
2063    
2064                    if (orderByComparator != null) {
2065                            query = new StringBundler(6 +
2066                                            (orderByComparator.getOrderByFields().length * 6));
2067                    }
2068                    else {
2069                            query = new StringBundler(3);
2070                    }
2071    
2072                    if (getDB().isSupportsInlineDistinct()) {
2073                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
2074                    }
2075                    else {
2076                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
2077                    }
2078    
2079                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2080    
2081                    if (!getDB().isSupportsInlineDistinct()) {
2082                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
2083                    }
2084    
2085                    if (orderByComparator != null) {
2086                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2087    
2088                            if (orderByConditionFields.length > 0) {
2089                                    query.append(WHERE_AND);
2090                            }
2091    
2092                            for (int i = 0; i < orderByConditionFields.length; i++) {
2093                                    if (getDB().isSupportsInlineDistinct()) {
2094                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2095                                    }
2096                                    else {
2097                                            query.append(_ORDER_BY_ENTITY_TABLE);
2098                                    }
2099    
2100                                    query.append(orderByConditionFields[i]);
2101    
2102                                    if ((i + 1) < orderByConditionFields.length) {
2103                                            if (orderByComparator.isAscending() ^ previous) {
2104                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2105                                            }
2106                                            else {
2107                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2108                                            }
2109                                    }
2110                                    else {
2111                                            if (orderByComparator.isAscending() ^ previous) {
2112                                                    query.append(WHERE_GREATER_THAN);
2113                                            }
2114                                            else {
2115                                                    query.append(WHERE_LESSER_THAN);
2116                                            }
2117                                    }
2118                            }
2119    
2120                            query.append(ORDER_BY_CLAUSE);
2121    
2122                            String[] orderByFields = orderByComparator.getOrderByFields();
2123    
2124                            for (int i = 0; i < orderByFields.length; i++) {
2125                                    if (getDB().isSupportsInlineDistinct()) {
2126                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2127                                    }
2128                                    else {
2129                                            query.append(_ORDER_BY_ENTITY_TABLE);
2130                                    }
2131    
2132                                    query.append(orderByFields[i]);
2133    
2134                                    if ((i + 1) < orderByFields.length) {
2135                                            if (orderByComparator.isAscending() ^ previous) {
2136                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2137                                            }
2138                                            else {
2139                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2140                                            }
2141                                    }
2142                                    else {
2143                                            if (orderByComparator.isAscending() ^ previous) {
2144                                                    query.append(ORDER_BY_ASC);
2145                                            }
2146                                            else {
2147                                                    query.append(ORDER_BY_DESC);
2148                                            }
2149                                    }
2150                            }
2151                    }
2152                    else {
2153                            if (getDB().isSupportsInlineDistinct()) {
2154                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
2155                            }
2156                            else {
2157                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
2158                            }
2159                    }
2160    
2161                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2162                                    DDMStructure.class.getName(),
2163                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2164    
2165                    SQLQuery q = session.createSQLQuery(sql);
2166    
2167                    q.setFirstResult(0);
2168                    q.setMaxResults(2);
2169    
2170                    if (getDB().isSupportsInlineDistinct()) {
2171                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
2172                    }
2173                    else {
2174                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2175                    }
2176    
2177                    QueryPos qPos = QueryPos.getInstance(q);
2178    
2179                    qPos.add(groupId);
2180    
2181                    if (orderByComparator != null) {
2182                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2183    
2184                            for (Object value : values) {
2185                                    qPos.add(value);
2186                            }
2187                    }
2188    
2189                    List<DDMStructure> list = q.list();
2190    
2191                    if (list.size() == 2) {
2192                            return list.get(1);
2193                    }
2194                    else {
2195                            return null;
2196                    }
2197            }
2198    
2199            /**
2200             * Returns all the d d m structures that the user has permission to view where groupId = any &#63;.
2201             *
2202             * @param groupIds the group IDs
2203             * @return the matching d d m structures that the user has permission to view
2204             * @throws SystemException if a system exception occurred
2205             */
2206            @Override
2207            public List<DDMStructure> filterFindByGroupId(long[] groupIds)
2208                    throws SystemException {
2209                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2210                            QueryUtil.ALL_POS, null);
2211            }
2212    
2213            /**
2214             * Returns a range of all the d d m structures that the user has permission to view where groupId = any &#63;.
2215             *
2216             * <p>
2217             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2218             * </p>
2219             *
2220             * @param groupIds the group IDs
2221             * @param start the lower bound of the range of d d m structures
2222             * @param end the upper bound of the range of d d m structures (not inclusive)
2223             * @return the range of matching d d m structures that the user has permission to view
2224             * @throws SystemException if a system exception occurred
2225             */
2226            @Override
2227            public List<DDMStructure> filterFindByGroupId(long[] groupIds, int start,
2228                    int end) throws SystemException {
2229                    return filterFindByGroupId(groupIds, start, end, null);
2230            }
2231    
2232            /**
2233             * Returns an ordered range of all the d d m structures that the user has permission to view where groupId = any &#63;.
2234             *
2235             * <p>
2236             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2237             * </p>
2238             *
2239             * @param groupIds the group IDs
2240             * @param start the lower bound of the range of d d m structures
2241             * @param end the upper bound of the range of d d m structures (not inclusive)
2242             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2243             * @return the ordered range of matching d d m structures that the user has permission to view
2244             * @throws SystemException if a system exception occurred
2245             */
2246            @Override
2247            public List<DDMStructure> filterFindByGroupId(long[] groupIds, int start,
2248                    int end, OrderByComparator orderByComparator) throws SystemException {
2249                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2250                            return findByGroupId(groupIds, start, end, orderByComparator);
2251                    }
2252    
2253                    StringBundler query = new StringBundler();
2254    
2255                    if (getDB().isSupportsInlineDistinct()) {
2256                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
2257                    }
2258                    else {
2259                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
2260                    }
2261    
2262                    boolean conjunctionable = false;
2263    
2264                    if ((groupIds == null) || (groupIds.length > 0)) {
2265                            if (conjunctionable) {
2266                                    query.append(WHERE_AND);
2267                            }
2268    
2269                            query.append(StringPool.OPEN_PARENTHESIS);
2270    
2271                            for (int i = 0; i < groupIds.length; i++) {
2272                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2273    
2274                                    if ((i + 1) < groupIds.length) {
2275                                            query.append(WHERE_OR);
2276                                    }
2277                            }
2278    
2279                            query.append(StringPool.CLOSE_PARENTHESIS);
2280    
2281                            conjunctionable = true;
2282                    }
2283    
2284                    if (!getDB().isSupportsInlineDistinct()) {
2285                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
2286                    }
2287    
2288                    if (orderByComparator != null) {
2289                            if (getDB().isSupportsInlineDistinct()) {
2290                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2291                                            orderByComparator, true);
2292                            }
2293                            else {
2294                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2295                                            orderByComparator, true);
2296                            }
2297                    }
2298                    else {
2299                            if (getDB().isSupportsInlineDistinct()) {
2300                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
2301                            }
2302                            else {
2303                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
2304                            }
2305                    }
2306    
2307                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2308                                    DDMStructure.class.getName(),
2309                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2310    
2311                    Session session = null;
2312    
2313                    try {
2314                            session = openSession();
2315    
2316                            SQLQuery q = session.createSQLQuery(sql);
2317    
2318                            if (getDB().isSupportsInlineDistinct()) {
2319                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
2320                            }
2321                            else {
2322                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2323                            }
2324    
2325                            QueryPos qPos = QueryPos.getInstance(q);
2326    
2327                            if (groupIds != null) {
2328                                    qPos.add(groupIds);
2329                            }
2330    
2331                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
2332                                    end);
2333                    }
2334                    catch (Exception e) {
2335                            throw processException(e);
2336                    }
2337                    finally {
2338                            closeSession(session);
2339                    }
2340            }
2341    
2342            /**
2343             * Returns all the d d m structures where groupId = any &#63;.
2344             *
2345             * <p>
2346             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2347             * </p>
2348             *
2349             * @param groupIds the group IDs
2350             * @return the matching d d m structures
2351             * @throws SystemException if a system exception occurred
2352             */
2353            @Override
2354            public List<DDMStructure> findByGroupId(long[] groupIds)
2355                    throws SystemException {
2356                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2357                            null);
2358            }
2359    
2360            /**
2361             * Returns a range of all the d d m structures where groupId = any &#63;.
2362             *
2363             * <p>
2364             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2365             * </p>
2366             *
2367             * @param groupIds the group IDs
2368             * @param start the lower bound of the range of d d m structures
2369             * @param end the upper bound of the range of d d m structures (not inclusive)
2370             * @return the range of matching d d m structures
2371             * @throws SystemException if a system exception occurred
2372             */
2373            @Override
2374            public List<DDMStructure> findByGroupId(long[] groupIds, int start, int end)
2375                    throws SystemException {
2376                    return findByGroupId(groupIds, start, end, null);
2377            }
2378    
2379            /**
2380             * Returns an ordered range of all the d d m structures where groupId = any &#63;.
2381             *
2382             * <p>
2383             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2384             * </p>
2385             *
2386             * @param groupIds the group IDs
2387             * @param start the lower bound of the range of d d m structures
2388             * @param end the upper bound of the range of d d m structures (not inclusive)
2389             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2390             * @return the ordered range of matching d d m structures
2391             * @throws SystemException if a system exception occurred
2392             */
2393            @Override
2394            public List<DDMStructure> findByGroupId(long[] groupIds, int start,
2395                    int end, OrderByComparator orderByComparator) throws SystemException {
2396                    if ((groupIds != null) && (groupIds.length == 1)) {
2397                            return findByGroupId(groupIds[0], start, end, orderByComparator);
2398                    }
2399    
2400                    boolean pagination = true;
2401                    Object[] finderArgs = null;
2402    
2403                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2404                                    (orderByComparator == null)) {
2405                            pagination = false;
2406                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
2407                    }
2408                    else {
2409                            finderArgs = new Object[] {
2410                                            StringUtil.merge(groupIds),
2411                                            
2412                                            start, end, orderByComparator
2413                                    };
2414                    }
2415    
2416                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2417                                    finderArgs, this);
2418    
2419                    if ((list != null) && !list.isEmpty()) {
2420                            for (DDMStructure ddmStructure : list) {
2421                                    if (!ArrayUtil.contains(groupIds, ddmStructure.getGroupId())) {
2422                                            list = null;
2423    
2424                                            break;
2425                                    }
2426                            }
2427                    }
2428    
2429                    if (list == null) {
2430                            StringBundler query = new StringBundler();
2431    
2432                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2433    
2434                            boolean conjunctionable = false;
2435    
2436                            if ((groupIds == null) || (groupIds.length > 0)) {
2437                                    if (conjunctionable) {
2438                                            query.append(WHERE_AND);
2439                                    }
2440    
2441                                    query.append(StringPool.OPEN_PARENTHESIS);
2442    
2443                                    for (int i = 0; i < groupIds.length; i++) {
2444                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2445    
2446                                            if ((i + 1) < groupIds.length) {
2447                                                    query.append(WHERE_OR);
2448                                            }
2449                                    }
2450    
2451                                    query.append(StringPool.CLOSE_PARENTHESIS);
2452    
2453                                    conjunctionable = true;
2454                            }
2455    
2456                            if (orderByComparator != null) {
2457                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2458                                            orderByComparator);
2459                            }
2460                            else
2461                             if (pagination) {
2462                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
2463                            }
2464    
2465                            String sql = query.toString();
2466    
2467                            Session session = null;
2468    
2469                            try {
2470                                    session = openSession();
2471    
2472                                    Query q = session.createQuery(sql);
2473    
2474                                    QueryPos qPos = QueryPos.getInstance(q);
2475    
2476                                    if (groupIds != null) {
2477                                            qPos.add(groupIds);
2478                                    }
2479    
2480                                    if (!pagination) {
2481                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2482                                                            start, end, false);
2483    
2484                                            Collections.sort(list);
2485    
2486                                            list = new UnmodifiableList<DDMStructure>(list);
2487                                    }
2488                                    else {
2489                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2490                                                            start, end);
2491                                    }
2492    
2493                                    cacheResult(list);
2494    
2495                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2496                                            finderArgs, list);
2497                            }
2498                            catch (Exception e) {
2499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2500                                            finderArgs);
2501    
2502                                    throw processException(e);
2503                            }
2504                            finally {
2505                                    closeSession(session);
2506                            }
2507                    }
2508    
2509                    return list;
2510            }
2511    
2512            /**
2513             * Removes all the d d m structures where groupId = &#63; from the database.
2514             *
2515             * @param groupId the group ID
2516             * @throws SystemException if a system exception occurred
2517             */
2518            @Override
2519            public void removeByGroupId(long groupId) throws SystemException {
2520                    for (DDMStructure ddmStructure : findByGroupId(groupId,
2521                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2522                            remove(ddmStructure);
2523                    }
2524            }
2525    
2526            /**
2527             * Returns the number of d d m structures where groupId = &#63;.
2528             *
2529             * @param groupId the group ID
2530             * @return the number of matching d d m structures
2531             * @throws SystemException if a system exception occurred
2532             */
2533            @Override
2534            public int countByGroupId(long groupId) throws SystemException {
2535                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2536    
2537                    Object[] finderArgs = new Object[] { groupId };
2538    
2539                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2540                                    this);
2541    
2542                    if (count == null) {
2543                            StringBundler query = new StringBundler(2);
2544    
2545                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
2546    
2547                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2548    
2549                            String sql = query.toString();
2550    
2551                            Session session = null;
2552    
2553                            try {
2554                                    session = openSession();
2555    
2556                                    Query q = session.createQuery(sql);
2557    
2558                                    QueryPos qPos = QueryPos.getInstance(q);
2559    
2560                                    qPos.add(groupId);
2561    
2562                                    count = (Long)q.uniqueResult();
2563    
2564                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2565                            }
2566                            catch (Exception e) {
2567                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2568    
2569                                    throw processException(e);
2570                            }
2571                            finally {
2572                                    closeSession(session);
2573                            }
2574                    }
2575    
2576                    return count.intValue();
2577            }
2578    
2579            /**
2580             * Returns the number of d d m structures where groupId = any &#63;.
2581             *
2582             * @param groupIds the group IDs
2583             * @return the number of matching d d m structures
2584             * @throws SystemException if a system exception occurred
2585             */
2586            @Override
2587            public int countByGroupId(long[] groupIds) throws SystemException {
2588                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2589    
2590                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2591                                    finderArgs, this);
2592    
2593                    if (count == null) {
2594                            StringBundler query = new StringBundler();
2595    
2596                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
2597    
2598                            boolean conjunctionable = false;
2599    
2600                            if ((groupIds == null) || (groupIds.length > 0)) {
2601                                    if (conjunctionable) {
2602                                            query.append(WHERE_AND);
2603                                    }
2604    
2605                                    query.append(StringPool.OPEN_PARENTHESIS);
2606    
2607                                    for (int i = 0; i < groupIds.length; i++) {
2608                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2609    
2610                                            if ((i + 1) < groupIds.length) {
2611                                                    query.append(WHERE_OR);
2612                                            }
2613                                    }
2614    
2615                                    query.append(StringPool.CLOSE_PARENTHESIS);
2616    
2617                                    conjunctionable = true;
2618                            }
2619    
2620                            String sql = query.toString();
2621    
2622                            Session session = null;
2623    
2624                            try {
2625                                    session = openSession();
2626    
2627                                    Query q = session.createQuery(sql);
2628    
2629                                    QueryPos qPos = QueryPos.getInstance(q);
2630    
2631                                    if (groupIds != null) {
2632                                            qPos.add(groupIds);
2633                                    }
2634    
2635                                    count = (Long)q.uniqueResult();
2636    
2637                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2638                                            finderArgs, count);
2639                            }
2640                            catch (Exception e) {
2641                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2642                                            finderArgs);
2643    
2644                                    throw processException(e);
2645                            }
2646                            finally {
2647                                    closeSession(session);
2648                            }
2649                    }
2650    
2651                    return count.intValue();
2652            }
2653    
2654            /**
2655             * Returns the number of d d m structures that the user has permission to view where groupId = &#63;.
2656             *
2657             * @param groupId the group ID
2658             * @return the number of matching d d m structures that the user has permission to view
2659             * @throws SystemException if a system exception occurred
2660             */
2661            @Override
2662            public int filterCountByGroupId(long groupId) throws SystemException {
2663                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2664                            return countByGroupId(groupId);
2665                    }
2666    
2667                    StringBundler query = new StringBundler(2);
2668    
2669                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
2670    
2671                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2672    
2673                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2674                                    DDMStructure.class.getName(),
2675                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2676    
2677                    Session session = null;
2678    
2679                    try {
2680                            session = openSession();
2681    
2682                            SQLQuery q = session.createSQLQuery(sql);
2683    
2684                            q.addScalar(COUNT_COLUMN_NAME,
2685                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2686    
2687                            QueryPos qPos = QueryPos.getInstance(q);
2688    
2689                            qPos.add(groupId);
2690    
2691                            Long count = (Long)q.uniqueResult();
2692    
2693                            return count.intValue();
2694                    }
2695                    catch (Exception e) {
2696                            throw processException(e);
2697                    }
2698                    finally {
2699                            closeSession(session);
2700                    }
2701            }
2702    
2703            /**
2704             * Returns the number of d d m structures that the user has permission to view where groupId = any &#63;.
2705             *
2706             * @param groupIds the group IDs
2707             * @return the number of matching d d m structures that the user has permission to view
2708             * @throws SystemException if a system exception occurred
2709             */
2710            @Override
2711            public int filterCountByGroupId(long[] groupIds) throws SystemException {
2712                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2713                            return countByGroupId(groupIds);
2714                    }
2715    
2716                    StringBundler query = new StringBundler();
2717    
2718                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
2719    
2720                    boolean conjunctionable = false;
2721    
2722                    if ((groupIds == null) || (groupIds.length > 0)) {
2723                            if (conjunctionable) {
2724                                    query.append(WHERE_AND);
2725                            }
2726    
2727                            query.append(StringPool.OPEN_PARENTHESIS);
2728    
2729                            for (int i = 0; i < groupIds.length; i++) {
2730                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2731    
2732                                    if ((i + 1) < groupIds.length) {
2733                                            query.append(WHERE_OR);
2734                                    }
2735                            }
2736    
2737                            query.append(StringPool.CLOSE_PARENTHESIS);
2738    
2739                            conjunctionable = true;
2740                    }
2741    
2742                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2743                                    DDMStructure.class.getName(),
2744                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2745    
2746                    Session session = null;
2747    
2748                    try {
2749                            session = openSession();
2750    
2751                            SQLQuery q = session.createSQLQuery(sql);
2752    
2753                            q.addScalar(COUNT_COLUMN_NAME,
2754                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2755    
2756                            QueryPos qPos = QueryPos.getInstance(q);
2757    
2758                            if (groupIds != null) {
2759                                    qPos.add(groupIds);
2760                            }
2761    
2762                            Long count = (Long)q.uniqueResult();
2763    
2764                            return count.intValue();
2765                    }
2766                    catch (Exception e) {
2767                            throw processException(e);
2768                    }
2769                    finally {
2770                            closeSession(session);
2771                    }
2772            }
2773    
2774            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddmStructure.groupId = ?";
2775            private static final String _FINDER_COLUMN_GROUPID_GROUPID_5 = "(" +
2776                    removeConjunction(_FINDER_COLUMN_GROUPID_GROUPID_2) + ")";
2777            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTSTRUCTUREID =
2778                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
2779                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
2780                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByParentStructureId",
2781                            new String[] {
2782                                    Long.class.getName(),
2783                                    
2784                            Integer.class.getName(), Integer.class.getName(),
2785                                    OrderByComparator.class.getName()
2786                            });
2787            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID =
2788                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
2789                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
2790                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2791                            "findByParentStructureId", new String[] { Long.class.getName() },
2792                            DDMStructureModelImpl.PARENTSTRUCTUREID_COLUMN_BITMASK);
2793            public static final FinderPath FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
2794                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
2795                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2796                            "countByParentStructureId", new String[] { Long.class.getName() });
2797    
2798            /**
2799             * Returns all the d d m structures where parentStructureId = &#63;.
2800             *
2801             * @param parentStructureId the parent structure ID
2802             * @return the matching d d m structures
2803             * @throws SystemException if a system exception occurred
2804             */
2805            @Override
2806            public List<DDMStructure> findByParentStructureId(long parentStructureId)
2807                    throws SystemException {
2808                    return findByParentStructureId(parentStructureId, QueryUtil.ALL_POS,
2809                            QueryUtil.ALL_POS, null);
2810            }
2811    
2812            /**
2813             * Returns a range of all the d d m structures where parentStructureId = &#63;.
2814             *
2815             * <p>
2816             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2817             * </p>
2818             *
2819             * @param parentStructureId the parent structure ID
2820             * @param start the lower bound of the range of d d m structures
2821             * @param end the upper bound of the range of d d m structures (not inclusive)
2822             * @return the range of matching d d m structures
2823             * @throws SystemException if a system exception occurred
2824             */
2825            @Override
2826            public List<DDMStructure> findByParentStructureId(long parentStructureId,
2827                    int start, int end) throws SystemException {
2828                    return findByParentStructureId(parentStructureId, start, end, null);
2829            }
2830    
2831            /**
2832             * Returns an ordered range of all the d d m structures where parentStructureId = &#63;.
2833             *
2834             * <p>
2835             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2836             * </p>
2837             *
2838             * @param parentStructureId the parent structure ID
2839             * @param start the lower bound of the range of d d m structures
2840             * @param end the upper bound of the range of d d m structures (not inclusive)
2841             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2842             * @return the ordered range of matching d d m structures
2843             * @throws SystemException if a system exception occurred
2844             */
2845            @Override
2846            public List<DDMStructure> findByParentStructureId(long parentStructureId,
2847                    int start, int end, OrderByComparator orderByComparator)
2848                    throws SystemException {
2849                    boolean pagination = true;
2850                    FinderPath finderPath = null;
2851                    Object[] finderArgs = null;
2852    
2853                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2854                                    (orderByComparator == null)) {
2855                            pagination = false;
2856                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID;
2857                            finderArgs = new Object[] { parentStructureId };
2858                    }
2859                    else {
2860                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTSTRUCTUREID;
2861                            finderArgs = new Object[] {
2862                                            parentStructureId,
2863                                            
2864                                            start, end, orderByComparator
2865                                    };
2866                    }
2867    
2868                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
2869                                    finderArgs, this);
2870    
2871                    if ((list != null) && !list.isEmpty()) {
2872                            for (DDMStructure ddmStructure : list) {
2873                                    if ((parentStructureId != ddmStructure.getParentStructureId())) {
2874                                            list = null;
2875    
2876                                            break;
2877                                    }
2878                            }
2879                    }
2880    
2881                    if (list == null) {
2882                            StringBundler query = null;
2883    
2884                            if (orderByComparator != null) {
2885                                    query = new StringBundler(3 +
2886                                                    (orderByComparator.getOrderByFields().length * 3));
2887                            }
2888                            else {
2889                                    query = new StringBundler(3);
2890                            }
2891    
2892                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2893    
2894                            query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
2895    
2896                            if (orderByComparator != null) {
2897                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2898                                            orderByComparator);
2899                            }
2900                            else
2901                             if (pagination) {
2902                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
2903                            }
2904    
2905                            String sql = query.toString();
2906    
2907                            Session session = null;
2908    
2909                            try {
2910                                    session = openSession();
2911    
2912                                    Query q = session.createQuery(sql);
2913    
2914                                    QueryPos qPos = QueryPos.getInstance(q);
2915    
2916                                    qPos.add(parentStructureId);
2917    
2918                                    if (!pagination) {
2919                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2920                                                            start, end, false);
2921    
2922                                            Collections.sort(list);
2923    
2924                                            list = new UnmodifiableList<DDMStructure>(list);
2925                                    }
2926                                    else {
2927                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2928                                                            start, end);
2929                                    }
2930    
2931                                    cacheResult(list);
2932    
2933                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2934                            }
2935                            catch (Exception e) {
2936                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2937    
2938                                    throw processException(e);
2939                            }
2940                            finally {
2941                                    closeSession(session);
2942                            }
2943                    }
2944    
2945                    return list;
2946            }
2947    
2948            /**
2949             * Returns the first d d m structure in the ordered set where parentStructureId = &#63;.
2950             *
2951             * @param parentStructureId the parent structure ID
2952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2953             * @return the first matching d d m structure
2954             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
2955             * @throws SystemException if a system exception occurred
2956             */
2957            @Override
2958            public DDMStructure findByParentStructureId_First(long parentStructureId,
2959                    OrderByComparator orderByComparator)
2960                    throws NoSuchStructureException, SystemException {
2961                    DDMStructure ddmStructure = fetchByParentStructureId_First(parentStructureId,
2962                                    orderByComparator);
2963    
2964                    if (ddmStructure != null) {
2965                            return ddmStructure;
2966                    }
2967    
2968                    StringBundler msg = new StringBundler(4);
2969    
2970                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2971    
2972                    msg.append("parentStructureId=");
2973                    msg.append(parentStructureId);
2974    
2975                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2976    
2977                    throw new NoSuchStructureException(msg.toString());
2978            }
2979    
2980            /**
2981             * Returns the first d d m structure in the ordered set where parentStructureId = &#63;.
2982             *
2983             * @param parentStructureId the parent structure ID
2984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2985             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
2986             * @throws SystemException if a system exception occurred
2987             */
2988            @Override
2989            public DDMStructure fetchByParentStructureId_First(long parentStructureId,
2990                    OrderByComparator orderByComparator) throws SystemException {
2991                    List<DDMStructure> list = findByParentStructureId(parentStructureId, 0,
2992                                    1, orderByComparator);
2993    
2994                    if (!list.isEmpty()) {
2995                            return list.get(0);
2996                    }
2997    
2998                    return null;
2999            }
3000    
3001            /**
3002             * Returns the last d d m structure in the ordered set where parentStructureId = &#63;.
3003             *
3004             * @param parentStructureId the parent structure ID
3005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3006             * @return the last matching d d m structure
3007             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3008             * @throws SystemException if a system exception occurred
3009             */
3010            @Override
3011            public DDMStructure findByParentStructureId_Last(long parentStructureId,
3012                    OrderByComparator orderByComparator)
3013                    throws NoSuchStructureException, SystemException {
3014                    DDMStructure ddmStructure = fetchByParentStructureId_Last(parentStructureId,
3015                                    orderByComparator);
3016    
3017                    if (ddmStructure != null) {
3018                            return ddmStructure;
3019                    }
3020    
3021                    StringBundler msg = new StringBundler(4);
3022    
3023                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3024    
3025                    msg.append("parentStructureId=");
3026                    msg.append(parentStructureId);
3027    
3028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3029    
3030                    throw new NoSuchStructureException(msg.toString());
3031            }
3032    
3033            /**
3034             * Returns the last d d m structure in the ordered set where parentStructureId = &#63;.
3035             *
3036             * @param parentStructureId the parent structure ID
3037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3038             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3039             * @throws SystemException if a system exception occurred
3040             */
3041            @Override
3042            public DDMStructure fetchByParentStructureId_Last(long parentStructureId,
3043                    OrderByComparator orderByComparator) throws SystemException {
3044                    int count = countByParentStructureId(parentStructureId);
3045    
3046                    if (count == 0) {
3047                            return null;
3048                    }
3049    
3050                    List<DDMStructure> list = findByParentStructureId(parentStructureId,
3051                                    count - 1, count, orderByComparator);
3052    
3053                    if (!list.isEmpty()) {
3054                            return list.get(0);
3055                    }
3056    
3057                    return null;
3058            }
3059    
3060            /**
3061             * Returns the d d m structures before and after the current d d m structure in the ordered set where parentStructureId = &#63;.
3062             *
3063             * @param structureId the primary key of the current d d m structure
3064             * @param parentStructureId the parent structure ID
3065             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3066             * @return the previous, current, and next d d m structure
3067             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
3068             * @throws SystemException if a system exception occurred
3069             */
3070            @Override
3071            public DDMStructure[] findByParentStructureId_PrevAndNext(
3072                    long structureId, long parentStructureId,
3073                    OrderByComparator orderByComparator)
3074                    throws NoSuchStructureException, SystemException {
3075                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
3076    
3077                    Session session = null;
3078    
3079                    try {
3080                            session = openSession();
3081    
3082                            DDMStructure[] array = new DDMStructureImpl[3];
3083    
3084                            array[0] = getByParentStructureId_PrevAndNext(session,
3085                                            ddmStructure, parentStructureId, orderByComparator, true);
3086    
3087                            array[1] = ddmStructure;
3088    
3089                            array[2] = getByParentStructureId_PrevAndNext(session,
3090                                            ddmStructure, parentStructureId, orderByComparator, false);
3091    
3092                            return array;
3093                    }
3094                    catch (Exception e) {
3095                            throw processException(e);
3096                    }
3097                    finally {
3098                            closeSession(session);
3099                    }
3100            }
3101    
3102            protected DDMStructure getByParentStructureId_PrevAndNext(Session session,
3103                    DDMStructure ddmStructure, long parentStructureId,
3104                    OrderByComparator orderByComparator, boolean previous) {
3105                    StringBundler query = null;
3106    
3107                    if (orderByComparator != null) {
3108                            query = new StringBundler(6 +
3109                                            (orderByComparator.getOrderByFields().length * 6));
3110                    }
3111                    else {
3112                            query = new StringBundler(3);
3113                    }
3114    
3115                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3116    
3117                    query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
3118    
3119                    if (orderByComparator != null) {
3120                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3121    
3122                            if (orderByConditionFields.length > 0) {
3123                                    query.append(WHERE_AND);
3124                            }
3125    
3126                            for (int i = 0; i < orderByConditionFields.length; i++) {
3127                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3128                                    query.append(orderByConditionFields[i]);
3129    
3130                                    if ((i + 1) < orderByConditionFields.length) {
3131                                            if (orderByComparator.isAscending() ^ previous) {
3132                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3133                                            }
3134                                            else {
3135                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3136                                            }
3137                                    }
3138                                    else {
3139                                            if (orderByComparator.isAscending() ^ previous) {
3140                                                    query.append(WHERE_GREATER_THAN);
3141                                            }
3142                                            else {
3143                                                    query.append(WHERE_LESSER_THAN);
3144                                            }
3145                                    }
3146                            }
3147    
3148                            query.append(ORDER_BY_CLAUSE);
3149    
3150                            String[] orderByFields = orderByComparator.getOrderByFields();
3151    
3152                            for (int i = 0; i < orderByFields.length; i++) {
3153                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3154                                    query.append(orderByFields[i]);
3155    
3156                                    if ((i + 1) < orderByFields.length) {
3157                                            if (orderByComparator.isAscending() ^ previous) {
3158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3159                                            }
3160                                            else {
3161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3162                                            }
3163                                    }
3164                                    else {
3165                                            if (orderByComparator.isAscending() ^ previous) {
3166                                                    query.append(ORDER_BY_ASC);
3167                                            }
3168                                            else {
3169                                                    query.append(ORDER_BY_DESC);
3170                                            }
3171                                    }
3172                            }
3173                    }
3174                    else {
3175                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
3176                    }
3177    
3178                    String sql = query.toString();
3179    
3180                    Query q = session.createQuery(sql);
3181    
3182                    q.setFirstResult(0);
3183                    q.setMaxResults(2);
3184    
3185                    QueryPos qPos = QueryPos.getInstance(q);
3186    
3187                    qPos.add(parentStructureId);
3188    
3189                    if (orderByComparator != null) {
3190                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3191    
3192                            for (Object value : values) {
3193                                    qPos.add(value);
3194                            }
3195                    }
3196    
3197                    List<DDMStructure> list = q.list();
3198    
3199                    if (list.size() == 2) {
3200                            return list.get(1);
3201                    }
3202                    else {
3203                            return null;
3204                    }
3205            }
3206    
3207            /**
3208             * Removes all the d d m structures where parentStructureId = &#63; from the database.
3209             *
3210             * @param parentStructureId the parent structure ID
3211             * @throws SystemException if a system exception occurred
3212             */
3213            @Override
3214            public void removeByParentStructureId(long parentStructureId)
3215                    throws SystemException {
3216                    for (DDMStructure ddmStructure : findByParentStructureId(
3217                                    parentStructureId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3218                            remove(ddmStructure);
3219                    }
3220            }
3221    
3222            /**
3223             * Returns the number of d d m structures where parentStructureId = &#63;.
3224             *
3225             * @param parentStructureId the parent structure ID
3226             * @return the number of matching d d m structures
3227             * @throws SystemException if a system exception occurred
3228             */
3229            @Override
3230            public int countByParentStructureId(long parentStructureId)
3231                    throws SystemException {
3232                    FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID;
3233    
3234                    Object[] finderArgs = new Object[] { parentStructureId };
3235    
3236                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3237                                    this);
3238    
3239                    if (count == null) {
3240                            StringBundler query = new StringBundler(2);
3241    
3242                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
3243    
3244                            query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
3245    
3246                            String sql = query.toString();
3247    
3248                            Session session = null;
3249    
3250                            try {
3251                                    session = openSession();
3252    
3253                                    Query q = session.createQuery(sql);
3254    
3255                                    QueryPos qPos = QueryPos.getInstance(q);
3256    
3257                                    qPos.add(parentStructureId);
3258    
3259                                    count = (Long)q.uniqueResult();
3260    
3261                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3262                            }
3263                            catch (Exception e) {
3264                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3265    
3266                                    throw processException(e);
3267                            }
3268                            finally {
3269                                    closeSession(session);
3270                            }
3271                    }
3272    
3273                    return count.intValue();
3274            }
3275    
3276            private static final String _FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2 =
3277                    "ddmStructure.parentStructureId = ?";
3278            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
3279                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3280                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
3281                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByClassNameId",
3282                            new String[] {
3283                                    Long.class.getName(),
3284                                    
3285                            Integer.class.getName(), Integer.class.getName(),
3286                                    OrderByComparator.class.getName()
3287                            });
3288            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
3289                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3290                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
3291                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
3292                            new String[] { Long.class.getName() },
3293                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
3294            public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3295                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
3296                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
3297                            new String[] { Long.class.getName() });
3298    
3299            /**
3300             * Returns all the d d m structures where classNameId = &#63;.
3301             *
3302             * @param classNameId the class name ID
3303             * @return the matching d d m structures
3304             * @throws SystemException if a system exception occurred
3305             */
3306            @Override
3307            public List<DDMStructure> findByClassNameId(long classNameId)
3308                    throws SystemException {
3309                    return findByClassNameId(classNameId, QueryUtil.ALL_POS,
3310                            QueryUtil.ALL_POS, null);
3311            }
3312    
3313            /**
3314             * Returns a range of all the d d m structures where classNameId = &#63;.
3315             *
3316             * <p>
3317             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3318             * </p>
3319             *
3320             * @param classNameId the class name ID
3321             * @param start the lower bound of the range of d d m structures
3322             * @param end the upper bound of the range of d d m structures (not inclusive)
3323             * @return the range of matching d d m structures
3324             * @throws SystemException if a system exception occurred
3325             */
3326            @Override
3327            public List<DDMStructure> findByClassNameId(long classNameId, int start,
3328                    int end) throws SystemException {
3329                    return findByClassNameId(classNameId, start, end, null);
3330            }
3331    
3332            /**
3333             * Returns an ordered range of all the d d m structures where classNameId = &#63;.
3334             *
3335             * <p>
3336             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3337             * </p>
3338             *
3339             * @param classNameId the class name ID
3340             * @param start the lower bound of the range of d d m structures
3341             * @param end the upper bound of the range of d d m structures (not inclusive)
3342             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3343             * @return the ordered range of matching d d m structures
3344             * @throws SystemException if a system exception occurred
3345             */
3346            @Override
3347            public List<DDMStructure> findByClassNameId(long classNameId, int start,
3348                    int end, OrderByComparator orderByComparator) throws SystemException {
3349                    boolean pagination = true;
3350                    FinderPath finderPath = null;
3351                    Object[] finderArgs = null;
3352    
3353                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3354                                    (orderByComparator == null)) {
3355                            pagination = false;
3356                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
3357                            finderArgs = new Object[] { classNameId };
3358                    }
3359                    else {
3360                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
3361                            finderArgs = new Object[] { classNameId, start, end, orderByComparator };
3362                    }
3363    
3364                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3365                                    finderArgs, this);
3366    
3367                    if ((list != null) && !list.isEmpty()) {
3368                            for (DDMStructure ddmStructure : list) {
3369                                    if ((classNameId != ddmStructure.getClassNameId())) {
3370                                            list = null;
3371    
3372                                            break;
3373                                    }
3374                            }
3375                    }
3376    
3377                    if (list == null) {
3378                            StringBundler query = null;
3379    
3380                            if (orderByComparator != null) {
3381                                    query = new StringBundler(3 +
3382                                                    (orderByComparator.getOrderByFields().length * 3));
3383                            }
3384                            else {
3385                                    query = new StringBundler(3);
3386                            }
3387    
3388                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3389    
3390                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
3391    
3392                            if (orderByComparator != null) {
3393                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3394                                            orderByComparator);
3395                            }
3396                            else
3397                             if (pagination) {
3398                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
3399                            }
3400    
3401                            String sql = query.toString();
3402    
3403                            Session session = null;
3404    
3405                            try {
3406                                    session = openSession();
3407    
3408                                    Query q = session.createQuery(sql);
3409    
3410                                    QueryPos qPos = QueryPos.getInstance(q);
3411    
3412                                    qPos.add(classNameId);
3413    
3414                                    if (!pagination) {
3415                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3416                                                            start, end, false);
3417    
3418                                            Collections.sort(list);
3419    
3420                                            list = new UnmodifiableList<DDMStructure>(list);
3421                                    }
3422                                    else {
3423                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3424                                                            start, end);
3425                                    }
3426    
3427                                    cacheResult(list);
3428    
3429                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3430                            }
3431                            catch (Exception e) {
3432                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3433    
3434                                    throw processException(e);
3435                            }
3436                            finally {
3437                                    closeSession(session);
3438                            }
3439                    }
3440    
3441                    return list;
3442            }
3443    
3444            /**
3445             * Returns the first d d m structure in the ordered set where classNameId = &#63;.
3446             *
3447             * @param classNameId the class name ID
3448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3449             * @return the first matching d d m structure
3450             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3451             * @throws SystemException if a system exception occurred
3452             */
3453            @Override
3454            public DDMStructure findByClassNameId_First(long classNameId,
3455                    OrderByComparator orderByComparator)
3456                    throws NoSuchStructureException, SystemException {
3457                    DDMStructure ddmStructure = fetchByClassNameId_First(classNameId,
3458                                    orderByComparator);
3459    
3460                    if (ddmStructure != null) {
3461                            return ddmStructure;
3462                    }
3463    
3464                    StringBundler msg = new StringBundler(4);
3465    
3466                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3467    
3468                    msg.append("classNameId=");
3469                    msg.append(classNameId);
3470    
3471                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3472    
3473                    throw new NoSuchStructureException(msg.toString());
3474            }
3475    
3476            /**
3477             * Returns the first d d m structure in the ordered set where classNameId = &#63;.
3478             *
3479             * @param classNameId the class name ID
3480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3481             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3482             * @throws SystemException if a system exception occurred
3483             */
3484            @Override
3485            public DDMStructure fetchByClassNameId_First(long classNameId,
3486                    OrderByComparator orderByComparator) throws SystemException {
3487                    List<DDMStructure> list = findByClassNameId(classNameId, 0, 1,
3488                                    orderByComparator);
3489    
3490                    if (!list.isEmpty()) {
3491                            return list.get(0);
3492                    }
3493    
3494                    return null;
3495            }
3496    
3497            /**
3498             * Returns the last d d m structure in the ordered set where classNameId = &#63;.
3499             *
3500             * @param classNameId the class name ID
3501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3502             * @return the last matching d d m structure
3503             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3504             * @throws SystemException if a system exception occurred
3505             */
3506            @Override
3507            public DDMStructure findByClassNameId_Last(long classNameId,
3508                    OrderByComparator orderByComparator)
3509                    throws NoSuchStructureException, SystemException {
3510                    DDMStructure ddmStructure = fetchByClassNameId_Last(classNameId,
3511                                    orderByComparator);
3512    
3513                    if (ddmStructure != null) {
3514                            return ddmStructure;
3515                    }
3516    
3517                    StringBundler msg = new StringBundler(4);
3518    
3519                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3520    
3521                    msg.append("classNameId=");
3522                    msg.append(classNameId);
3523    
3524                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3525    
3526                    throw new NoSuchStructureException(msg.toString());
3527            }
3528    
3529            /**
3530             * Returns the last d d m structure in the ordered set where classNameId = &#63;.
3531             *
3532             * @param classNameId the class name ID
3533             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3534             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3535             * @throws SystemException if a system exception occurred
3536             */
3537            @Override
3538            public DDMStructure fetchByClassNameId_Last(long classNameId,
3539                    OrderByComparator orderByComparator) throws SystemException {
3540                    int count = countByClassNameId(classNameId);
3541    
3542                    if (count == 0) {
3543                            return null;
3544                    }
3545    
3546                    List<DDMStructure> list = findByClassNameId(classNameId, count - 1,
3547                                    count, orderByComparator);
3548    
3549                    if (!list.isEmpty()) {
3550                            return list.get(0);
3551                    }
3552    
3553                    return null;
3554            }
3555    
3556            /**
3557             * Returns the d d m structures before and after the current d d m structure in the ordered set where classNameId = &#63;.
3558             *
3559             * @param structureId the primary key of the current d d m structure
3560             * @param classNameId the class name ID
3561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3562             * @return the previous, current, and next d d m structure
3563             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
3564             * @throws SystemException if a system exception occurred
3565             */
3566            @Override
3567            public DDMStructure[] findByClassNameId_PrevAndNext(long structureId,
3568                    long classNameId, OrderByComparator orderByComparator)
3569                    throws NoSuchStructureException, SystemException {
3570                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
3571    
3572                    Session session = null;
3573    
3574                    try {
3575                            session = openSession();
3576    
3577                            DDMStructure[] array = new DDMStructureImpl[3];
3578    
3579                            array[0] = getByClassNameId_PrevAndNext(session, ddmStructure,
3580                                            classNameId, orderByComparator, true);
3581    
3582                            array[1] = ddmStructure;
3583    
3584                            array[2] = getByClassNameId_PrevAndNext(session, ddmStructure,
3585                                            classNameId, orderByComparator, false);
3586    
3587                            return array;
3588                    }
3589                    catch (Exception e) {
3590                            throw processException(e);
3591                    }
3592                    finally {
3593                            closeSession(session);
3594                    }
3595            }
3596    
3597            protected DDMStructure getByClassNameId_PrevAndNext(Session session,
3598                    DDMStructure ddmStructure, long classNameId,
3599                    OrderByComparator orderByComparator, boolean previous) {
3600                    StringBundler query = null;
3601    
3602                    if (orderByComparator != null) {
3603                            query = new StringBundler(6 +
3604                                            (orderByComparator.getOrderByFields().length * 6));
3605                    }
3606                    else {
3607                            query = new StringBundler(3);
3608                    }
3609    
3610                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3611    
3612                    query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
3613    
3614                    if (orderByComparator != null) {
3615                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3616    
3617                            if (orderByConditionFields.length > 0) {
3618                                    query.append(WHERE_AND);
3619                            }
3620    
3621                            for (int i = 0; i < orderByConditionFields.length; i++) {
3622                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3623                                    query.append(orderByConditionFields[i]);
3624    
3625                                    if ((i + 1) < orderByConditionFields.length) {
3626                                            if (orderByComparator.isAscending() ^ previous) {
3627                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3628                                            }
3629                                            else {
3630                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3631                                            }
3632                                    }
3633                                    else {
3634                                            if (orderByComparator.isAscending() ^ previous) {
3635                                                    query.append(WHERE_GREATER_THAN);
3636                                            }
3637                                            else {
3638                                                    query.append(WHERE_LESSER_THAN);
3639                                            }
3640                                    }
3641                            }
3642    
3643                            query.append(ORDER_BY_CLAUSE);
3644    
3645                            String[] orderByFields = orderByComparator.getOrderByFields();
3646    
3647                            for (int i = 0; i < orderByFields.length; i++) {
3648                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3649                                    query.append(orderByFields[i]);
3650    
3651                                    if ((i + 1) < orderByFields.length) {
3652                                            if (orderByComparator.isAscending() ^ previous) {
3653                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3654                                            }
3655                                            else {
3656                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3657                                            }
3658                                    }
3659                                    else {
3660                                            if (orderByComparator.isAscending() ^ previous) {
3661                                                    query.append(ORDER_BY_ASC);
3662                                            }
3663                                            else {
3664                                                    query.append(ORDER_BY_DESC);
3665                                            }
3666                                    }
3667                            }
3668                    }
3669                    else {
3670                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
3671                    }
3672    
3673                    String sql = query.toString();
3674    
3675                    Query q = session.createQuery(sql);
3676    
3677                    q.setFirstResult(0);
3678                    q.setMaxResults(2);
3679    
3680                    QueryPos qPos = QueryPos.getInstance(q);
3681    
3682                    qPos.add(classNameId);
3683    
3684                    if (orderByComparator != null) {
3685                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3686    
3687                            for (Object value : values) {
3688                                    qPos.add(value);
3689                            }
3690                    }
3691    
3692                    List<DDMStructure> list = q.list();
3693    
3694                    if (list.size() == 2) {
3695                            return list.get(1);
3696                    }
3697                    else {
3698                            return null;
3699                    }
3700            }
3701    
3702            /**
3703             * Removes all the d d m structures where classNameId = &#63; from the database.
3704             *
3705             * @param classNameId the class name ID
3706             * @throws SystemException if a system exception occurred
3707             */
3708            @Override
3709            public void removeByClassNameId(long classNameId) throws SystemException {
3710                    for (DDMStructure ddmStructure : findByClassNameId(classNameId,
3711                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3712                            remove(ddmStructure);
3713                    }
3714            }
3715    
3716            /**
3717             * Returns the number of d d m structures where classNameId = &#63;.
3718             *
3719             * @param classNameId the class name ID
3720             * @return the number of matching d d m structures
3721             * @throws SystemException if a system exception occurred
3722             */
3723            @Override
3724            public int countByClassNameId(long classNameId) throws SystemException {
3725                    FinderPath finderPath = FINDER_PATH_COUNT_BY_CLASSNAMEID;
3726    
3727                    Object[] finderArgs = new Object[] { classNameId };
3728    
3729                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3730                                    this);
3731    
3732                    if (count == null) {
3733                            StringBundler query = new StringBundler(2);
3734    
3735                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
3736    
3737                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
3738    
3739                            String sql = query.toString();
3740    
3741                            Session session = null;
3742    
3743                            try {
3744                                    session = openSession();
3745    
3746                                    Query q = session.createQuery(sql);
3747    
3748                                    QueryPos qPos = QueryPos.getInstance(q);
3749    
3750                                    qPos.add(classNameId);
3751    
3752                                    count = (Long)q.uniqueResult();
3753    
3754                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3755                            }
3756                            catch (Exception e) {
3757                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3758    
3759                                    throw processException(e);
3760                            }
3761                            finally {
3762                                    closeSession(session);
3763                            }
3764                    }
3765    
3766                    return count.intValue();
3767            }
3768    
3769            private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
3770            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREKEY =
3771                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3772                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
3773                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStructureKey",
3774                            new String[] {
3775                                    String.class.getName(),
3776                                    
3777                            Integer.class.getName(), Integer.class.getName(),
3778                                    OrderByComparator.class.getName()
3779                            });
3780            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREKEY =
3781                    new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3782                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
3783                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureKey",
3784                            new String[] { String.class.getName() },
3785                            DDMStructureModelImpl.STRUCTUREKEY_COLUMN_BITMASK);
3786            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREKEY = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3787                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
3788                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureKey",
3789                            new String[] { String.class.getName() });
3790    
3791            /**
3792             * Returns all the d d m structures where structureKey = &#63;.
3793             *
3794             * @param structureKey the structure key
3795             * @return the matching d d m structures
3796             * @throws SystemException if a system exception occurred
3797             */
3798            @Override
3799            public List<DDMStructure> findByStructureKey(String structureKey)
3800                    throws SystemException {
3801                    return findByStructureKey(structureKey, QueryUtil.ALL_POS,
3802                            QueryUtil.ALL_POS, null);
3803            }
3804    
3805            /**
3806             * Returns a range of all the d d m structures where structureKey = &#63;.
3807             *
3808             * <p>
3809             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3810             * </p>
3811             *
3812             * @param structureKey the structure key
3813             * @param start the lower bound of the range of d d m structures
3814             * @param end the upper bound of the range of d d m structures (not inclusive)
3815             * @return the range of matching d d m structures
3816             * @throws SystemException if a system exception occurred
3817             */
3818            @Override
3819            public List<DDMStructure> findByStructureKey(String structureKey,
3820                    int start, int end) throws SystemException {
3821                    return findByStructureKey(structureKey, start, end, null);
3822            }
3823    
3824            /**
3825             * Returns an ordered range of all the d d m structures where structureKey = &#63;.
3826             *
3827             * <p>
3828             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3829             * </p>
3830             *
3831             * @param structureKey the structure key
3832             * @param start the lower bound of the range of d d m structures
3833             * @param end the upper bound of the range of d d m structures (not inclusive)
3834             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3835             * @return the ordered range of matching d d m structures
3836             * @throws SystemException if a system exception occurred
3837             */
3838            @Override
3839            public List<DDMStructure> findByStructureKey(String structureKey,
3840                    int start, int end, OrderByComparator orderByComparator)
3841                    throws SystemException {
3842                    boolean pagination = true;
3843                    FinderPath finderPath = null;
3844                    Object[] finderArgs = null;
3845    
3846                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3847                                    (orderByComparator == null)) {
3848                            pagination = false;
3849                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREKEY;
3850                            finderArgs = new Object[] { structureKey };
3851                    }
3852                    else {
3853                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREKEY;
3854                            finderArgs = new Object[] {
3855                                            structureKey,
3856                                            
3857                                            start, end, orderByComparator
3858                                    };
3859                    }
3860    
3861                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3862                                    finderArgs, this);
3863    
3864                    if ((list != null) && !list.isEmpty()) {
3865                            for (DDMStructure ddmStructure : list) {
3866                                    if (!Validator.equals(structureKey,
3867                                                            ddmStructure.getStructureKey())) {
3868                                            list = null;
3869    
3870                                            break;
3871                                    }
3872                            }
3873                    }
3874    
3875                    if (list == null) {
3876                            StringBundler query = null;
3877    
3878                            if (orderByComparator != null) {
3879                                    query = new StringBundler(3 +
3880                                                    (orderByComparator.getOrderByFields().length * 3));
3881                            }
3882                            else {
3883                                    query = new StringBundler(3);
3884                            }
3885    
3886                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3887    
3888                            boolean bindStructureKey = false;
3889    
3890                            if (structureKey == null) {
3891                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_1);
3892                            }
3893                            else if (structureKey.equals(StringPool.BLANK)) {
3894                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_3);
3895                            }
3896                            else {
3897                                    bindStructureKey = true;
3898    
3899                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_2);
3900                            }
3901    
3902                            if (orderByComparator != null) {
3903                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3904                                            orderByComparator);
3905                            }
3906                            else
3907                             if (pagination) {
3908                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
3909                            }
3910    
3911                            String sql = query.toString();
3912    
3913                            Session session = null;
3914    
3915                            try {
3916                                    session = openSession();
3917    
3918                                    Query q = session.createQuery(sql);
3919    
3920                                    QueryPos qPos = QueryPos.getInstance(q);
3921    
3922                                    if (bindStructureKey) {
3923                                            qPos.add(structureKey);
3924                                    }
3925    
3926                                    if (!pagination) {
3927                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3928                                                            start, end, false);
3929    
3930                                            Collections.sort(list);
3931    
3932                                            list = new UnmodifiableList<DDMStructure>(list);
3933                                    }
3934                                    else {
3935                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3936                                                            start, end);
3937                                    }
3938    
3939                                    cacheResult(list);
3940    
3941                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3942                            }
3943                            catch (Exception e) {
3944                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3945    
3946                                    throw processException(e);
3947                            }
3948                            finally {
3949                                    closeSession(session);
3950                            }
3951                    }
3952    
3953                    return list;
3954            }
3955    
3956            /**
3957             * Returns the first d d m structure in the ordered set where structureKey = &#63;.
3958             *
3959             * @param structureKey the structure key
3960             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3961             * @return the first matching d d m structure
3962             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
3963             * @throws SystemException if a system exception occurred
3964             */
3965            @Override
3966            public DDMStructure findByStructureKey_First(String structureKey,
3967                    OrderByComparator orderByComparator)
3968                    throws NoSuchStructureException, SystemException {
3969                    DDMStructure ddmStructure = fetchByStructureKey_First(structureKey,
3970                                    orderByComparator);
3971    
3972                    if (ddmStructure != null) {
3973                            return ddmStructure;
3974                    }
3975    
3976                    StringBundler msg = new StringBundler(4);
3977    
3978                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3979    
3980                    msg.append("structureKey=");
3981                    msg.append(structureKey);
3982    
3983                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3984    
3985                    throw new NoSuchStructureException(msg.toString());
3986            }
3987    
3988            /**
3989             * Returns the first d d m structure in the ordered set where structureKey = &#63;.
3990             *
3991             * @param structureKey the structure key
3992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3993             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
3994             * @throws SystemException if a system exception occurred
3995             */
3996            @Override
3997            public DDMStructure fetchByStructureKey_First(String structureKey,
3998                    OrderByComparator orderByComparator) throws SystemException {
3999                    List<DDMStructure> list = findByStructureKey(structureKey, 0, 1,
4000                                    orderByComparator);
4001    
4002                    if (!list.isEmpty()) {
4003                            return list.get(0);
4004                    }
4005    
4006                    return null;
4007            }
4008    
4009            /**
4010             * Returns the last d d m structure in the ordered set where structureKey = &#63;.
4011             *
4012             * @param structureKey the structure key
4013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4014             * @return the last matching d d m structure
4015             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
4016             * @throws SystemException if a system exception occurred
4017             */
4018            @Override
4019            public DDMStructure findByStructureKey_Last(String structureKey,
4020                    OrderByComparator orderByComparator)
4021                    throws NoSuchStructureException, SystemException {
4022                    DDMStructure ddmStructure = fetchByStructureKey_Last(structureKey,
4023                                    orderByComparator);
4024    
4025                    if (ddmStructure != null) {
4026                            return ddmStructure;
4027                    }
4028    
4029                    StringBundler msg = new StringBundler(4);
4030    
4031                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4032    
4033                    msg.append("structureKey=");
4034                    msg.append(structureKey);
4035    
4036                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4037    
4038                    throw new NoSuchStructureException(msg.toString());
4039            }
4040    
4041            /**
4042             * Returns the last d d m structure in the ordered set where structureKey = &#63;.
4043             *
4044             * @param structureKey the structure key
4045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4046             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
4047             * @throws SystemException if a system exception occurred
4048             */
4049            @Override
4050            public DDMStructure fetchByStructureKey_Last(String structureKey,
4051                    OrderByComparator orderByComparator) throws SystemException {
4052                    int count = countByStructureKey(structureKey);
4053    
4054                    if (count == 0) {
4055                            return null;
4056                    }
4057    
4058                    List<DDMStructure> list = findByStructureKey(structureKey, count - 1,
4059                                    count, orderByComparator);
4060    
4061                    if (!list.isEmpty()) {
4062                            return list.get(0);
4063                    }
4064    
4065                    return null;
4066            }
4067    
4068            /**
4069             * Returns the d d m structures before and after the current d d m structure in the ordered set where structureKey = &#63;.
4070             *
4071             * @param structureId the primary key of the current d d m structure
4072             * @param structureKey the structure key
4073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4074             * @return the previous, current, and next d d m structure
4075             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
4076             * @throws SystemException if a system exception occurred
4077             */
4078            @Override
4079            public DDMStructure[] findByStructureKey_PrevAndNext(long structureId,
4080                    String structureKey, OrderByComparator orderByComparator)
4081                    throws NoSuchStructureException, SystemException {
4082                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
4083    
4084                    Session session = null;
4085    
4086                    try {
4087                            session = openSession();
4088    
4089                            DDMStructure[] array = new DDMStructureImpl[3];
4090    
4091                            array[0] = getByStructureKey_PrevAndNext(session, ddmStructure,
4092                                            structureKey, orderByComparator, true);
4093    
4094                            array[1] = ddmStructure;
4095    
4096                            array[2] = getByStructureKey_PrevAndNext(session, ddmStructure,
4097                                            structureKey, orderByComparator, false);
4098    
4099                            return array;
4100                    }
4101                    catch (Exception e) {
4102                            throw processException(e);
4103                    }
4104                    finally {
4105                            closeSession(session);
4106                    }
4107            }
4108    
4109            protected DDMStructure getByStructureKey_PrevAndNext(Session session,
4110                    DDMStructure ddmStructure, String structureKey,
4111                    OrderByComparator orderByComparator, boolean previous) {
4112                    StringBundler query = null;
4113    
4114                    if (orderByComparator != null) {
4115                            query = new StringBundler(6 +
4116                                            (orderByComparator.getOrderByFields().length * 6));
4117                    }
4118                    else {
4119                            query = new StringBundler(3);
4120                    }
4121    
4122                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
4123    
4124                    boolean bindStructureKey = false;
4125    
4126                    if (structureKey == null) {
4127                            query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_1);
4128                    }
4129                    else if (structureKey.equals(StringPool.BLANK)) {
4130                            query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_3);
4131                    }
4132                    else {
4133                            bindStructureKey = true;
4134    
4135                            query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_2);
4136                    }
4137    
4138                    if (orderByComparator != null) {
4139                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4140    
4141                            if (orderByConditionFields.length > 0) {
4142                                    query.append(WHERE_AND);
4143                            }
4144    
4145                            for (int i = 0; i < orderByConditionFields.length; i++) {
4146                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4147                                    query.append(orderByConditionFields[i]);
4148    
4149                                    if ((i + 1) < orderByConditionFields.length) {
4150                                            if (orderByComparator.isAscending() ^ previous) {
4151                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4152                                            }
4153                                            else {
4154                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4155                                            }
4156                                    }
4157                                    else {
4158                                            if (orderByComparator.isAscending() ^ previous) {
4159                                                    query.append(WHERE_GREATER_THAN);
4160                                            }
4161                                            else {
4162                                                    query.append(WHERE_LESSER_THAN);
4163                                            }
4164                                    }
4165                            }
4166    
4167                            query.append(ORDER_BY_CLAUSE);
4168    
4169                            String[] orderByFields = orderByComparator.getOrderByFields();
4170    
4171                            for (int i = 0; i < orderByFields.length; i++) {
4172                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4173                                    query.append(orderByFields[i]);
4174    
4175                                    if ((i + 1) < orderByFields.length) {
4176                                            if (orderByComparator.isAscending() ^ previous) {
4177                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4178                                            }
4179                                            else {
4180                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4181                                            }
4182                                    }
4183                                    else {
4184                                            if (orderByComparator.isAscending() ^ previous) {
4185                                                    query.append(ORDER_BY_ASC);
4186                                            }
4187                                            else {
4188                                                    query.append(ORDER_BY_DESC);
4189                                            }
4190                                    }
4191                            }
4192                    }
4193                    else {
4194                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
4195                    }
4196    
4197                    String sql = query.toString();
4198    
4199                    Query q = session.createQuery(sql);
4200    
4201                    q.setFirstResult(0);
4202                    q.setMaxResults(2);
4203    
4204                    QueryPos qPos = QueryPos.getInstance(q);
4205    
4206                    if (bindStructureKey) {
4207                            qPos.add(structureKey);
4208                    }
4209    
4210                    if (orderByComparator != null) {
4211                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
4212    
4213                            for (Object value : values) {
4214                                    qPos.add(value);
4215                            }
4216                    }
4217    
4218                    List<DDMStructure> list = q.list();
4219    
4220                    if (list.size() == 2) {
4221                            return list.get(1);
4222                    }
4223                    else {
4224                            return null;
4225                    }
4226            }
4227    
4228            /**
4229             * Removes all the d d m structures where structureKey = &#63; from the database.
4230             *
4231             * @param structureKey the structure key
4232             * @throws SystemException if a system exception occurred
4233             */
4234            @Override
4235            public void removeByStructureKey(String structureKey)
4236                    throws SystemException {
4237                    for (DDMStructure ddmStructure : findByStructureKey(structureKey,
4238                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4239                            remove(ddmStructure);
4240                    }
4241            }
4242    
4243            /**
4244             * Returns the number of d d m structures where structureKey = &#63;.
4245             *
4246             * @param structureKey the structure key
4247             * @return the number of matching d d m structures
4248             * @throws SystemException if a system exception occurred
4249             */
4250            @Override
4251            public int countByStructureKey(String structureKey)
4252                    throws SystemException {
4253                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREKEY;
4254    
4255                    Object[] finderArgs = new Object[] { structureKey };
4256    
4257                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4258                                    this);
4259    
4260                    if (count == null) {
4261                            StringBundler query = new StringBundler(2);
4262    
4263                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4264    
4265                            boolean bindStructureKey = false;
4266    
4267                            if (structureKey == null) {
4268                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_1);
4269                            }
4270                            else if (structureKey.equals(StringPool.BLANK)) {
4271                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_3);
4272                            }
4273                            else {
4274                                    bindStructureKey = true;
4275    
4276                                    query.append(_FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_2);
4277                            }
4278    
4279                            String sql = query.toString();
4280    
4281                            Session session = null;
4282    
4283                            try {
4284                                    session = openSession();
4285    
4286                                    Query q = session.createQuery(sql);
4287    
4288                                    QueryPos qPos = QueryPos.getInstance(q);
4289    
4290                                    if (bindStructureKey) {
4291                                            qPos.add(structureKey);
4292                                    }
4293    
4294                                    count = (Long)q.uniqueResult();
4295    
4296                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4297                            }
4298                            catch (Exception e) {
4299                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4300    
4301                                    throw processException(e);
4302                            }
4303                            finally {
4304                                    closeSession(session);
4305                            }
4306                    }
4307    
4308                    return count.intValue();
4309            }
4310    
4311            private static final String _FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_1 = "ddmStructure.structureKey IS NULL";
4312            private static final String _FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_2 = "ddmStructure.structureKey = ?";
4313            private static final String _FINDER_COLUMN_STRUCTUREKEY_STRUCTUREKEY_3 = "(ddmStructure.structureKey IS NULL OR ddmStructure.structureKey = '')";
4314            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
4315                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
4316                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
4317                            new String[] {
4318                                    Long.class.getName(), Long.class.getName(),
4319                                    
4320                            Integer.class.getName(), Integer.class.getName(),
4321                                    OrderByComparator.class.getName()
4322                            });
4323            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
4324                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
4325                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
4326                            new String[] { Long.class.getName(), Long.class.getName() },
4327                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
4328                            DDMStructureModelImpl.PARENTSTRUCTUREID_COLUMN_BITMASK);
4329            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
4330                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
4331                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
4332                            new String[] { Long.class.getName(), Long.class.getName() });
4333    
4334            /**
4335             * Returns all the d d m structures where groupId = &#63; and parentStructureId = &#63;.
4336             *
4337             * @param groupId the group ID
4338             * @param parentStructureId the parent structure ID
4339             * @return the matching d d m structures
4340             * @throws SystemException if a system exception occurred
4341             */
4342            @Override
4343            public List<DDMStructure> findByG_P(long groupId, long parentStructureId)
4344                    throws SystemException {
4345                    return findByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
4346                            QueryUtil.ALL_POS, null);
4347            }
4348    
4349            /**
4350             * Returns a range of all the d d m structures where groupId = &#63; and parentStructureId = &#63;.
4351             *
4352             * <p>
4353             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4354             * </p>
4355             *
4356             * @param groupId the group ID
4357             * @param parentStructureId the parent structure ID
4358             * @param start the lower bound of the range of d d m structures
4359             * @param end the upper bound of the range of d d m structures (not inclusive)
4360             * @return the range of matching d d m structures
4361             * @throws SystemException if a system exception occurred
4362             */
4363            @Override
4364            public List<DDMStructure> findByG_P(long groupId, long parentStructureId,
4365                    int start, int end) throws SystemException {
4366                    return findByG_P(groupId, parentStructureId, start, end, null);
4367            }
4368    
4369            /**
4370             * Returns an ordered range of all the d d m structures where groupId = &#63; and parentStructureId = &#63;.
4371             *
4372             * <p>
4373             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4374             * </p>
4375             *
4376             * @param groupId the group ID
4377             * @param parentStructureId the parent structure ID
4378             * @param start the lower bound of the range of d d m structures
4379             * @param end the upper bound of the range of d d m structures (not inclusive)
4380             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4381             * @return the ordered range of matching d d m structures
4382             * @throws SystemException if a system exception occurred
4383             */
4384            @Override
4385            public List<DDMStructure> findByG_P(long groupId, long parentStructureId,
4386                    int start, int end, OrderByComparator orderByComparator)
4387                    throws SystemException {
4388                    boolean pagination = true;
4389                    FinderPath finderPath = null;
4390                    Object[] finderArgs = null;
4391    
4392                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4393                                    (orderByComparator == null)) {
4394                            pagination = false;
4395                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
4396                            finderArgs = new Object[] { groupId, parentStructureId };
4397                    }
4398                    else {
4399                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
4400                            finderArgs = new Object[] {
4401                                            groupId, parentStructureId,
4402                                            
4403                                            start, end, orderByComparator
4404                                    };
4405                    }
4406    
4407                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
4408                                    finderArgs, this);
4409    
4410                    if ((list != null) && !list.isEmpty()) {
4411                            for (DDMStructure ddmStructure : list) {
4412                                    if ((groupId != ddmStructure.getGroupId()) ||
4413                                                    (parentStructureId != ddmStructure.getParentStructureId())) {
4414                                            list = null;
4415    
4416                                            break;
4417                                    }
4418                            }
4419                    }
4420    
4421                    if (list == null) {
4422                            StringBundler query = null;
4423    
4424                            if (orderByComparator != null) {
4425                                    query = new StringBundler(4 +
4426                                                    (orderByComparator.getOrderByFields().length * 3));
4427                            }
4428                            else {
4429                                    query = new StringBundler(4);
4430                            }
4431    
4432                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
4433    
4434                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4435    
4436                            query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4437    
4438                            if (orderByComparator != null) {
4439                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4440                                            orderByComparator);
4441                            }
4442                            else
4443                             if (pagination) {
4444                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
4445                            }
4446    
4447                            String sql = query.toString();
4448    
4449                            Session session = null;
4450    
4451                            try {
4452                                    session = openSession();
4453    
4454                                    Query q = session.createQuery(sql);
4455    
4456                                    QueryPos qPos = QueryPos.getInstance(q);
4457    
4458                                    qPos.add(groupId);
4459    
4460                                    qPos.add(parentStructureId);
4461    
4462                                    if (!pagination) {
4463                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
4464                                                            start, end, false);
4465    
4466                                            Collections.sort(list);
4467    
4468                                            list = new UnmodifiableList<DDMStructure>(list);
4469                                    }
4470                                    else {
4471                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
4472                                                            start, end);
4473                                    }
4474    
4475                                    cacheResult(list);
4476    
4477                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4478                            }
4479                            catch (Exception e) {
4480                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4481    
4482                                    throw processException(e);
4483                            }
4484                            finally {
4485                                    closeSession(session);
4486                            }
4487                    }
4488    
4489                    return list;
4490            }
4491    
4492            /**
4493             * Returns the first d d m structure in the ordered set where groupId = &#63; and parentStructureId = &#63;.
4494             *
4495             * @param groupId the group ID
4496             * @param parentStructureId the parent structure ID
4497             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4498             * @return the first matching d d m structure
4499             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
4500             * @throws SystemException if a system exception occurred
4501             */
4502            @Override
4503            public DDMStructure findByG_P_First(long groupId, long parentStructureId,
4504                    OrderByComparator orderByComparator)
4505                    throws NoSuchStructureException, SystemException {
4506                    DDMStructure ddmStructure = fetchByG_P_First(groupId,
4507                                    parentStructureId, orderByComparator);
4508    
4509                    if (ddmStructure != null) {
4510                            return ddmStructure;
4511                    }
4512    
4513                    StringBundler msg = new StringBundler(6);
4514    
4515                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4516    
4517                    msg.append("groupId=");
4518                    msg.append(groupId);
4519    
4520                    msg.append(", parentStructureId=");
4521                    msg.append(parentStructureId);
4522    
4523                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4524    
4525                    throw new NoSuchStructureException(msg.toString());
4526            }
4527    
4528            /**
4529             * Returns the first d d m structure in the ordered set where groupId = &#63; and parentStructureId = &#63;.
4530             *
4531             * @param groupId the group ID
4532             * @param parentStructureId the parent structure ID
4533             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4534             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
4535             * @throws SystemException if a system exception occurred
4536             */
4537            @Override
4538            public DDMStructure fetchByG_P_First(long groupId, long parentStructureId,
4539                    OrderByComparator orderByComparator) throws SystemException {
4540                    List<DDMStructure> list = findByG_P(groupId, parentStructureId, 0, 1,
4541                                    orderByComparator);
4542    
4543                    if (!list.isEmpty()) {
4544                            return list.get(0);
4545                    }
4546    
4547                    return null;
4548            }
4549    
4550            /**
4551             * Returns the last d d m structure in the ordered set where groupId = &#63; and parentStructureId = &#63;.
4552             *
4553             * @param groupId the group ID
4554             * @param parentStructureId the parent structure ID
4555             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4556             * @return the last matching d d m structure
4557             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
4558             * @throws SystemException if a system exception occurred
4559             */
4560            @Override
4561            public DDMStructure findByG_P_Last(long groupId, long parentStructureId,
4562                    OrderByComparator orderByComparator)
4563                    throws NoSuchStructureException, SystemException {
4564                    DDMStructure ddmStructure = fetchByG_P_Last(groupId, parentStructureId,
4565                                    orderByComparator);
4566    
4567                    if (ddmStructure != null) {
4568                            return ddmStructure;
4569                    }
4570    
4571                    StringBundler msg = new StringBundler(6);
4572    
4573                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4574    
4575                    msg.append("groupId=");
4576                    msg.append(groupId);
4577    
4578                    msg.append(", parentStructureId=");
4579                    msg.append(parentStructureId);
4580    
4581                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4582    
4583                    throw new NoSuchStructureException(msg.toString());
4584            }
4585    
4586            /**
4587             * Returns the last d d m structure in the ordered set where groupId = &#63; and parentStructureId = &#63;.
4588             *
4589             * @param groupId the group ID
4590             * @param parentStructureId the parent structure ID
4591             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4592             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
4593             * @throws SystemException if a system exception occurred
4594             */
4595            @Override
4596            public DDMStructure fetchByG_P_Last(long groupId, long parentStructureId,
4597                    OrderByComparator orderByComparator) throws SystemException {
4598                    int count = countByG_P(groupId, parentStructureId);
4599    
4600                    if (count == 0) {
4601                            return null;
4602                    }
4603    
4604                    List<DDMStructure> list = findByG_P(groupId, parentStructureId,
4605                                    count - 1, count, orderByComparator);
4606    
4607                    if (!list.isEmpty()) {
4608                            return list.get(0);
4609                    }
4610    
4611                    return null;
4612            }
4613    
4614            /**
4615             * Returns the d d m structures before and after the current d d m structure in the ordered set where groupId = &#63; and parentStructureId = &#63;.
4616             *
4617             * @param structureId the primary key of the current d d m structure
4618             * @param groupId the group ID
4619             * @param parentStructureId the parent structure ID
4620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4621             * @return the previous, current, and next d d m structure
4622             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
4623             * @throws SystemException if a system exception occurred
4624             */
4625            @Override
4626            public DDMStructure[] findByG_P_PrevAndNext(long structureId, long groupId,
4627                    long parentStructureId, OrderByComparator orderByComparator)
4628                    throws NoSuchStructureException, SystemException {
4629                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
4630    
4631                    Session session = null;
4632    
4633                    try {
4634                            session = openSession();
4635    
4636                            DDMStructure[] array = new DDMStructureImpl[3];
4637    
4638                            array[0] = getByG_P_PrevAndNext(session, ddmStructure, groupId,
4639                                            parentStructureId, orderByComparator, true);
4640    
4641                            array[1] = ddmStructure;
4642    
4643                            array[2] = getByG_P_PrevAndNext(session, ddmStructure, groupId,
4644                                            parentStructureId, orderByComparator, false);
4645    
4646                            return array;
4647                    }
4648                    catch (Exception e) {
4649                            throw processException(e);
4650                    }
4651                    finally {
4652                            closeSession(session);
4653                    }
4654            }
4655    
4656            protected DDMStructure getByG_P_PrevAndNext(Session session,
4657                    DDMStructure ddmStructure, long groupId, long parentStructureId,
4658                    OrderByComparator orderByComparator, boolean previous) {
4659                    StringBundler query = null;
4660    
4661                    if (orderByComparator != null) {
4662                            query = new StringBundler(6 +
4663                                            (orderByComparator.getOrderByFields().length * 6));
4664                    }
4665                    else {
4666                            query = new StringBundler(3);
4667                    }
4668    
4669                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
4670    
4671                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4672    
4673                    query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4674    
4675                    if (orderByComparator != null) {
4676                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4677    
4678                            if (orderByConditionFields.length > 0) {
4679                                    query.append(WHERE_AND);
4680                            }
4681    
4682                            for (int i = 0; i < orderByConditionFields.length; i++) {
4683                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4684                                    query.append(orderByConditionFields[i]);
4685    
4686                                    if ((i + 1) < orderByConditionFields.length) {
4687                                            if (orderByComparator.isAscending() ^ previous) {
4688                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4689                                            }
4690                                            else {
4691                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4692                                            }
4693                                    }
4694                                    else {
4695                                            if (orderByComparator.isAscending() ^ previous) {
4696                                                    query.append(WHERE_GREATER_THAN);
4697                                            }
4698                                            else {
4699                                                    query.append(WHERE_LESSER_THAN);
4700                                            }
4701                                    }
4702                            }
4703    
4704                            query.append(ORDER_BY_CLAUSE);
4705    
4706                            String[] orderByFields = orderByComparator.getOrderByFields();
4707    
4708                            for (int i = 0; i < orderByFields.length; i++) {
4709                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4710                                    query.append(orderByFields[i]);
4711    
4712                                    if ((i + 1) < orderByFields.length) {
4713                                            if (orderByComparator.isAscending() ^ previous) {
4714                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4715                                            }
4716                                            else {
4717                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4718                                            }
4719                                    }
4720                                    else {
4721                                            if (orderByComparator.isAscending() ^ previous) {
4722                                                    query.append(ORDER_BY_ASC);
4723                                            }
4724                                            else {
4725                                                    query.append(ORDER_BY_DESC);
4726                                            }
4727                                    }
4728                            }
4729                    }
4730                    else {
4731                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
4732                    }
4733    
4734                    String sql = query.toString();
4735    
4736                    Query q = session.createQuery(sql);
4737    
4738                    q.setFirstResult(0);
4739                    q.setMaxResults(2);
4740    
4741                    QueryPos qPos = QueryPos.getInstance(q);
4742    
4743                    qPos.add(groupId);
4744    
4745                    qPos.add(parentStructureId);
4746    
4747                    if (orderByComparator != null) {
4748                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
4749    
4750                            for (Object value : values) {
4751                                    qPos.add(value);
4752                            }
4753                    }
4754    
4755                    List<DDMStructure> list = q.list();
4756    
4757                    if (list.size() == 2) {
4758                            return list.get(1);
4759                    }
4760                    else {
4761                            return null;
4762                    }
4763            }
4764    
4765            /**
4766             * Returns all the d d m structures that the user has permission to view where groupId = &#63; and parentStructureId = &#63;.
4767             *
4768             * @param groupId the group ID
4769             * @param parentStructureId the parent structure ID
4770             * @return the matching d d m structures that the user has permission to view
4771             * @throws SystemException if a system exception occurred
4772             */
4773            @Override
4774            public List<DDMStructure> filterFindByG_P(long groupId,
4775                    long parentStructureId) throws SystemException {
4776                    return filterFindByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
4777                            QueryUtil.ALL_POS, null);
4778            }
4779    
4780            /**
4781             * Returns a range of all the d d m structures that the user has permission to view where groupId = &#63; and parentStructureId = &#63;.
4782             *
4783             * <p>
4784             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4785             * </p>
4786             *
4787             * @param groupId the group ID
4788             * @param parentStructureId the parent structure ID
4789             * @param start the lower bound of the range of d d m structures
4790             * @param end the upper bound of the range of d d m structures (not inclusive)
4791             * @return the range of matching d d m structures that the user has permission to view
4792             * @throws SystemException if a system exception occurred
4793             */
4794            @Override
4795            public List<DDMStructure> filterFindByG_P(long groupId,
4796                    long parentStructureId, int start, int end) throws SystemException {
4797                    return filterFindByG_P(groupId, parentStructureId, start, end, null);
4798            }
4799    
4800            /**
4801             * Returns an ordered range of all the d d m structures that the user has permissions to view where groupId = &#63; and parentStructureId = &#63;.
4802             *
4803             * <p>
4804             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4805             * </p>
4806             *
4807             * @param groupId the group ID
4808             * @param parentStructureId the parent structure ID
4809             * @param start the lower bound of the range of d d m structures
4810             * @param end the upper bound of the range of d d m structures (not inclusive)
4811             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4812             * @return the ordered range of matching d d m structures that the user has permission to view
4813             * @throws SystemException if a system exception occurred
4814             */
4815            @Override
4816            public List<DDMStructure> filterFindByG_P(long groupId,
4817                    long parentStructureId, int start, int end,
4818                    OrderByComparator orderByComparator) throws SystemException {
4819                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4820                            return findByG_P(groupId, parentStructureId, start, end,
4821                                    orderByComparator);
4822                    }
4823    
4824                    StringBundler query = null;
4825    
4826                    if (orderByComparator != null) {
4827                            query = new StringBundler(4 +
4828                                            (orderByComparator.getOrderByFields().length * 3));
4829                    }
4830                    else {
4831                            query = new StringBundler(4);
4832                    }
4833    
4834                    if (getDB().isSupportsInlineDistinct()) {
4835                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
4836                    }
4837                    else {
4838                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
4839                    }
4840    
4841                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4842    
4843                    query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4844    
4845                    if (!getDB().isSupportsInlineDistinct()) {
4846                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
4847                    }
4848    
4849                    if (orderByComparator != null) {
4850                            if (getDB().isSupportsInlineDistinct()) {
4851                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4852                                            orderByComparator, true);
4853                            }
4854                            else {
4855                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4856                                            orderByComparator, true);
4857                            }
4858                    }
4859                    else {
4860                            if (getDB().isSupportsInlineDistinct()) {
4861                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
4862                            }
4863                            else {
4864                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
4865                            }
4866                    }
4867    
4868                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4869                                    DDMStructure.class.getName(),
4870                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4871    
4872                    Session session = null;
4873    
4874                    try {
4875                            session = openSession();
4876    
4877                            SQLQuery q = session.createSQLQuery(sql);
4878    
4879                            if (getDB().isSupportsInlineDistinct()) {
4880                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
4881                            }
4882                            else {
4883                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
4884                            }
4885    
4886                            QueryPos qPos = QueryPos.getInstance(q);
4887    
4888                            qPos.add(groupId);
4889    
4890                            qPos.add(parentStructureId);
4891    
4892                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
4893                                    end);
4894                    }
4895                    catch (Exception e) {
4896                            throw processException(e);
4897                    }
4898                    finally {
4899                            closeSession(session);
4900                    }
4901            }
4902    
4903            /**
4904             * 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 parentStructureId = &#63;.
4905             *
4906             * @param structureId the primary key of the current d d m structure
4907             * @param groupId the group ID
4908             * @param parentStructureId the parent structure ID
4909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4910             * @return the previous, current, and next d d m structure
4911             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
4912             * @throws SystemException if a system exception occurred
4913             */
4914            @Override
4915            public DDMStructure[] filterFindByG_P_PrevAndNext(long structureId,
4916                    long groupId, long parentStructureId,
4917                    OrderByComparator orderByComparator)
4918                    throws NoSuchStructureException, SystemException {
4919                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4920                            return findByG_P_PrevAndNext(structureId, groupId,
4921                                    parentStructureId, orderByComparator);
4922                    }
4923    
4924                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
4925    
4926                    Session session = null;
4927    
4928                    try {
4929                            session = openSession();
4930    
4931                            DDMStructure[] array = new DDMStructureImpl[3];
4932    
4933                            array[0] = filterGetByG_P_PrevAndNext(session, ddmStructure,
4934                                            groupId, parentStructureId, orderByComparator, true);
4935    
4936                            array[1] = ddmStructure;
4937    
4938                            array[2] = filterGetByG_P_PrevAndNext(session, ddmStructure,
4939                                            groupId, parentStructureId, orderByComparator, false);
4940    
4941                            return array;
4942                    }
4943                    catch (Exception e) {
4944                            throw processException(e);
4945                    }
4946                    finally {
4947                            closeSession(session);
4948                    }
4949            }
4950    
4951            protected DDMStructure filterGetByG_P_PrevAndNext(Session session,
4952                    DDMStructure ddmStructure, long groupId, long parentStructureId,
4953                    OrderByComparator orderByComparator, boolean previous) {
4954                    StringBundler query = null;
4955    
4956                    if (orderByComparator != null) {
4957                            query = new StringBundler(6 +
4958                                            (orderByComparator.getOrderByFields().length * 6));
4959                    }
4960                    else {
4961                            query = new StringBundler(3);
4962                    }
4963    
4964                    if (getDB().isSupportsInlineDistinct()) {
4965                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
4966                    }
4967                    else {
4968                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
4969                    }
4970    
4971                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4972    
4973                    query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4974    
4975                    if (!getDB().isSupportsInlineDistinct()) {
4976                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
4977                    }
4978    
4979                    if (orderByComparator != null) {
4980                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4981    
4982                            if (orderByConditionFields.length > 0) {
4983                                    query.append(WHERE_AND);
4984                            }
4985    
4986                            for (int i = 0; i < orderByConditionFields.length; i++) {
4987                                    if (getDB().isSupportsInlineDistinct()) {
4988                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4989                                    }
4990                                    else {
4991                                            query.append(_ORDER_BY_ENTITY_TABLE);
4992                                    }
4993    
4994                                    query.append(orderByConditionFields[i]);
4995    
4996                                    if ((i + 1) < orderByConditionFields.length) {
4997                                            if (orderByComparator.isAscending() ^ previous) {
4998                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4999                                            }
5000                                            else {
5001                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5002                                            }
5003                                    }
5004                                    else {
5005                                            if (orderByComparator.isAscending() ^ previous) {
5006                                                    query.append(WHERE_GREATER_THAN);
5007                                            }
5008                                            else {
5009                                                    query.append(WHERE_LESSER_THAN);
5010                                            }
5011                                    }
5012                            }
5013    
5014                            query.append(ORDER_BY_CLAUSE);
5015    
5016                            String[] orderByFields = orderByComparator.getOrderByFields();
5017    
5018                            for (int i = 0; i < orderByFields.length; i++) {
5019                                    if (getDB().isSupportsInlineDistinct()) {
5020                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5021                                    }
5022                                    else {
5023                                            query.append(_ORDER_BY_ENTITY_TABLE);
5024                                    }
5025    
5026                                    query.append(orderByFields[i]);
5027    
5028                                    if ((i + 1) < orderByFields.length) {
5029                                            if (orderByComparator.isAscending() ^ previous) {
5030                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5031                                            }
5032                                            else {
5033                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5034                                            }
5035                                    }
5036                                    else {
5037                                            if (orderByComparator.isAscending() ^ previous) {
5038                                                    query.append(ORDER_BY_ASC);
5039                                            }
5040                                            else {
5041                                                    query.append(ORDER_BY_DESC);
5042                                            }
5043                                    }
5044                            }
5045                    }
5046                    else {
5047                            if (getDB().isSupportsInlineDistinct()) {
5048                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
5049                            }
5050                            else {
5051                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
5052                            }
5053                    }
5054    
5055                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5056                                    DDMStructure.class.getName(),
5057                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5058    
5059                    SQLQuery q = session.createSQLQuery(sql);
5060    
5061                    q.setFirstResult(0);
5062                    q.setMaxResults(2);
5063    
5064                    if (getDB().isSupportsInlineDistinct()) {
5065                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
5066                    }
5067                    else {
5068                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
5069                    }
5070    
5071                    QueryPos qPos = QueryPos.getInstance(q);
5072    
5073                    qPos.add(groupId);
5074    
5075                    qPos.add(parentStructureId);
5076    
5077                    if (orderByComparator != null) {
5078                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
5079    
5080                            for (Object value : values) {
5081                                    qPos.add(value);
5082                            }
5083                    }
5084    
5085                    List<DDMStructure> list = q.list();
5086    
5087                    if (list.size() == 2) {
5088                            return list.get(1);
5089                    }
5090                    else {
5091                            return null;
5092                    }
5093            }
5094    
5095            /**
5096             * Removes all the d d m structures where groupId = &#63; and parentStructureId = &#63; from the database.
5097             *
5098             * @param groupId the group ID
5099             * @param parentStructureId the parent structure ID
5100             * @throws SystemException if a system exception occurred
5101             */
5102            @Override
5103            public void removeByG_P(long groupId, long parentStructureId)
5104                    throws SystemException {
5105                    for (DDMStructure ddmStructure : findByG_P(groupId, parentStructureId,
5106                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5107                            remove(ddmStructure);
5108                    }
5109            }
5110    
5111            /**
5112             * Returns the number of d d m structures where groupId = &#63; and parentStructureId = &#63;.
5113             *
5114             * @param groupId the group ID
5115             * @param parentStructureId the parent structure ID
5116             * @return the number of matching d d m structures
5117             * @throws SystemException if a system exception occurred
5118             */
5119            @Override
5120            public int countByG_P(long groupId, long parentStructureId)
5121                    throws SystemException {
5122                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
5123    
5124                    Object[] finderArgs = new Object[] { groupId, parentStructureId };
5125    
5126                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5127                                    this);
5128    
5129                    if (count == null) {
5130                            StringBundler query = new StringBundler(3);
5131    
5132                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
5133    
5134                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5135    
5136                            query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
5137    
5138                            String sql = query.toString();
5139    
5140                            Session session = null;
5141    
5142                            try {
5143                                    session = openSession();
5144    
5145                                    Query q = session.createQuery(sql);
5146    
5147                                    QueryPos qPos = QueryPos.getInstance(q);
5148    
5149                                    qPos.add(groupId);
5150    
5151                                    qPos.add(parentStructureId);
5152    
5153                                    count = (Long)q.uniqueResult();
5154    
5155                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5156                            }
5157                            catch (Exception e) {
5158                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5159    
5160                                    throw processException(e);
5161                            }
5162                            finally {
5163                                    closeSession(session);
5164                            }
5165                    }
5166    
5167                    return count.intValue();
5168            }
5169    
5170            /**
5171             * Returns the number of d d m structures that the user has permission to view where groupId = &#63; and parentStructureId = &#63;.
5172             *
5173             * @param groupId the group ID
5174             * @param parentStructureId the parent structure ID
5175             * @return the number of matching d d m structures that the user has permission to view
5176             * @throws SystemException if a system exception occurred
5177             */
5178            @Override
5179            public int filterCountByG_P(long groupId, long parentStructureId)
5180                    throws SystemException {
5181                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5182                            return countByG_P(groupId, parentStructureId);
5183                    }
5184    
5185                    StringBundler query = new StringBundler(3);
5186    
5187                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
5188    
5189                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5190    
5191                    query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
5192    
5193                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5194                                    DDMStructure.class.getName(),
5195                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5196    
5197                    Session session = null;
5198    
5199                    try {
5200                            session = openSession();
5201    
5202                            SQLQuery q = session.createSQLQuery(sql);
5203    
5204                            q.addScalar(COUNT_COLUMN_NAME,
5205                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5206    
5207                            QueryPos qPos = QueryPos.getInstance(q);
5208    
5209                            qPos.add(groupId);
5210    
5211                            qPos.add(parentStructureId);
5212    
5213                            Long count = (Long)q.uniqueResult();
5214    
5215                            return count.intValue();
5216                    }
5217                    catch (Exception e) {
5218                            throw processException(e);
5219                    }
5220                    finally {
5221                            closeSession(session);
5222                    }
5223            }
5224    
5225            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "ddmStructure.groupId = ? AND ";
5226            private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2 = "ddmStructure.parentStructureId = ?";
5227            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
5228                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
5229                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
5230                            new String[] {
5231                                    Long.class.getName(), Long.class.getName(),
5232                                    
5233                            Integer.class.getName(), Integer.class.getName(),
5234                                    OrderByComparator.class.getName()
5235                            });
5236            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
5237                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
5238                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
5239                            new String[] { Long.class.getName(), Long.class.getName() },
5240                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
5241                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
5242            public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
5243                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
5244                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
5245                            new String[] { Long.class.getName(), Long.class.getName() });
5246            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
5247                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
5248                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C",
5249                            new String[] { Long.class.getName(), Long.class.getName() });
5250    
5251            /**
5252             * Returns all the d d m structures where groupId = &#63; and classNameId = &#63;.
5253             *
5254             * @param groupId the group ID
5255             * @param classNameId the class name ID
5256             * @return the matching d d m structures
5257             * @throws SystemException if a system exception occurred
5258             */
5259            @Override
5260            public List<DDMStructure> findByG_C(long groupId, long classNameId)
5261                    throws SystemException {
5262                    return findByG_C(groupId, classNameId, QueryUtil.ALL_POS,
5263                            QueryUtil.ALL_POS, null);
5264            }
5265    
5266            /**
5267             * Returns a range of all the d d m structures where groupId = &#63; and classNameId = &#63;.
5268             *
5269             * <p>
5270             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5271             * </p>
5272             *
5273             * @param groupId the group ID
5274             * @param classNameId the class name ID
5275             * @param start the lower bound of the range of d d m structures
5276             * @param end the upper bound of the range of d d m structures (not inclusive)
5277             * @return the range of matching d d m structures
5278             * @throws SystemException if a system exception occurred
5279             */
5280            @Override
5281            public List<DDMStructure> findByG_C(long groupId, long classNameId,
5282                    int start, int end) throws SystemException {
5283                    return findByG_C(groupId, classNameId, start, end, null);
5284            }
5285    
5286            /**
5287             * Returns an ordered range of all the d d m structures where groupId = &#63; and classNameId = &#63;.
5288             *
5289             * <p>
5290             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5291             * </p>
5292             *
5293             * @param groupId the group ID
5294             * @param classNameId the class name ID
5295             * @param start the lower bound of the range of d d m structures
5296             * @param end the upper bound of the range of d d m structures (not inclusive)
5297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5298             * @return the ordered range of matching d d m structures
5299             * @throws SystemException if a system exception occurred
5300             */
5301            @Override
5302            public List<DDMStructure> findByG_C(long groupId, long classNameId,
5303                    int start, int end, OrderByComparator orderByComparator)
5304                    throws SystemException {
5305                    boolean pagination = true;
5306                    FinderPath finderPath = null;
5307                    Object[] finderArgs = null;
5308    
5309                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5310                                    (orderByComparator == null)) {
5311                            pagination = false;
5312                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
5313                            finderArgs = new Object[] { groupId, classNameId };
5314                    }
5315                    else {
5316                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
5317                            finderArgs = new Object[] {
5318                                            groupId, classNameId,
5319                                            
5320                                            start, end, orderByComparator
5321                                    };
5322                    }
5323    
5324                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
5325                                    finderArgs, this);
5326    
5327                    if ((list != null) && !list.isEmpty()) {
5328                            for (DDMStructure ddmStructure : list) {
5329                                    if ((groupId != ddmStructure.getGroupId()) ||
5330                                                    (classNameId != ddmStructure.getClassNameId())) {
5331                                            list = null;
5332    
5333                                            break;
5334                                    }
5335                            }
5336                    }
5337    
5338                    if (list == null) {
5339                            StringBundler query = null;
5340    
5341                            if (orderByComparator != null) {
5342                                    query = new StringBundler(4 +
5343                                                    (orderByComparator.getOrderByFields().length * 3));
5344                            }
5345                            else {
5346                                    query = new StringBundler(4);
5347                            }
5348    
5349                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
5350    
5351                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5352    
5353                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
5354    
5355                            if (orderByComparator != null) {
5356                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5357                                            orderByComparator);
5358                            }
5359                            else
5360                             if (pagination) {
5361                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
5362                            }
5363    
5364                            String sql = query.toString();
5365    
5366                            Session session = null;
5367    
5368                            try {
5369                                    session = openSession();
5370    
5371                                    Query q = session.createQuery(sql);
5372    
5373                                    QueryPos qPos = QueryPos.getInstance(q);
5374    
5375                                    qPos.add(groupId);
5376    
5377                                    qPos.add(classNameId);
5378    
5379                                    if (!pagination) {
5380                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
5381                                                            start, end, false);
5382    
5383                                            Collections.sort(list);
5384    
5385                                            list = new UnmodifiableList<DDMStructure>(list);
5386                                    }
5387                                    else {
5388                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
5389                                                            start, end);
5390                                    }
5391    
5392                                    cacheResult(list);
5393    
5394                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5395                            }
5396                            catch (Exception e) {
5397                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5398    
5399                                    throw processException(e);
5400                            }
5401                            finally {
5402                                    closeSession(session);
5403                            }
5404                    }
5405    
5406                    return list;
5407            }
5408    
5409            /**
5410             * Returns the first d d m structure in the ordered set where groupId = &#63; and classNameId = &#63;.
5411             *
5412             * @param groupId the group ID
5413             * @param classNameId the class name ID
5414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5415             * @return the first matching d d m structure
5416             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
5417             * @throws SystemException if a system exception occurred
5418             */
5419            @Override
5420            public DDMStructure findByG_C_First(long groupId, long classNameId,
5421                    OrderByComparator orderByComparator)
5422                    throws NoSuchStructureException, SystemException {
5423                    DDMStructure ddmStructure = fetchByG_C_First(groupId, classNameId,
5424                                    orderByComparator);
5425    
5426                    if (ddmStructure != null) {
5427                            return ddmStructure;
5428                    }
5429    
5430                    StringBundler msg = new StringBundler(6);
5431    
5432                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5433    
5434                    msg.append("groupId=");
5435                    msg.append(groupId);
5436    
5437                    msg.append(", classNameId=");
5438                    msg.append(classNameId);
5439    
5440                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5441    
5442                    throw new NoSuchStructureException(msg.toString());
5443            }
5444    
5445            /**
5446             * Returns the first d d m structure in the ordered set where groupId = &#63; and classNameId = &#63;.
5447             *
5448             * @param groupId the group ID
5449             * @param classNameId the class name ID
5450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5451             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
5452             * @throws SystemException if a system exception occurred
5453             */
5454            @Override
5455            public DDMStructure fetchByG_C_First(long groupId, long classNameId,
5456                    OrderByComparator orderByComparator) throws SystemException {
5457                    List<DDMStructure> list = findByG_C(groupId, classNameId, 0, 1,
5458                                    orderByComparator);
5459    
5460                    if (!list.isEmpty()) {
5461                            return list.get(0);
5462                    }
5463    
5464                    return null;
5465            }
5466    
5467            /**
5468             * Returns the last d d m structure in the ordered set where groupId = &#63; and classNameId = &#63;.
5469             *
5470             * @param groupId the group ID
5471             * @param classNameId the class name ID
5472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5473             * @return the last matching d d m structure
5474             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
5475             * @throws SystemException if a system exception occurred
5476             */
5477            @Override
5478            public DDMStructure findByG_C_Last(long groupId, long classNameId,
5479                    OrderByComparator orderByComparator)
5480                    throws NoSuchStructureException, SystemException {
5481                    DDMStructure ddmStructure = fetchByG_C_Last(groupId, classNameId,
5482                                    orderByComparator);
5483    
5484                    if (ddmStructure != null) {
5485                            return ddmStructure;
5486                    }
5487    
5488                    StringBundler msg = new StringBundler(6);
5489    
5490                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5491    
5492                    msg.append("groupId=");
5493                    msg.append(groupId);
5494    
5495                    msg.append(", classNameId=");
5496                    msg.append(classNameId);
5497    
5498                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5499    
5500                    throw new NoSuchStructureException(msg.toString());
5501            }
5502    
5503            /**
5504             * Returns the last d d m structure in the ordered set where groupId = &#63; and classNameId = &#63;.
5505             *
5506             * @param groupId the group ID
5507             * @param classNameId the class name ID
5508             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5509             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
5510             * @throws SystemException if a system exception occurred
5511             */
5512            @Override
5513            public DDMStructure fetchByG_C_Last(long groupId, long classNameId,
5514                    OrderByComparator orderByComparator) throws SystemException {
5515                    int count = countByG_C(groupId, classNameId);
5516    
5517                    if (count == 0) {
5518                            return null;
5519                    }
5520    
5521                    List<DDMStructure> list = findByG_C(groupId, classNameId, count - 1,
5522                                    count, orderByComparator);
5523    
5524                    if (!list.isEmpty()) {
5525                            return list.get(0);
5526                    }
5527    
5528                    return null;
5529            }
5530    
5531            /**
5532             * Returns the d d m structures before and after the current d d m structure in the ordered set where groupId = &#63; and classNameId = &#63;.
5533             *
5534             * @param structureId the primary key of the current d d m structure
5535             * @param groupId the group ID
5536             * @param classNameId the class name ID
5537             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5538             * @return the previous, current, and next d d m structure
5539             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
5540             * @throws SystemException if a system exception occurred
5541             */
5542            @Override
5543            public DDMStructure[] findByG_C_PrevAndNext(long structureId, long groupId,
5544                    long classNameId, OrderByComparator orderByComparator)
5545                    throws NoSuchStructureException, SystemException {
5546                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
5547    
5548                    Session session = null;
5549    
5550                    try {
5551                            session = openSession();
5552    
5553                            DDMStructure[] array = new DDMStructureImpl[3];
5554    
5555                            array[0] = getByG_C_PrevAndNext(session, ddmStructure, groupId,
5556                                            classNameId, orderByComparator, true);
5557    
5558                            array[1] = ddmStructure;
5559    
5560                            array[2] = getByG_C_PrevAndNext(session, ddmStructure, groupId,
5561                                            classNameId, orderByComparator, false);
5562    
5563                            return array;
5564                    }
5565                    catch (Exception e) {
5566                            throw processException(e);
5567                    }
5568                    finally {
5569                            closeSession(session);
5570                    }
5571            }
5572    
5573            protected DDMStructure getByG_C_PrevAndNext(Session session,
5574                    DDMStructure ddmStructure, long groupId, long classNameId,
5575                    OrderByComparator orderByComparator, boolean previous) {
5576                    StringBundler query = null;
5577    
5578                    if (orderByComparator != null) {
5579                            query = new StringBundler(6 +
5580                                            (orderByComparator.getOrderByFields().length * 6));
5581                    }
5582                    else {
5583                            query = new StringBundler(3);
5584                    }
5585    
5586                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
5587    
5588                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5589    
5590                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
5591    
5592                    if (orderByComparator != null) {
5593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5594    
5595                            if (orderByConditionFields.length > 0) {
5596                                    query.append(WHERE_AND);
5597                            }
5598    
5599                            for (int i = 0; i < orderByConditionFields.length; i++) {
5600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5601                                    query.append(orderByConditionFields[i]);
5602    
5603                                    if ((i + 1) < orderByConditionFields.length) {
5604                                            if (orderByComparator.isAscending() ^ previous) {
5605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5606                                            }
5607                                            else {
5608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5609                                            }
5610                                    }
5611                                    else {
5612                                            if (orderByComparator.isAscending() ^ previous) {
5613                                                    query.append(WHERE_GREATER_THAN);
5614                                            }
5615                                            else {
5616                                                    query.append(WHERE_LESSER_THAN);
5617                                            }
5618                                    }
5619                            }
5620    
5621                            query.append(ORDER_BY_CLAUSE);
5622    
5623                            String[] orderByFields = orderByComparator.getOrderByFields();
5624    
5625                            for (int i = 0; i < orderByFields.length; i++) {
5626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5627                                    query.append(orderByFields[i]);
5628    
5629                                    if ((i + 1) < orderByFields.length) {
5630                                            if (orderByComparator.isAscending() ^ previous) {
5631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5632                                            }
5633                                            else {
5634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5635                                            }
5636                                    }
5637                                    else {
5638                                            if (orderByComparator.isAscending() ^ previous) {
5639                                                    query.append(ORDER_BY_ASC);
5640                                            }
5641                                            else {
5642                                                    query.append(ORDER_BY_DESC);
5643                                            }
5644                                    }
5645                            }
5646                    }
5647                    else {
5648                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
5649                    }
5650    
5651                    String sql = query.toString();
5652    
5653                    Query q = session.createQuery(sql);
5654    
5655                    q.setFirstResult(0);
5656                    q.setMaxResults(2);
5657    
5658                    QueryPos qPos = QueryPos.getInstance(q);
5659    
5660                    qPos.add(groupId);
5661    
5662                    qPos.add(classNameId);
5663    
5664                    if (orderByComparator != null) {
5665                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
5666    
5667                            for (Object value : values) {
5668                                    qPos.add(value);
5669                            }
5670                    }
5671    
5672                    List<DDMStructure> list = q.list();
5673    
5674                    if (list.size() == 2) {
5675                            return list.get(1);
5676                    }
5677                    else {
5678                            return null;
5679                    }
5680            }
5681    
5682            /**
5683             * Returns all the d d m structures that the user has permission to view where groupId = &#63; and classNameId = &#63;.
5684             *
5685             * @param groupId the group ID
5686             * @param classNameId the class name ID
5687             * @return the matching d d m structures that the user has permission to view
5688             * @throws SystemException if a system exception occurred
5689             */
5690            @Override
5691            public List<DDMStructure> filterFindByG_C(long groupId, long classNameId)
5692                    throws SystemException {
5693                    return filterFindByG_C(groupId, classNameId, QueryUtil.ALL_POS,
5694                            QueryUtil.ALL_POS, null);
5695            }
5696    
5697            /**
5698             * Returns a range of all the d d m structures that the user has permission to view where groupId = &#63; and classNameId = &#63;.
5699             *
5700             * <p>
5701             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5702             * </p>
5703             *
5704             * @param groupId the group ID
5705             * @param classNameId the class name ID
5706             * @param start the lower bound of the range of d d m structures
5707             * @param end the upper bound of the range of d d m structures (not inclusive)
5708             * @return the range of matching d d m structures that the user has permission to view
5709             * @throws SystemException if a system exception occurred
5710             */
5711            @Override
5712            public List<DDMStructure> filterFindByG_C(long groupId, long classNameId,
5713                    int start, int end) throws SystemException {
5714                    return filterFindByG_C(groupId, classNameId, start, end, null);
5715            }
5716    
5717            /**
5718             * Returns an ordered range of all the d d m structures that the user has permissions to view where groupId = &#63; and classNameId = &#63;.
5719             *
5720             * <p>
5721             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5722             * </p>
5723             *
5724             * @param groupId the group ID
5725             * @param classNameId the class name ID
5726             * @param start the lower bound of the range of d d m structures
5727             * @param end the upper bound of the range of d d m structures (not inclusive)
5728             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5729             * @return the ordered range of matching d d m structures that the user has permission to view
5730             * @throws SystemException if a system exception occurred
5731             */
5732            @Override
5733            public List<DDMStructure> filterFindByG_C(long groupId, long classNameId,
5734                    int start, int end, OrderByComparator orderByComparator)
5735                    throws SystemException {
5736                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5737                            return findByG_C(groupId, classNameId, start, end, orderByComparator);
5738                    }
5739    
5740                    StringBundler query = null;
5741    
5742                    if (orderByComparator != null) {
5743                            query = new StringBundler(4 +
5744                                            (orderByComparator.getOrderByFields().length * 3));
5745                    }
5746                    else {
5747                            query = new StringBundler(4);
5748                    }
5749    
5750                    if (getDB().isSupportsInlineDistinct()) {
5751                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
5752                    }
5753                    else {
5754                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
5755                    }
5756    
5757                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5758    
5759                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
5760    
5761                    if (!getDB().isSupportsInlineDistinct()) {
5762                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
5763                    }
5764    
5765                    if (orderByComparator != null) {
5766                            if (getDB().isSupportsInlineDistinct()) {
5767                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5768                                            orderByComparator, true);
5769                            }
5770                            else {
5771                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5772                                            orderByComparator, true);
5773                            }
5774                    }
5775                    else {
5776                            if (getDB().isSupportsInlineDistinct()) {
5777                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
5778                            }
5779                            else {
5780                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
5781                            }
5782                    }
5783    
5784                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5785                                    DDMStructure.class.getName(),
5786                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5787    
5788                    Session session = null;
5789    
5790                    try {
5791                            session = openSession();
5792    
5793                            SQLQuery q = session.createSQLQuery(sql);
5794    
5795                            if (getDB().isSupportsInlineDistinct()) {
5796                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
5797                            }
5798                            else {
5799                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
5800                            }
5801    
5802                            QueryPos qPos = QueryPos.getInstance(q);
5803    
5804                            qPos.add(groupId);
5805    
5806                            qPos.add(classNameId);
5807    
5808                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
5809                                    end);
5810                    }
5811                    catch (Exception e) {
5812                            throw processException(e);
5813                    }
5814                    finally {
5815                            closeSession(session);
5816                    }
5817            }
5818    
5819            /**
5820             * 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 classNameId = &#63;.
5821             *
5822             * @param structureId the primary key of the current d d m structure
5823             * @param groupId the group ID
5824             * @param classNameId the class name ID
5825             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5826             * @return the previous, current, and next d d m structure
5827             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
5828             * @throws SystemException if a system exception occurred
5829             */
5830            @Override
5831            public DDMStructure[] filterFindByG_C_PrevAndNext(long structureId,
5832                    long groupId, long classNameId, OrderByComparator orderByComparator)
5833                    throws NoSuchStructureException, SystemException {
5834                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5835                            return findByG_C_PrevAndNext(structureId, groupId, classNameId,
5836                                    orderByComparator);
5837                    }
5838    
5839                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
5840    
5841                    Session session = null;
5842    
5843                    try {
5844                            session = openSession();
5845    
5846                            DDMStructure[] array = new DDMStructureImpl[3];
5847    
5848                            array[0] = filterGetByG_C_PrevAndNext(session, ddmStructure,
5849                                            groupId, classNameId, orderByComparator, true);
5850    
5851                            array[1] = ddmStructure;
5852    
5853                            array[2] = filterGetByG_C_PrevAndNext(session, ddmStructure,
5854                                            groupId, classNameId, orderByComparator, false);
5855    
5856                            return array;
5857                    }
5858                    catch (Exception e) {
5859                            throw processException(e);
5860                    }
5861                    finally {
5862                            closeSession(session);
5863                    }
5864            }
5865    
5866            protected DDMStructure filterGetByG_C_PrevAndNext(Session session,
5867                    DDMStructure ddmStructure, long groupId, long classNameId,
5868                    OrderByComparator orderByComparator, boolean previous) {
5869                    StringBundler query = null;
5870    
5871                    if (orderByComparator != null) {
5872                            query = new StringBundler(6 +
5873                                            (orderByComparator.getOrderByFields().length * 6));
5874                    }
5875                    else {
5876                            query = new StringBundler(3);
5877                    }
5878    
5879                    if (getDB().isSupportsInlineDistinct()) {
5880                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
5881                    }
5882                    else {
5883                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
5884                    }
5885    
5886                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5887    
5888                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
5889    
5890                    if (!getDB().isSupportsInlineDistinct()) {
5891                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
5892                    }
5893    
5894                    if (orderByComparator != null) {
5895                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5896    
5897                            if (orderByConditionFields.length > 0) {
5898                                    query.append(WHERE_AND);
5899                            }
5900    
5901                            for (int i = 0; i < orderByConditionFields.length; i++) {
5902                                    if (getDB().isSupportsInlineDistinct()) {
5903                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5904                                    }
5905                                    else {
5906                                            query.append(_ORDER_BY_ENTITY_TABLE);
5907                                    }
5908    
5909                                    query.append(orderByConditionFields[i]);
5910    
5911                                    if ((i + 1) < orderByConditionFields.length) {
5912                                            if (orderByComparator.isAscending() ^ previous) {
5913                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5914                                            }
5915                                            else {
5916                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5917                                            }
5918                                    }
5919                                    else {
5920                                            if (orderByComparator.isAscending() ^ previous) {
5921                                                    query.append(WHERE_GREATER_THAN);
5922                                            }
5923                                            else {
5924                                                    query.append(WHERE_LESSER_THAN);
5925                                            }
5926                                    }
5927                            }
5928    
5929                            query.append(ORDER_BY_CLAUSE);
5930    
5931                            String[] orderByFields = orderByComparator.getOrderByFields();
5932    
5933                            for (int i = 0; i < orderByFields.length; i++) {
5934                                    if (getDB().isSupportsInlineDistinct()) {
5935                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5936                                    }
5937                                    else {
5938                                            query.append(_ORDER_BY_ENTITY_TABLE);
5939                                    }
5940    
5941                                    query.append(orderByFields[i]);
5942    
5943                                    if ((i + 1) < orderByFields.length) {
5944                                            if (orderByComparator.isAscending() ^ previous) {
5945                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5946                                            }
5947                                            else {
5948                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5949                                            }
5950                                    }
5951                                    else {
5952                                            if (orderByComparator.isAscending() ^ previous) {
5953                                                    query.append(ORDER_BY_ASC);
5954                                            }
5955                                            else {
5956                                                    query.append(ORDER_BY_DESC);
5957                                            }
5958                                    }
5959                            }
5960                    }
5961                    else {
5962                            if (getDB().isSupportsInlineDistinct()) {
5963                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
5964                            }
5965                            else {
5966                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
5967                            }
5968                    }
5969    
5970                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5971                                    DDMStructure.class.getName(),
5972                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5973    
5974                    SQLQuery q = session.createSQLQuery(sql);
5975    
5976                    q.setFirstResult(0);
5977                    q.setMaxResults(2);
5978    
5979                    if (getDB().isSupportsInlineDistinct()) {
5980                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
5981                    }
5982                    else {
5983                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
5984                    }
5985    
5986                    QueryPos qPos = QueryPos.getInstance(q);
5987    
5988                    qPos.add(groupId);
5989    
5990                    qPos.add(classNameId);
5991    
5992                    if (orderByComparator != null) {
5993                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
5994    
5995                            for (Object value : values) {
5996                                    qPos.add(value);
5997                            }
5998                    }
5999    
6000                    List<DDMStructure> list = q.list();
6001    
6002                    if (list.size() == 2) {
6003                            return list.get(1);
6004                    }
6005                    else {
6006                            return null;
6007                    }
6008            }
6009    
6010            /**
6011             * Returns all the d d m structures that the user has permission to view where groupId = any &#63; and classNameId = &#63;.
6012             *
6013             * @param groupIds the group IDs
6014             * @param classNameId the class name ID
6015             * @return the matching d d m structures that the user has permission to view
6016             * @throws SystemException if a system exception occurred
6017             */
6018            @Override
6019            public List<DDMStructure> filterFindByG_C(long[] groupIds, long classNameId)
6020                    throws SystemException {
6021                    return filterFindByG_C(groupIds, classNameId, QueryUtil.ALL_POS,
6022                            QueryUtil.ALL_POS, null);
6023            }
6024    
6025            /**
6026             * Returns a range of all the d d m structures that the user has permission to view where groupId = any &#63; and classNameId = &#63;.
6027             *
6028             * <p>
6029             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6030             * </p>
6031             *
6032             * @param groupIds the group IDs
6033             * @param classNameId the class name ID
6034             * @param start the lower bound of the range of d d m structures
6035             * @param end the upper bound of the range of d d m structures (not inclusive)
6036             * @return the range of matching d d m structures that the user has permission to view
6037             * @throws SystemException if a system exception occurred
6038             */
6039            @Override
6040            public List<DDMStructure> filterFindByG_C(long[] groupIds,
6041                    long classNameId, int start, int end) throws SystemException {
6042                    return filterFindByG_C(groupIds, classNameId, start, end, null);
6043            }
6044    
6045            /**
6046             * Returns an ordered range of all the d d m structures that the user has permission to view where groupId = any &#63; and classNameId = &#63;.
6047             *
6048             * <p>
6049             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6050             * </p>
6051             *
6052             * @param groupIds the group IDs
6053             * @param classNameId the class name ID
6054             * @param start the lower bound of the range of d d m structures
6055             * @param end the upper bound of the range of d d m structures (not inclusive)
6056             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6057             * @return the ordered range of matching d d m structures that the user has permission to view
6058             * @throws SystemException if a system exception occurred
6059             */
6060            @Override
6061            public List<DDMStructure> filterFindByG_C(long[] groupIds,
6062                    long classNameId, int start, int end,
6063                    OrderByComparator orderByComparator) throws SystemException {
6064                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
6065                            return findByG_C(groupIds, classNameId, start, end,
6066                                    orderByComparator);
6067                    }
6068    
6069                    StringBundler query = new StringBundler();
6070    
6071                    if (getDB().isSupportsInlineDistinct()) {
6072                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
6073                    }
6074                    else {
6075                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
6076                    }
6077    
6078                    boolean conjunctionable = false;
6079    
6080                    if ((groupIds == null) || (groupIds.length > 0)) {
6081                            if (conjunctionable) {
6082                                    query.append(WHERE_AND);
6083                            }
6084    
6085                            query.append(StringPool.OPEN_PARENTHESIS);
6086    
6087                            for (int i = 0; i < groupIds.length; i++) {
6088                                    query.append(_FINDER_COLUMN_G_C_GROUPID_5);
6089    
6090                                    if ((i + 1) < groupIds.length) {
6091                                            query.append(WHERE_OR);
6092                                    }
6093                            }
6094    
6095                            query.append(StringPool.CLOSE_PARENTHESIS);
6096    
6097                            conjunctionable = true;
6098                    }
6099    
6100                    if (conjunctionable) {
6101                            query.append(WHERE_AND);
6102                    }
6103    
6104                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_5);
6105    
6106                    conjunctionable = true;
6107    
6108                    if (!getDB().isSupportsInlineDistinct()) {
6109                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
6110                    }
6111    
6112                    if (orderByComparator != null) {
6113                            if (getDB().isSupportsInlineDistinct()) {
6114                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6115                                            orderByComparator, true);
6116                            }
6117                            else {
6118                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6119                                            orderByComparator, true);
6120                            }
6121                    }
6122                    else {
6123                            if (getDB().isSupportsInlineDistinct()) {
6124                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
6125                            }
6126                            else {
6127                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
6128                            }
6129                    }
6130    
6131                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6132                                    DDMStructure.class.getName(),
6133                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
6134    
6135                    Session session = null;
6136    
6137                    try {
6138                            session = openSession();
6139    
6140                            SQLQuery q = session.createSQLQuery(sql);
6141    
6142                            if (getDB().isSupportsInlineDistinct()) {
6143                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
6144                            }
6145                            else {
6146                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
6147                            }
6148    
6149                            QueryPos qPos = QueryPos.getInstance(q);
6150    
6151                            if (groupIds != null) {
6152                                    qPos.add(groupIds);
6153                            }
6154    
6155                            qPos.add(classNameId);
6156    
6157                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
6158                                    end);
6159                    }
6160                    catch (Exception e) {
6161                            throw processException(e);
6162                    }
6163                    finally {
6164                            closeSession(session);
6165                    }
6166            }
6167    
6168            /**
6169             * Returns all the d d m structures where groupId = any &#63; and classNameId = &#63;.
6170             *
6171             * <p>
6172             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6173             * </p>
6174             *
6175             * @param groupIds the group IDs
6176             * @param classNameId the class name ID
6177             * @return the matching d d m structures
6178             * @throws SystemException if a system exception occurred
6179             */
6180            @Override
6181            public List<DDMStructure> findByG_C(long[] groupIds, long classNameId)
6182                    throws SystemException {
6183                    return findByG_C(groupIds, classNameId, QueryUtil.ALL_POS,
6184                            QueryUtil.ALL_POS, null);
6185            }
6186    
6187            /**
6188             * Returns a range of all the d d m structures where groupId = any &#63; and classNameId = &#63;.
6189             *
6190             * <p>
6191             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6192             * </p>
6193             *
6194             * @param groupIds the group IDs
6195             * @param classNameId the class name ID
6196             * @param start the lower bound of the range of d d m structures
6197             * @param end the upper bound of the range of d d m structures (not inclusive)
6198             * @return the range of matching d d m structures
6199             * @throws SystemException if a system exception occurred
6200             */
6201            @Override
6202            public List<DDMStructure> findByG_C(long[] groupIds, long classNameId,
6203                    int start, int end) throws SystemException {
6204                    return findByG_C(groupIds, classNameId, start, end, null);
6205            }
6206    
6207            /**
6208             * Returns an ordered range of all the d d m structures where groupId = any &#63; and classNameId = &#63;.
6209             *
6210             * <p>
6211             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6212             * </p>
6213             *
6214             * @param groupIds the group IDs
6215             * @param classNameId the class name ID
6216             * @param start the lower bound of the range of d d m structures
6217             * @param end the upper bound of the range of d d m structures (not inclusive)
6218             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6219             * @return the ordered range of matching d d m structures
6220             * @throws SystemException if a system exception occurred
6221             */
6222            @Override
6223            public List<DDMStructure> findByG_C(long[] groupIds, long classNameId,
6224                    int start, int end, OrderByComparator orderByComparator)
6225                    throws SystemException {
6226                    if ((groupIds != null) && (groupIds.length == 1)) {
6227                            return findByG_C(groupIds[0], classNameId, start, end,
6228                                    orderByComparator);
6229                    }
6230    
6231                    boolean pagination = true;
6232                    Object[] finderArgs = null;
6233    
6234                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6235                                    (orderByComparator == null)) {
6236                            pagination = false;
6237                            finderArgs = new Object[] { StringUtil.merge(groupIds), classNameId };
6238                    }
6239                    else {
6240                            finderArgs = new Object[] {
6241                                            StringUtil.merge(groupIds), classNameId,
6242                                            
6243                                            start, end, orderByComparator
6244                                    };
6245                    }
6246    
6247                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
6248                                    finderArgs, this);
6249    
6250                    if ((list != null) && !list.isEmpty()) {
6251                            for (DDMStructure ddmStructure : list) {
6252                                    if (!ArrayUtil.contains(groupIds, ddmStructure.getGroupId()) ||
6253                                                    (classNameId != ddmStructure.getClassNameId())) {
6254                                            list = null;
6255    
6256                                            break;
6257                                    }
6258                            }
6259                    }
6260    
6261                    if (list == null) {
6262                            StringBundler query = new StringBundler();
6263    
6264                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
6265    
6266                            boolean conjunctionable = false;
6267    
6268                            if ((groupIds == null) || (groupIds.length > 0)) {
6269                                    if (conjunctionable) {
6270                                            query.append(WHERE_AND);
6271                                    }
6272    
6273                                    query.append(StringPool.OPEN_PARENTHESIS);
6274    
6275                                    for (int i = 0; i < groupIds.length; i++) {
6276                                            query.append(_FINDER_COLUMN_G_C_GROUPID_5);
6277    
6278                                            if ((i + 1) < groupIds.length) {
6279                                                    query.append(WHERE_OR);
6280                                            }
6281                                    }
6282    
6283                                    query.append(StringPool.CLOSE_PARENTHESIS);
6284    
6285                                    conjunctionable = true;
6286                            }
6287    
6288                            if (conjunctionable) {
6289                                    query.append(WHERE_AND);
6290                            }
6291    
6292                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_5);
6293    
6294                            conjunctionable = true;
6295    
6296                            if (orderByComparator != null) {
6297                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6298                                            orderByComparator);
6299                            }
6300                            else
6301                             if (pagination) {
6302                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
6303                            }
6304    
6305                            String sql = query.toString();
6306    
6307                            Session session = null;
6308    
6309                            try {
6310                                    session = openSession();
6311    
6312                                    Query q = session.createQuery(sql);
6313    
6314                                    QueryPos qPos = QueryPos.getInstance(q);
6315    
6316                                    if (groupIds != null) {
6317                                            qPos.add(groupIds);
6318                                    }
6319    
6320                                    qPos.add(classNameId);
6321    
6322                                    if (!pagination) {
6323                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
6324                                                            start, end, false);
6325    
6326                                            Collections.sort(list);
6327    
6328                                            list = new UnmodifiableList<DDMStructure>(list);
6329                                    }
6330                                    else {
6331                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
6332                                                            start, end);
6333                                    }
6334    
6335                                    cacheResult(list);
6336    
6337                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
6338                                            finderArgs, list);
6339                            }
6340                            catch (Exception e) {
6341                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
6342                                            finderArgs);
6343    
6344                                    throw processException(e);
6345                            }
6346                            finally {
6347                                    closeSession(session);
6348                            }
6349                    }
6350    
6351                    return list;
6352            }
6353    
6354            /**
6355             * Removes all the d d m structures where groupId = &#63; and classNameId = &#63; from the database.
6356             *
6357             * @param groupId the group ID
6358             * @param classNameId the class name ID
6359             * @throws SystemException if a system exception occurred
6360             */
6361            @Override
6362            public void removeByG_C(long groupId, long classNameId)
6363                    throws SystemException {
6364                    for (DDMStructure ddmStructure : findByG_C(groupId, classNameId,
6365                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6366                            remove(ddmStructure);
6367                    }
6368            }
6369    
6370            /**
6371             * Returns the number of d d m structures where groupId = &#63; and classNameId = &#63;.
6372             *
6373             * @param groupId the group ID
6374             * @param classNameId the class name ID
6375             * @return the number of matching d d m structures
6376             * @throws SystemException if a system exception occurred
6377             */
6378            @Override
6379            public int countByG_C(long groupId, long classNameId)
6380                    throws SystemException {
6381                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
6382    
6383                    Object[] finderArgs = new Object[] { groupId, classNameId };
6384    
6385                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6386                                    this);
6387    
6388                    if (count == null) {
6389                            StringBundler query = new StringBundler(3);
6390    
6391                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
6392    
6393                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
6394    
6395                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
6396    
6397                            String sql = query.toString();
6398    
6399                            Session session = null;
6400    
6401                            try {
6402                                    session = openSession();
6403    
6404                                    Query q = session.createQuery(sql);
6405    
6406                                    QueryPos qPos = QueryPos.getInstance(q);
6407    
6408                                    qPos.add(groupId);
6409    
6410                                    qPos.add(classNameId);
6411    
6412                                    count = (Long)q.uniqueResult();
6413    
6414                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6415                            }
6416                            catch (Exception e) {
6417                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6418    
6419                                    throw processException(e);
6420                            }
6421                            finally {
6422                                    closeSession(session);
6423                            }
6424                    }
6425    
6426                    return count.intValue();
6427            }
6428    
6429            /**
6430             * Returns the number of d d m structures where groupId = any &#63; and classNameId = &#63;.
6431             *
6432             * @param groupIds the group IDs
6433             * @param classNameId the class name ID
6434             * @return the number of matching d d m structures
6435             * @throws SystemException if a system exception occurred
6436             */
6437            @Override
6438            public int countByG_C(long[] groupIds, long classNameId)
6439                    throws SystemException {
6440                    Object[] finderArgs = new Object[] {
6441                                    StringUtil.merge(groupIds), classNameId
6442                            };
6443    
6444                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
6445                                    finderArgs, this);
6446    
6447                    if (count == null) {
6448                            StringBundler query = new StringBundler();
6449    
6450                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
6451    
6452                            boolean conjunctionable = false;
6453    
6454                            if ((groupIds == null) || (groupIds.length > 0)) {
6455                                    if (conjunctionable) {
6456                                            query.append(WHERE_AND);
6457                                    }
6458    
6459                                    query.append(StringPool.OPEN_PARENTHESIS);
6460    
6461                                    for (int i = 0; i < groupIds.length; i++) {
6462                                            query.append(_FINDER_COLUMN_G_C_GROUPID_5);
6463    
6464                                            if ((i + 1) < groupIds.length) {
6465                                                    query.append(WHERE_OR);
6466                                            }
6467                                    }
6468    
6469                                    query.append(StringPool.CLOSE_PARENTHESIS);
6470    
6471                                    conjunctionable = true;
6472                            }
6473    
6474                            if (conjunctionable) {
6475                                    query.append(WHERE_AND);
6476                            }
6477    
6478                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_5);
6479    
6480                            conjunctionable = true;
6481    
6482                            String sql = query.toString();
6483    
6484                            Session session = null;
6485    
6486                            try {
6487                                    session = openSession();
6488    
6489                                    Query q = session.createQuery(sql);
6490    
6491                                    QueryPos qPos = QueryPos.getInstance(q);
6492    
6493                                    if (groupIds != null) {
6494                                            qPos.add(groupIds);
6495                                    }
6496    
6497                                    qPos.add(classNameId);
6498    
6499                                    count = (Long)q.uniqueResult();
6500    
6501                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
6502                                            finderArgs, count);
6503                            }
6504                            catch (Exception e) {
6505                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
6506                                            finderArgs);
6507    
6508                                    throw processException(e);
6509                            }
6510                            finally {
6511                                    closeSession(session);
6512                            }
6513                    }
6514    
6515                    return count.intValue();
6516            }
6517    
6518            /**
6519             * Returns the number of d d m structures that the user has permission to view where groupId = &#63; and classNameId = &#63;.
6520             *
6521             * @param groupId the group ID
6522             * @param classNameId the class name ID
6523             * @return the number of matching d d m structures that the user has permission to view
6524             * @throws SystemException if a system exception occurred
6525             */
6526            @Override
6527            public int filterCountByG_C(long groupId, long classNameId)
6528                    throws SystemException {
6529                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6530                            return countByG_C(groupId, classNameId);
6531                    }
6532    
6533                    StringBundler query = new StringBundler(3);
6534    
6535                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
6536    
6537                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
6538    
6539                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
6540    
6541                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6542                                    DDMStructure.class.getName(),
6543                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6544    
6545                    Session session = null;
6546    
6547                    try {
6548                            session = openSession();
6549    
6550                            SQLQuery q = session.createSQLQuery(sql);
6551    
6552                            q.addScalar(COUNT_COLUMN_NAME,
6553                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6554    
6555                            QueryPos qPos = QueryPos.getInstance(q);
6556    
6557                            qPos.add(groupId);
6558    
6559                            qPos.add(classNameId);
6560    
6561                            Long count = (Long)q.uniqueResult();
6562    
6563                            return count.intValue();
6564                    }
6565                    catch (Exception e) {
6566                            throw processException(e);
6567                    }
6568                    finally {
6569                            closeSession(session);
6570                    }
6571            }
6572    
6573            /**
6574             * Returns the number of d d m structures that the user has permission to view where groupId = any &#63; and classNameId = &#63;.
6575             *
6576             * @param groupIds the group IDs
6577             * @param classNameId the class name ID
6578             * @return the number of matching d d m structures that the user has permission to view
6579             * @throws SystemException if a system exception occurred
6580             */
6581            @Override
6582            public int filterCountByG_C(long[] groupIds, long classNameId)
6583                    throws SystemException {
6584                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
6585                            return countByG_C(groupIds, classNameId);
6586                    }
6587    
6588                    StringBundler query = new StringBundler();
6589    
6590                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
6591    
6592                    boolean conjunctionable = false;
6593    
6594                    if ((groupIds == null) || (groupIds.length > 0)) {
6595                            if (conjunctionable) {
6596                                    query.append(WHERE_AND);
6597                            }
6598    
6599                            query.append(StringPool.OPEN_PARENTHESIS);
6600    
6601                            for (int i = 0; i < groupIds.length; i++) {
6602                                    query.append(_FINDER_COLUMN_G_C_GROUPID_5);
6603    
6604                                    if ((i + 1) < groupIds.length) {
6605                                            query.append(WHERE_OR);
6606                                    }
6607                            }
6608    
6609                            query.append(StringPool.CLOSE_PARENTHESIS);
6610    
6611                            conjunctionable = true;
6612                    }
6613    
6614                    if (conjunctionable) {
6615                            query.append(WHERE_AND);
6616                    }
6617    
6618                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_5);
6619    
6620                    conjunctionable = true;
6621    
6622                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6623                                    DDMStructure.class.getName(),
6624                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
6625    
6626                    Session session = null;
6627    
6628                    try {
6629                            session = openSession();
6630    
6631                            SQLQuery q = session.createSQLQuery(sql);
6632    
6633                            q.addScalar(COUNT_COLUMN_NAME,
6634                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6635    
6636                            QueryPos qPos = QueryPos.getInstance(q);
6637    
6638                            if (groupIds != null) {
6639                                    qPos.add(groupIds);
6640                            }
6641    
6642                            qPos.add(classNameId);
6643    
6644                            Long count = (Long)q.uniqueResult();
6645    
6646                            return count.intValue();
6647                    }
6648                    catch (Exception e) {
6649                            throw processException(e);
6650                    }
6651                    finally {
6652                            closeSession(session);
6653                    }
6654            }
6655    
6656            private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "ddmStructure.groupId = ? AND ";
6657            private static final String _FINDER_COLUMN_G_C_GROUPID_5 = "(" +
6658                    removeConjunction(_FINDER_COLUMN_G_C_GROUPID_2) + ")";
6659            private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
6660            private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_5 = "(" +
6661                    removeConjunction(_FINDER_COLUMN_G_C_CLASSNAMEID_2) + ")";
6662            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
6663                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
6664                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
6665                            new String[] {
6666                                    Long.class.getName(), Long.class.getName(),
6667                                    
6668                            Integer.class.getName(), Integer.class.getName(),
6669                                    OrderByComparator.class.getName()
6670                            });
6671            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
6672                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
6673                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
6674                            new String[] { Long.class.getName(), Long.class.getName() },
6675                            DDMStructureModelImpl.COMPANYID_COLUMN_BITMASK |
6676                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
6677            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
6678                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
6679                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
6680                            new String[] { Long.class.getName(), Long.class.getName() });
6681    
6682            /**
6683             * Returns all the d d m structures where companyId = &#63; and classNameId = &#63;.
6684             *
6685             * @param companyId the company ID
6686             * @param classNameId the class name ID
6687             * @return the matching d d m structures
6688             * @throws SystemException if a system exception occurred
6689             */
6690            @Override
6691            public List<DDMStructure> findByC_C(long companyId, long classNameId)
6692                    throws SystemException {
6693                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
6694                            QueryUtil.ALL_POS, null);
6695            }
6696    
6697            /**
6698             * Returns a range of all the d d m structures where companyId = &#63; and classNameId = &#63;.
6699             *
6700             * <p>
6701             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6702             * </p>
6703             *
6704             * @param companyId the company ID
6705             * @param classNameId the class name ID
6706             * @param start the lower bound of the range of d d m structures
6707             * @param end the upper bound of the range of d d m structures (not inclusive)
6708             * @return the range of matching d d m structures
6709             * @throws SystemException if a system exception occurred
6710             */
6711            @Override
6712            public List<DDMStructure> findByC_C(long companyId, long classNameId,
6713                    int start, int end) throws SystemException {
6714                    return findByC_C(companyId, classNameId, start, end, null);
6715            }
6716    
6717            /**
6718             * Returns an ordered range of all the d d m structures where companyId = &#63; and classNameId = &#63;.
6719             *
6720             * <p>
6721             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6722             * </p>
6723             *
6724             * @param companyId the company ID
6725             * @param classNameId the class name ID
6726             * @param start the lower bound of the range of d d m structures
6727             * @param end the upper bound of the range of d d m structures (not inclusive)
6728             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6729             * @return the ordered range of matching d d m structures
6730             * @throws SystemException if a system exception occurred
6731             */
6732            @Override
6733            public List<DDMStructure> findByC_C(long companyId, long classNameId,
6734                    int start, int end, OrderByComparator orderByComparator)
6735                    throws SystemException {
6736                    boolean pagination = true;
6737                    FinderPath finderPath = null;
6738                    Object[] finderArgs = null;
6739    
6740                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6741                                    (orderByComparator == null)) {
6742                            pagination = false;
6743                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
6744                            finderArgs = new Object[] { companyId, classNameId };
6745                    }
6746                    else {
6747                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
6748                            finderArgs = new Object[] {
6749                                            companyId, classNameId,
6750                                            
6751                                            start, end, orderByComparator
6752                                    };
6753                    }
6754    
6755                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
6756                                    finderArgs, this);
6757    
6758                    if ((list != null) && !list.isEmpty()) {
6759                            for (DDMStructure ddmStructure : list) {
6760                                    if ((companyId != ddmStructure.getCompanyId()) ||
6761                                                    (classNameId != ddmStructure.getClassNameId())) {
6762                                            list = null;
6763    
6764                                            break;
6765                                    }
6766                            }
6767                    }
6768    
6769                    if (list == null) {
6770                            StringBundler query = null;
6771    
6772                            if (orderByComparator != null) {
6773                                    query = new StringBundler(4 +
6774                                                    (orderByComparator.getOrderByFields().length * 3));
6775                            }
6776                            else {
6777                                    query = new StringBundler(4);
6778                            }
6779    
6780                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
6781    
6782                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
6783    
6784                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
6785    
6786                            if (orderByComparator != null) {
6787                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6788                                            orderByComparator);
6789                            }
6790                            else
6791                             if (pagination) {
6792                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
6793                            }
6794    
6795                            String sql = query.toString();
6796    
6797                            Session session = null;
6798    
6799                            try {
6800                                    session = openSession();
6801    
6802                                    Query q = session.createQuery(sql);
6803    
6804                                    QueryPos qPos = QueryPos.getInstance(q);
6805    
6806                                    qPos.add(companyId);
6807    
6808                                    qPos.add(classNameId);
6809    
6810                                    if (!pagination) {
6811                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
6812                                                            start, end, false);
6813    
6814                                            Collections.sort(list);
6815    
6816                                            list = new UnmodifiableList<DDMStructure>(list);
6817                                    }
6818                                    else {
6819                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
6820                                                            start, end);
6821                                    }
6822    
6823                                    cacheResult(list);
6824    
6825                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6826                            }
6827                            catch (Exception e) {
6828                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6829    
6830                                    throw processException(e);
6831                            }
6832                            finally {
6833                                    closeSession(session);
6834                            }
6835                    }
6836    
6837                    return list;
6838            }
6839    
6840            /**
6841             * Returns the first d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
6842             *
6843             * @param companyId the company ID
6844             * @param classNameId the class name ID
6845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6846             * @return the first matching d d m structure
6847             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
6848             * @throws SystemException if a system exception occurred
6849             */
6850            @Override
6851            public DDMStructure findByC_C_First(long companyId, long classNameId,
6852                    OrderByComparator orderByComparator)
6853                    throws NoSuchStructureException, SystemException {
6854                    DDMStructure ddmStructure = fetchByC_C_First(companyId, classNameId,
6855                                    orderByComparator);
6856    
6857                    if (ddmStructure != null) {
6858                            return ddmStructure;
6859                    }
6860    
6861                    StringBundler msg = new StringBundler(6);
6862    
6863                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6864    
6865                    msg.append("companyId=");
6866                    msg.append(companyId);
6867    
6868                    msg.append(", classNameId=");
6869                    msg.append(classNameId);
6870    
6871                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6872    
6873                    throw new NoSuchStructureException(msg.toString());
6874            }
6875    
6876            /**
6877             * Returns the first d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
6878             *
6879             * @param companyId the company ID
6880             * @param classNameId the class name ID
6881             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6882             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
6883             * @throws SystemException if a system exception occurred
6884             */
6885            @Override
6886            public DDMStructure fetchByC_C_First(long companyId, long classNameId,
6887                    OrderByComparator orderByComparator) throws SystemException {
6888                    List<DDMStructure> list = findByC_C(companyId, classNameId, 0, 1,
6889                                    orderByComparator);
6890    
6891                    if (!list.isEmpty()) {
6892                            return list.get(0);
6893                    }
6894    
6895                    return null;
6896            }
6897    
6898            /**
6899             * Returns the last d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
6900             *
6901             * @param companyId the company ID
6902             * @param classNameId the class name ID
6903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6904             * @return the last matching d d m structure
6905             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
6906             * @throws SystemException if a system exception occurred
6907             */
6908            @Override
6909            public DDMStructure findByC_C_Last(long companyId, long classNameId,
6910                    OrderByComparator orderByComparator)
6911                    throws NoSuchStructureException, SystemException {
6912                    DDMStructure ddmStructure = fetchByC_C_Last(companyId, classNameId,
6913                                    orderByComparator);
6914    
6915                    if (ddmStructure != null) {
6916                            return ddmStructure;
6917                    }
6918    
6919                    StringBundler msg = new StringBundler(6);
6920    
6921                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6922    
6923                    msg.append("companyId=");
6924                    msg.append(companyId);
6925    
6926                    msg.append(", classNameId=");
6927                    msg.append(classNameId);
6928    
6929                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6930    
6931                    throw new NoSuchStructureException(msg.toString());
6932            }
6933    
6934            /**
6935             * Returns the last d d m structure in the ordered set where companyId = &#63; and classNameId = &#63;.
6936             *
6937             * @param companyId the company ID
6938             * @param classNameId the class name ID
6939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6940             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
6941             * @throws SystemException if a system exception occurred
6942             */
6943            @Override
6944            public DDMStructure fetchByC_C_Last(long companyId, long classNameId,
6945                    OrderByComparator orderByComparator) throws SystemException {
6946                    int count = countByC_C(companyId, classNameId);
6947    
6948                    if (count == 0) {
6949                            return null;
6950                    }
6951    
6952                    List<DDMStructure> list = findByC_C(companyId, classNameId, count - 1,
6953                                    count, orderByComparator);
6954    
6955                    if (!list.isEmpty()) {
6956                            return list.get(0);
6957                    }
6958    
6959                    return null;
6960            }
6961    
6962            /**
6963             * 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;.
6964             *
6965             * @param structureId the primary key of the current d d m structure
6966             * @param companyId the company ID
6967             * @param classNameId the class name ID
6968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6969             * @return the previous, current, and next d d m structure
6970             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
6971             * @throws SystemException if a system exception occurred
6972             */
6973            @Override
6974            public DDMStructure[] findByC_C_PrevAndNext(long structureId,
6975                    long companyId, long classNameId, OrderByComparator orderByComparator)
6976                    throws NoSuchStructureException, SystemException {
6977                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
6978    
6979                    Session session = null;
6980    
6981                    try {
6982                            session = openSession();
6983    
6984                            DDMStructure[] array = new DDMStructureImpl[3];
6985    
6986                            array[0] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
6987                                            classNameId, orderByComparator, true);
6988    
6989                            array[1] = ddmStructure;
6990    
6991                            array[2] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
6992                                            classNameId, orderByComparator, false);
6993    
6994                            return array;
6995                    }
6996                    catch (Exception e) {
6997                            throw processException(e);
6998                    }
6999                    finally {
7000                            closeSession(session);
7001                    }
7002            }
7003    
7004            protected DDMStructure getByC_C_PrevAndNext(Session session,
7005                    DDMStructure ddmStructure, long companyId, long classNameId,
7006                    OrderByComparator orderByComparator, boolean previous) {
7007                    StringBundler query = null;
7008    
7009                    if (orderByComparator != null) {
7010                            query = new StringBundler(6 +
7011                                            (orderByComparator.getOrderByFields().length * 6));
7012                    }
7013                    else {
7014                            query = new StringBundler(3);
7015                    }
7016    
7017                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
7018    
7019                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
7020    
7021                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
7022    
7023                    if (orderByComparator != null) {
7024                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7025    
7026                            if (orderByConditionFields.length > 0) {
7027                                    query.append(WHERE_AND);
7028                            }
7029    
7030                            for (int i = 0; i < orderByConditionFields.length; i++) {
7031                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7032                                    query.append(orderByConditionFields[i]);
7033    
7034                                    if ((i + 1) < orderByConditionFields.length) {
7035                                            if (orderByComparator.isAscending() ^ previous) {
7036                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7037                                            }
7038                                            else {
7039                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7040                                            }
7041                                    }
7042                                    else {
7043                                            if (orderByComparator.isAscending() ^ previous) {
7044                                                    query.append(WHERE_GREATER_THAN);
7045                                            }
7046                                            else {
7047                                                    query.append(WHERE_LESSER_THAN);
7048                                            }
7049                                    }
7050                            }
7051    
7052                            query.append(ORDER_BY_CLAUSE);
7053    
7054                            String[] orderByFields = orderByComparator.getOrderByFields();
7055    
7056                            for (int i = 0; i < orderByFields.length; i++) {
7057                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7058                                    query.append(orderByFields[i]);
7059    
7060                                    if ((i + 1) < orderByFields.length) {
7061                                            if (orderByComparator.isAscending() ^ previous) {
7062                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7063                                            }
7064                                            else {
7065                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7066                                            }
7067                                    }
7068                                    else {
7069                                            if (orderByComparator.isAscending() ^ previous) {
7070                                                    query.append(ORDER_BY_ASC);
7071                                            }
7072                                            else {
7073                                                    query.append(ORDER_BY_DESC);
7074                                            }
7075                                    }
7076                            }
7077                    }
7078                    else {
7079                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
7080                    }
7081    
7082                    String sql = query.toString();
7083    
7084                    Query q = session.createQuery(sql);
7085    
7086                    q.setFirstResult(0);
7087                    q.setMaxResults(2);
7088    
7089                    QueryPos qPos = QueryPos.getInstance(q);
7090    
7091                    qPos.add(companyId);
7092    
7093                    qPos.add(classNameId);
7094    
7095                    if (orderByComparator != null) {
7096                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
7097    
7098                            for (Object value : values) {
7099                                    qPos.add(value);
7100                            }
7101                    }
7102    
7103                    List<DDMStructure> list = q.list();
7104    
7105                    if (list.size() == 2) {
7106                            return list.get(1);
7107                    }
7108                    else {
7109                            return null;
7110                    }
7111            }
7112    
7113            /**
7114             * Removes all the d d m structures where companyId = &#63; and classNameId = &#63; from the database.
7115             *
7116             * @param companyId the company ID
7117             * @param classNameId the class name ID
7118             * @throws SystemException if a system exception occurred
7119             */
7120            @Override
7121            public void removeByC_C(long companyId, long classNameId)
7122                    throws SystemException {
7123                    for (DDMStructure ddmStructure : findByC_C(companyId, classNameId,
7124                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7125                            remove(ddmStructure);
7126                    }
7127            }
7128    
7129            /**
7130             * Returns the number of d d m structures where companyId = &#63; and classNameId = &#63;.
7131             *
7132             * @param companyId the company ID
7133             * @param classNameId the class name ID
7134             * @return the number of matching d d m structures
7135             * @throws SystemException if a system exception occurred
7136             */
7137            @Override
7138            public int countByC_C(long companyId, long classNameId)
7139                    throws SystemException {
7140                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
7141    
7142                    Object[] finderArgs = new Object[] { companyId, classNameId };
7143    
7144                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7145                                    this);
7146    
7147                    if (count == null) {
7148                            StringBundler query = new StringBundler(3);
7149    
7150                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
7151    
7152                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
7153    
7154                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
7155    
7156                            String sql = query.toString();
7157    
7158                            Session session = null;
7159    
7160                            try {
7161                                    session = openSession();
7162    
7163                                    Query q = session.createQuery(sql);
7164    
7165                                    QueryPos qPos = QueryPos.getInstance(q);
7166    
7167                                    qPos.add(companyId);
7168    
7169                                    qPos.add(classNameId);
7170    
7171                                    count = (Long)q.uniqueResult();
7172    
7173                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7174                            }
7175                            catch (Exception e) {
7176                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7177    
7178                                    throw processException(e);
7179                            }
7180                            finally {
7181                                    closeSession(session);
7182                            }
7183                    }
7184    
7185                    return count.intValue();
7186            }
7187    
7188            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "ddmStructure.companyId = ? AND ";
7189            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
7190            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
7191                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
7192                            FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
7193                            new String[] {
7194                                    Long.class.getName(), Long.class.getName(),
7195                                    String.class.getName()
7196                            },
7197                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
7198                            DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK |
7199                            DDMStructureModelImpl.STRUCTUREKEY_COLUMN_BITMASK);
7200            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
7201                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
7202                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
7203                            new String[] {
7204                                    Long.class.getName(), Long.class.getName(),
7205                                    String.class.getName()
7206                            });
7207    
7208            /**
7209             * Returns the d d m structure where groupId = &#63; and classNameId = &#63; and structureKey = &#63; or throws a {@link com.liferay.portlet.dynamicdatamapping.NoSuchStructureException} if it could not be found.
7210             *
7211             * @param groupId the group ID
7212             * @param classNameId the class name ID
7213             * @param structureKey the structure key
7214             * @return the matching d d m structure
7215             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
7216             * @throws SystemException if a system exception occurred
7217             */
7218            @Override
7219            public DDMStructure findByG_C_S(long groupId, long classNameId,
7220                    String structureKey) throws NoSuchStructureException, SystemException {
7221                    DDMStructure ddmStructure = fetchByG_C_S(groupId, classNameId,
7222                                    structureKey);
7223    
7224                    if (ddmStructure == null) {
7225                            StringBundler msg = new StringBundler(8);
7226    
7227                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7228    
7229                            msg.append("groupId=");
7230                            msg.append(groupId);
7231    
7232                            msg.append(", classNameId=");
7233                            msg.append(classNameId);
7234    
7235                            msg.append(", structureKey=");
7236                            msg.append(structureKey);
7237    
7238                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7239    
7240                            if (_log.isWarnEnabled()) {
7241                                    _log.warn(msg.toString());
7242                            }
7243    
7244                            throw new NoSuchStructureException(msg.toString());
7245                    }
7246    
7247                    return ddmStructure;
7248            }
7249    
7250            /**
7251             * Returns the d d m structure where groupId = &#63; and classNameId = &#63; and structureKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
7252             *
7253             * @param groupId the group ID
7254             * @param classNameId the class name ID
7255             * @param structureKey the structure key
7256             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
7257             * @throws SystemException if a system exception occurred
7258             */
7259            @Override
7260            public DDMStructure fetchByG_C_S(long groupId, long classNameId,
7261                    String structureKey) throws SystemException {
7262                    return fetchByG_C_S(groupId, classNameId, structureKey, true);
7263            }
7264    
7265            /**
7266             * Returns the d d m structure where groupId = &#63; and classNameId = &#63; and structureKey = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
7267             *
7268             * @param groupId the group ID
7269             * @param classNameId the class name ID
7270             * @param structureKey the structure key
7271             * @param retrieveFromCache whether to use the finder cache
7272             * @return the matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
7273             * @throws SystemException if a system exception occurred
7274             */
7275            @Override
7276            public DDMStructure fetchByG_C_S(long groupId, long classNameId,
7277                    String structureKey, boolean retrieveFromCache)
7278                    throws SystemException {
7279                    Object[] finderArgs = new Object[] { groupId, classNameId, structureKey };
7280    
7281                    Object result = null;
7282    
7283                    if (retrieveFromCache) {
7284                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
7285                                            finderArgs, this);
7286                    }
7287    
7288                    if (result instanceof DDMStructure) {
7289                            DDMStructure ddmStructure = (DDMStructure)result;
7290    
7291                            if ((groupId != ddmStructure.getGroupId()) ||
7292                                            (classNameId != ddmStructure.getClassNameId()) ||
7293                                            !Validator.equals(structureKey,
7294                                                    ddmStructure.getStructureKey())) {
7295                                    result = null;
7296                            }
7297                    }
7298    
7299                    if (result == null) {
7300                            StringBundler query = new StringBundler(5);
7301    
7302                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
7303    
7304                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
7305    
7306                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
7307    
7308                            boolean bindStructureKey = false;
7309    
7310                            if (structureKey == null) {
7311                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_1);
7312                            }
7313                            else if (structureKey.equals(StringPool.BLANK)) {
7314                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_3);
7315                            }
7316                            else {
7317                                    bindStructureKey = true;
7318    
7319                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_2);
7320                            }
7321    
7322                            String sql = query.toString();
7323    
7324                            Session session = null;
7325    
7326                            try {
7327                                    session = openSession();
7328    
7329                                    Query q = session.createQuery(sql);
7330    
7331                                    QueryPos qPos = QueryPos.getInstance(q);
7332    
7333                                    qPos.add(groupId);
7334    
7335                                    qPos.add(classNameId);
7336    
7337                                    if (bindStructureKey) {
7338                                            qPos.add(structureKey);
7339                                    }
7340    
7341                                    List<DDMStructure> list = q.list();
7342    
7343                                    if (list.isEmpty()) {
7344                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
7345                                                    finderArgs, list);
7346                                    }
7347                                    else {
7348                                            DDMStructure ddmStructure = list.get(0);
7349    
7350                                            result = ddmStructure;
7351    
7352                                            cacheResult(ddmStructure);
7353    
7354                                            if ((ddmStructure.getGroupId() != groupId) ||
7355                                                            (ddmStructure.getClassNameId() != classNameId) ||
7356                                                            (ddmStructure.getStructureKey() == null) ||
7357                                                            !ddmStructure.getStructureKey().equals(structureKey)) {
7358                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
7359                                                            finderArgs, ddmStructure);
7360                                            }
7361                                    }
7362                            }
7363                            catch (Exception e) {
7364                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
7365                                            finderArgs);
7366    
7367                                    throw processException(e);
7368                            }
7369                            finally {
7370                                    closeSession(session);
7371                            }
7372                    }
7373    
7374                    if (result instanceof List<?>) {
7375                            return null;
7376                    }
7377                    else {
7378                            return (DDMStructure)result;
7379                    }
7380            }
7381    
7382            /**
7383             * Removes the d d m structure where groupId = &#63; and classNameId = &#63; and structureKey = &#63; from the database.
7384             *
7385             * @param groupId the group ID
7386             * @param classNameId the class name ID
7387             * @param structureKey the structure key
7388             * @return the d d m structure that was removed
7389             * @throws SystemException if a system exception occurred
7390             */
7391            @Override
7392            public DDMStructure removeByG_C_S(long groupId, long classNameId,
7393                    String structureKey) throws NoSuchStructureException, SystemException {
7394                    DDMStructure ddmStructure = findByG_C_S(groupId, classNameId,
7395                                    structureKey);
7396    
7397                    return remove(ddmStructure);
7398            }
7399    
7400            /**
7401             * Returns the number of d d m structures where groupId = &#63; and classNameId = &#63; and structureKey = &#63;.
7402             *
7403             * @param groupId the group ID
7404             * @param classNameId the class name ID
7405             * @param structureKey the structure key
7406             * @return the number of matching d d m structures
7407             * @throws SystemException if a system exception occurred
7408             */
7409            @Override
7410            public int countByG_C_S(long groupId, long classNameId, String structureKey)
7411                    throws SystemException {
7412                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
7413    
7414                    Object[] finderArgs = new Object[] { groupId, classNameId, structureKey };
7415    
7416                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7417                                    this);
7418    
7419                    if (count == null) {
7420                            StringBundler query = new StringBundler(4);
7421    
7422                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
7423    
7424                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
7425    
7426                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
7427    
7428                            boolean bindStructureKey = false;
7429    
7430                            if (structureKey == null) {
7431                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_1);
7432                            }
7433                            else if (structureKey.equals(StringPool.BLANK)) {
7434                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_3);
7435                            }
7436                            else {
7437                                    bindStructureKey = true;
7438    
7439                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREKEY_2);
7440                            }
7441    
7442                            String sql = query.toString();
7443    
7444                            Session session = null;
7445    
7446                            try {
7447                                    session = openSession();
7448    
7449                                    Query q = session.createQuery(sql);
7450    
7451                                    QueryPos qPos = QueryPos.getInstance(q);
7452    
7453                                    qPos.add(groupId);
7454    
7455                                    qPos.add(classNameId);
7456    
7457                                    if (bindStructureKey) {
7458                                            qPos.add(structureKey);
7459                                    }
7460    
7461                                    count = (Long)q.uniqueResult();
7462    
7463                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7464                            }
7465                            catch (Exception e) {
7466                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7467    
7468                                    throw processException(e);
7469                            }
7470                            finally {
7471                                    closeSession(session);
7472                            }
7473                    }
7474    
7475                    return count.intValue();
7476            }
7477    
7478            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "ddmStructure.groupId = ? AND ";
7479            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "ddmStructure.classNameId = ? AND ";
7480            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREKEY_1 = "ddmStructure.structureKey IS NULL";
7481            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREKEY_2 = "ddmStructure.structureKey = ?";
7482            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREKEY_3 = "(ddmStructure.structureKey IS NULL OR ddmStructure.structureKey = '')";
7483            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
7484                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
7485                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_D",
7486                            new String[] {
7487                                    Long.class.getName(), String.class.getName(),
7488                                    String.class.getName(),
7489                                    
7490                            Integer.class.getName(), Integer.class.getName(),
7491                                    OrderByComparator.class.getName()
7492                            });
7493            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
7494                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
7495                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_D",
7496                            new String[] {
7497                                    Long.class.getName(), String.class.getName(),
7498                                    String.class.getName()
7499                            },
7500                            DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
7501                            DDMStructureModelImpl.NAME_COLUMN_BITMASK |
7502                            DDMStructureModelImpl.DESCRIPTION_COLUMN_BITMASK);
7503            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
7504                            DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
7505                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_D",
7506                            new String[] {
7507                                    Long.class.getName(), String.class.getName(),
7508                                    String.class.getName()
7509                            });
7510    
7511            /**
7512             * Returns all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
7513             *
7514             * @param groupId the group ID
7515             * @param name the name
7516             * @param description the description
7517             * @return the matching d d m structures
7518             * @throws SystemException if a system exception occurred
7519             */
7520            @Override
7521            public List<DDMStructure> findByG_N_D(long groupId, String name,
7522                    String description) throws SystemException {
7523                    return findByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
7524                            QueryUtil.ALL_POS, null);
7525            }
7526    
7527            /**
7528             * Returns a range of all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
7529             *
7530             * <p>
7531             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7532             * </p>
7533             *
7534             * @param groupId the group ID
7535             * @param name the name
7536             * @param description the description
7537             * @param start the lower bound of the range of d d m structures
7538             * @param end the upper bound of the range of d d m structures (not inclusive)
7539             * @return the range of matching d d m structures
7540             * @throws SystemException if a system exception occurred
7541             */
7542            @Override
7543            public List<DDMStructure> findByG_N_D(long groupId, String name,
7544                    String description, int start, int end) throws SystemException {
7545                    return findByG_N_D(groupId, name, description, start, end, null);
7546            }
7547    
7548            /**
7549             * Returns an ordered range of all the d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
7550             *
7551             * <p>
7552             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7553             * </p>
7554             *
7555             * @param groupId the group ID
7556             * @param name the name
7557             * @param description the description
7558             * @param start the lower bound of the range of d d m structures
7559             * @param end the upper bound of the range of d d m structures (not inclusive)
7560             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7561             * @return the ordered range of matching d d m structures
7562             * @throws SystemException if a system exception occurred
7563             */
7564            @Override
7565            public List<DDMStructure> findByG_N_D(long groupId, String name,
7566                    String description, int start, int end,
7567                    OrderByComparator orderByComparator) throws SystemException {
7568                    boolean pagination = true;
7569                    FinderPath finderPath = null;
7570                    Object[] finderArgs = null;
7571    
7572                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7573                                    (orderByComparator == null)) {
7574                            pagination = false;
7575                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D;
7576                            finderArgs = new Object[] { groupId, name, description };
7577                    }
7578                    else {
7579                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D;
7580                            finderArgs = new Object[] {
7581                                            groupId, name, description,
7582                                            
7583                                            start, end, orderByComparator
7584                                    };
7585                    }
7586    
7587                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
7588                                    finderArgs, this);
7589    
7590                    if ((list != null) && !list.isEmpty()) {
7591                            for (DDMStructure ddmStructure : list) {
7592                                    if ((groupId != ddmStructure.getGroupId()) ||
7593                                                    !Validator.equals(name, ddmStructure.getName()) ||
7594                                                    !Validator.equals(description,
7595                                                            ddmStructure.getDescription())) {
7596                                            list = null;
7597    
7598                                            break;
7599                                    }
7600                            }
7601                    }
7602    
7603                    if (list == null) {
7604                            StringBundler query = null;
7605    
7606                            if (orderByComparator != null) {
7607                                    query = new StringBundler(5 +
7608                                                    (orderByComparator.getOrderByFields().length * 3));
7609                            }
7610                            else {
7611                                    query = new StringBundler(5);
7612                            }
7613    
7614                            query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
7615    
7616                            query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
7617    
7618                            boolean bindName = false;
7619    
7620                            if (name == null) {
7621                                    query.append(_FINDER_COLUMN_G_N_D_NAME_1);
7622                            }
7623                            else if (name.equals(StringPool.BLANK)) {
7624                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
7625                            }
7626                            else {
7627                                    bindName = true;
7628    
7629                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
7630                            }
7631    
7632                            boolean bindDescription = false;
7633    
7634                            if (description == null) {
7635                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
7636                            }
7637                            else if (description.equals(StringPool.BLANK)) {
7638                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
7639                            }
7640                            else {
7641                                    bindDescription = true;
7642    
7643                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
7644                            }
7645    
7646                            if (orderByComparator != null) {
7647                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7648                                            orderByComparator);
7649                            }
7650                            else
7651                             if (pagination) {
7652                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
7653                            }
7654    
7655                            String sql = query.toString();
7656    
7657                            Session session = null;
7658    
7659                            try {
7660                                    session = openSession();
7661    
7662                                    Query q = session.createQuery(sql);
7663    
7664                                    QueryPos qPos = QueryPos.getInstance(q);
7665    
7666                                    qPos.add(groupId);
7667    
7668                                    if (bindName) {
7669                                            qPos.add(name);
7670                                    }
7671    
7672                                    if (bindDescription) {
7673                                            qPos.add(description);
7674                                    }
7675    
7676                                    if (!pagination) {
7677                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
7678                                                            start, end, false);
7679    
7680                                            Collections.sort(list);
7681    
7682                                            list = new UnmodifiableList<DDMStructure>(list);
7683                                    }
7684                                    else {
7685                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
7686                                                            start, end);
7687                                    }
7688    
7689                                    cacheResult(list);
7690    
7691                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7692                            }
7693                            catch (Exception e) {
7694                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7695    
7696                                    throw processException(e);
7697                            }
7698                            finally {
7699                                    closeSession(session);
7700                            }
7701                    }
7702    
7703                    return list;
7704            }
7705    
7706            /**
7707             * Returns the first d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
7708             *
7709             * @param groupId the group ID
7710             * @param name the name
7711             * @param description the description
7712             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7713             * @return the first matching d d m structure
7714             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
7715             * @throws SystemException if a system exception occurred
7716             */
7717            @Override
7718            public DDMStructure findByG_N_D_First(long groupId, String name,
7719                    String description, OrderByComparator orderByComparator)
7720                    throws NoSuchStructureException, SystemException {
7721                    DDMStructure ddmStructure = fetchByG_N_D_First(groupId, name,
7722                                    description, orderByComparator);
7723    
7724                    if (ddmStructure != null) {
7725                            return ddmStructure;
7726                    }
7727    
7728                    StringBundler msg = new StringBundler(8);
7729    
7730                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7731    
7732                    msg.append("groupId=");
7733                    msg.append(groupId);
7734    
7735                    msg.append(", name=");
7736                    msg.append(name);
7737    
7738                    msg.append(", description=");
7739                    msg.append(description);
7740    
7741                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7742    
7743                    throw new NoSuchStructureException(msg.toString());
7744            }
7745    
7746            /**
7747             * Returns the first d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
7748             *
7749             * @param groupId the group ID
7750             * @param name the name
7751             * @param description the description
7752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7753             * @return the first matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
7754             * @throws SystemException if a system exception occurred
7755             */
7756            @Override
7757            public DDMStructure fetchByG_N_D_First(long groupId, String name,
7758                    String description, OrderByComparator orderByComparator)
7759                    throws SystemException {
7760                    List<DDMStructure> list = findByG_N_D(groupId, name, description, 0, 1,
7761                                    orderByComparator);
7762    
7763                    if (!list.isEmpty()) {
7764                            return list.get(0);
7765                    }
7766    
7767                    return null;
7768            }
7769    
7770            /**
7771             * Returns the last d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
7772             *
7773             * @param groupId the group ID
7774             * @param name the name
7775             * @param description the description
7776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7777             * @return the last matching d d m structure
7778             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a matching d d m structure could not be found
7779             * @throws SystemException if a system exception occurred
7780             */
7781            @Override
7782            public DDMStructure findByG_N_D_Last(long groupId, String name,
7783                    String description, OrderByComparator orderByComparator)
7784                    throws NoSuchStructureException, SystemException {
7785                    DDMStructure ddmStructure = fetchByG_N_D_Last(groupId, name,
7786                                    description, orderByComparator);
7787    
7788                    if (ddmStructure != null) {
7789                            return ddmStructure;
7790                    }
7791    
7792                    StringBundler msg = new StringBundler(8);
7793    
7794                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7795    
7796                    msg.append("groupId=");
7797                    msg.append(groupId);
7798    
7799                    msg.append(", name=");
7800                    msg.append(name);
7801    
7802                    msg.append(", description=");
7803                    msg.append(description);
7804    
7805                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7806    
7807                    throw new NoSuchStructureException(msg.toString());
7808            }
7809    
7810            /**
7811             * Returns the last d d m structure in the ordered set where groupId = &#63; and name = &#63; and description = &#63;.
7812             *
7813             * @param groupId the group ID
7814             * @param name the name
7815             * @param description the description
7816             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7817             * @return the last matching d d m structure, or <code>null</code> if a matching d d m structure could not be found
7818             * @throws SystemException if a system exception occurred
7819             */
7820            @Override
7821            public DDMStructure fetchByG_N_D_Last(long groupId, String name,
7822                    String description, OrderByComparator orderByComparator)
7823                    throws SystemException {
7824                    int count = countByG_N_D(groupId, name, description);
7825    
7826                    if (count == 0) {
7827                            return null;
7828                    }
7829    
7830                    List<DDMStructure> list = findByG_N_D(groupId, name, description,
7831                                    count - 1, count, orderByComparator);
7832    
7833                    if (!list.isEmpty()) {
7834                            return list.get(0);
7835                    }
7836    
7837                    return null;
7838            }
7839    
7840            /**
7841             * 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;.
7842             *
7843             * @param structureId the primary key of the current d d m structure
7844             * @param groupId the group ID
7845             * @param name the name
7846             * @param description the description
7847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7848             * @return the previous, current, and next d d m structure
7849             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
7850             * @throws SystemException if a system exception occurred
7851             */
7852            @Override
7853            public DDMStructure[] findByG_N_D_PrevAndNext(long structureId,
7854                    long groupId, String name, String description,
7855                    OrderByComparator orderByComparator)
7856                    throws NoSuchStructureException, SystemException {
7857                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
7858    
7859                    Session session = null;
7860    
7861                    try {
7862                            session = openSession();
7863    
7864                            DDMStructure[] array = new DDMStructureImpl[3];
7865    
7866                            array[0] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
7867                                            name, description, orderByComparator, true);
7868    
7869                            array[1] = ddmStructure;
7870    
7871                            array[2] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
7872                                            name, description, orderByComparator, false);
7873    
7874                            return array;
7875                    }
7876                    catch (Exception e) {
7877                            throw processException(e);
7878                    }
7879                    finally {
7880                            closeSession(session);
7881                    }
7882            }
7883    
7884            protected DDMStructure getByG_N_D_PrevAndNext(Session session,
7885                    DDMStructure ddmStructure, long groupId, String name,
7886                    String description, OrderByComparator orderByComparator,
7887                    boolean previous) {
7888                    StringBundler query = null;
7889    
7890                    if (orderByComparator != null) {
7891                            query = new StringBundler(6 +
7892                                            (orderByComparator.getOrderByFields().length * 6));
7893                    }
7894                    else {
7895                            query = new StringBundler(3);
7896                    }
7897    
7898                    query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
7899    
7900                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
7901    
7902                    boolean bindName = false;
7903    
7904                    if (name == null) {
7905                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
7906                    }
7907                    else if (name.equals(StringPool.BLANK)) {
7908                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
7909                    }
7910                    else {
7911                            bindName = true;
7912    
7913                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
7914                    }
7915    
7916                    boolean bindDescription = false;
7917    
7918                    if (description == null) {
7919                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
7920                    }
7921                    else if (description.equals(StringPool.BLANK)) {
7922                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
7923                    }
7924                    else {
7925                            bindDescription = true;
7926    
7927                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
7928                    }
7929    
7930                    if (orderByComparator != null) {
7931                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7932    
7933                            if (orderByConditionFields.length > 0) {
7934                                    query.append(WHERE_AND);
7935                            }
7936    
7937                            for (int i = 0; i < orderByConditionFields.length; i++) {
7938                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7939                                    query.append(orderByConditionFields[i]);
7940    
7941                                    if ((i + 1) < orderByConditionFields.length) {
7942                                            if (orderByComparator.isAscending() ^ previous) {
7943                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7944                                            }
7945                                            else {
7946                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7947                                            }
7948                                    }
7949                                    else {
7950                                            if (orderByComparator.isAscending() ^ previous) {
7951                                                    query.append(WHERE_GREATER_THAN);
7952                                            }
7953                                            else {
7954                                                    query.append(WHERE_LESSER_THAN);
7955                                            }
7956                                    }
7957                            }
7958    
7959                            query.append(ORDER_BY_CLAUSE);
7960    
7961                            String[] orderByFields = orderByComparator.getOrderByFields();
7962    
7963                            for (int i = 0; i < orderByFields.length; i++) {
7964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7965                                    query.append(orderByFields[i]);
7966    
7967                                    if ((i + 1) < orderByFields.length) {
7968                                            if (orderByComparator.isAscending() ^ previous) {
7969                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7970                                            }
7971                                            else {
7972                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7973                                            }
7974                                    }
7975                                    else {
7976                                            if (orderByComparator.isAscending() ^ previous) {
7977                                                    query.append(ORDER_BY_ASC);
7978                                            }
7979                                            else {
7980                                                    query.append(ORDER_BY_DESC);
7981                                            }
7982                                    }
7983                            }
7984                    }
7985                    else {
7986                            query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
7987                    }
7988    
7989                    String sql = query.toString();
7990    
7991                    Query q = session.createQuery(sql);
7992    
7993                    q.setFirstResult(0);
7994                    q.setMaxResults(2);
7995    
7996                    QueryPos qPos = QueryPos.getInstance(q);
7997    
7998                    qPos.add(groupId);
7999    
8000                    if (bindName) {
8001                            qPos.add(name);
8002                    }
8003    
8004                    if (bindDescription) {
8005                            qPos.add(description);
8006                    }
8007    
8008                    if (orderByComparator != null) {
8009                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
8010    
8011                            for (Object value : values) {
8012                                    qPos.add(value);
8013                            }
8014                    }
8015    
8016                    List<DDMStructure> list = q.list();
8017    
8018                    if (list.size() == 2) {
8019                            return list.get(1);
8020                    }
8021                    else {
8022                            return null;
8023                    }
8024            }
8025    
8026            /**
8027             * Returns all the d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
8028             *
8029             * @param groupId the group ID
8030             * @param name the name
8031             * @param description the description
8032             * @return the matching d d m structures that the user has permission to view
8033             * @throws SystemException if a system exception occurred
8034             */
8035            @Override
8036            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
8037                    String description) throws SystemException {
8038                    return filterFindByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
8039                            QueryUtil.ALL_POS, null);
8040            }
8041    
8042            /**
8043             * 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;.
8044             *
8045             * <p>
8046             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8047             * </p>
8048             *
8049             * @param groupId the group ID
8050             * @param name the name
8051             * @param description the description
8052             * @param start the lower bound of the range of d d m structures
8053             * @param end the upper bound of the range of d d m structures (not inclusive)
8054             * @return the range of matching d d m structures that the user has permission to view
8055             * @throws SystemException if a system exception occurred
8056             */
8057            @Override
8058            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
8059                    String description, int start, int end) throws SystemException {
8060                    return filterFindByG_N_D(groupId, name, description, start, end, null);
8061            }
8062    
8063            /**
8064             * 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;.
8065             *
8066             * <p>
8067             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8068             * </p>
8069             *
8070             * @param groupId the group ID
8071             * @param name the name
8072             * @param description the description
8073             * @param start the lower bound of the range of d d m structures
8074             * @param end the upper bound of the range of d d m structures (not inclusive)
8075             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8076             * @return the ordered range of matching d d m structures that the user has permission to view
8077             * @throws SystemException if a system exception occurred
8078             */
8079            @Override
8080            public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
8081                    String description, int start, int end,
8082                    OrderByComparator orderByComparator) throws SystemException {
8083                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8084                            return findByG_N_D(groupId, name, description, start, end,
8085                                    orderByComparator);
8086                    }
8087    
8088                    StringBundler query = null;
8089    
8090                    if (orderByComparator != null) {
8091                            query = new StringBundler(5 +
8092                                            (orderByComparator.getOrderByFields().length * 3));
8093                    }
8094                    else {
8095                            query = new StringBundler(5);
8096                    }
8097    
8098                    if (getDB().isSupportsInlineDistinct()) {
8099                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
8100                    }
8101                    else {
8102                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
8103                    }
8104    
8105                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
8106    
8107                    boolean bindName = false;
8108    
8109                    if (name == null) {
8110                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
8111                    }
8112                    else if (name.equals(StringPool.BLANK)) {
8113                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
8114                    }
8115                    else {
8116                            bindName = true;
8117    
8118                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
8119                    }
8120    
8121                    boolean bindDescription = false;
8122    
8123                    if (description == null) {
8124                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
8125                    }
8126                    else if (description.equals(StringPool.BLANK)) {
8127                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
8128                    }
8129                    else {
8130                            bindDescription = true;
8131    
8132                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
8133                    }
8134    
8135                    if (!getDB().isSupportsInlineDistinct()) {
8136                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
8137                    }
8138    
8139                    if (orderByComparator != null) {
8140                            if (getDB().isSupportsInlineDistinct()) {
8141                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8142                                            orderByComparator, true);
8143                            }
8144                            else {
8145                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8146                                            orderByComparator, true);
8147                            }
8148                    }
8149                    else {
8150                            if (getDB().isSupportsInlineDistinct()) {
8151                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
8152                            }
8153                            else {
8154                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
8155                            }
8156                    }
8157    
8158                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8159                                    DDMStructure.class.getName(),
8160                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8161    
8162                    Session session = null;
8163    
8164                    try {
8165                            session = openSession();
8166    
8167                            SQLQuery q = session.createSQLQuery(sql);
8168    
8169                            if (getDB().isSupportsInlineDistinct()) {
8170                                    q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
8171                            }
8172                            else {
8173                                    q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
8174                            }
8175    
8176                            QueryPos qPos = QueryPos.getInstance(q);
8177    
8178                            qPos.add(groupId);
8179    
8180                            if (bindName) {
8181                                    qPos.add(name);
8182                            }
8183    
8184                            if (bindDescription) {
8185                                    qPos.add(description);
8186                            }
8187    
8188                            return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
8189                                    end);
8190                    }
8191                    catch (Exception e) {
8192                            throw processException(e);
8193                    }
8194                    finally {
8195                            closeSession(session);
8196                    }
8197            }
8198    
8199            /**
8200             * 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;.
8201             *
8202             * @param structureId the primary key of the current d d m structure
8203             * @param groupId the group ID
8204             * @param name the name
8205             * @param description the description
8206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8207             * @return the previous, current, and next d d m structure
8208             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
8209             * @throws SystemException if a system exception occurred
8210             */
8211            @Override
8212            public DDMStructure[] filterFindByG_N_D_PrevAndNext(long structureId,
8213                    long groupId, String name, String description,
8214                    OrderByComparator orderByComparator)
8215                    throws NoSuchStructureException, SystemException {
8216                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8217                            return findByG_N_D_PrevAndNext(structureId, groupId, name,
8218                                    description, orderByComparator);
8219                    }
8220    
8221                    DDMStructure ddmStructure = findByPrimaryKey(structureId);
8222    
8223                    Session session = null;
8224    
8225                    try {
8226                            session = openSession();
8227    
8228                            DDMStructure[] array = new DDMStructureImpl[3];
8229    
8230                            array[0] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
8231                                            groupId, name, description, orderByComparator, true);
8232    
8233                            array[1] = ddmStructure;
8234    
8235                            array[2] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
8236                                            groupId, name, description, orderByComparator, false);
8237    
8238                            return array;
8239                    }
8240                    catch (Exception e) {
8241                            throw processException(e);
8242                    }
8243                    finally {
8244                            closeSession(session);
8245                    }
8246            }
8247    
8248            protected DDMStructure filterGetByG_N_D_PrevAndNext(Session session,
8249                    DDMStructure ddmStructure, long groupId, String name,
8250                    String description, OrderByComparator orderByComparator,
8251                    boolean previous) {
8252                    StringBundler query = null;
8253    
8254                    if (orderByComparator != null) {
8255                            query = new StringBundler(6 +
8256                                            (orderByComparator.getOrderByFields().length * 6));
8257                    }
8258                    else {
8259                            query = new StringBundler(3);
8260                    }
8261    
8262                    if (getDB().isSupportsInlineDistinct()) {
8263                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
8264                    }
8265                    else {
8266                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
8267                    }
8268    
8269                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
8270    
8271                    boolean bindName = false;
8272    
8273                    if (name == null) {
8274                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
8275                    }
8276                    else if (name.equals(StringPool.BLANK)) {
8277                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
8278                    }
8279                    else {
8280                            bindName = true;
8281    
8282                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
8283                    }
8284    
8285                    boolean bindDescription = false;
8286    
8287                    if (description == null) {
8288                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
8289                    }
8290                    else if (description.equals(StringPool.BLANK)) {
8291                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
8292                    }
8293                    else {
8294                            bindDescription = true;
8295    
8296                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
8297                    }
8298    
8299                    if (!getDB().isSupportsInlineDistinct()) {
8300                            query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
8301                    }
8302    
8303                    if (orderByComparator != null) {
8304                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8305    
8306                            if (orderByConditionFields.length > 0) {
8307                                    query.append(WHERE_AND);
8308                            }
8309    
8310                            for (int i = 0; i < orderByConditionFields.length; i++) {
8311                                    if (getDB().isSupportsInlineDistinct()) {
8312                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8313                                    }
8314                                    else {
8315                                            query.append(_ORDER_BY_ENTITY_TABLE);
8316                                    }
8317    
8318                                    query.append(orderByConditionFields[i]);
8319    
8320                                    if ((i + 1) < orderByConditionFields.length) {
8321                                            if (orderByComparator.isAscending() ^ previous) {
8322                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8323                                            }
8324                                            else {
8325                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8326                                            }
8327                                    }
8328                                    else {
8329                                            if (orderByComparator.isAscending() ^ previous) {
8330                                                    query.append(WHERE_GREATER_THAN);
8331                                            }
8332                                            else {
8333                                                    query.append(WHERE_LESSER_THAN);
8334                                            }
8335                                    }
8336                            }
8337    
8338                            query.append(ORDER_BY_CLAUSE);
8339    
8340                            String[] orderByFields = orderByComparator.getOrderByFields();
8341    
8342                            for (int i = 0; i < orderByFields.length; i++) {
8343                                    if (getDB().isSupportsInlineDistinct()) {
8344                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8345                                    }
8346                                    else {
8347                                            query.append(_ORDER_BY_ENTITY_TABLE);
8348                                    }
8349    
8350                                    query.append(orderByFields[i]);
8351    
8352                                    if ((i + 1) < orderByFields.length) {
8353                                            if (orderByComparator.isAscending() ^ previous) {
8354                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8355                                            }
8356                                            else {
8357                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8358                                            }
8359                                    }
8360                                    else {
8361                                            if (orderByComparator.isAscending() ^ previous) {
8362                                                    query.append(ORDER_BY_ASC);
8363                                            }
8364                                            else {
8365                                                    query.append(ORDER_BY_DESC);
8366                                            }
8367                                    }
8368                            }
8369                    }
8370                    else {
8371                            if (getDB().isSupportsInlineDistinct()) {
8372                                    query.append(DDMStructureModelImpl.ORDER_BY_JPQL);
8373                            }
8374                            else {
8375                                    query.append(DDMStructureModelImpl.ORDER_BY_SQL);
8376                            }
8377                    }
8378    
8379                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8380                                    DDMStructure.class.getName(),
8381                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8382    
8383                    SQLQuery q = session.createSQLQuery(sql);
8384    
8385                    q.setFirstResult(0);
8386                    q.setMaxResults(2);
8387    
8388                    if (getDB().isSupportsInlineDistinct()) {
8389                            q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
8390                    }
8391                    else {
8392                            q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
8393                    }
8394    
8395                    QueryPos qPos = QueryPos.getInstance(q);
8396    
8397                    qPos.add(groupId);
8398    
8399                    if (bindName) {
8400                            qPos.add(name);
8401                    }
8402    
8403                    if (bindDescription) {
8404                            qPos.add(description);
8405                    }
8406    
8407                    if (orderByComparator != null) {
8408                            Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
8409    
8410                            for (Object value : values) {
8411                                    qPos.add(value);
8412                            }
8413                    }
8414    
8415                    List<DDMStructure> list = q.list();
8416    
8417                    if (list.size() == 2) {
8418                            return list.get(1);
8419                    }
8420                    else {
8421                            return null;
8422                    }
8423            }
8424    
8425            /**
8426             * Removes all the d d m structures where groupId = &#63; and name = &#63; and description = &#63; from the database.
8427             *
8428             * @param groupId the group ID
8429             * @param name the name
8430             * @param description the description
8431             * @throws SystemException if a system exception occurred
8432             */
8433            @Override
8434            public void removeByG_N_D(long groupId, String name, String description)
8435                    throws SystemException {
8436                    for (DDMStructure ddmStructure : findByG_N_D(groupId, name,
8437                                    description, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8438                            remove(ddmStructure);
8439                    }
8440            }
8441    
8442            /**
8443             * Returns the number of d d m structures where groupId = &#63; and name = &#63; and description = &#63;.
8444             *
8445             * @param groupId the group ID
8446             * @param name the name
8447             * @param description the description
8448             * @return the number of matching d d m structures
8449             * @throws SystemException if a system exception occurred
8450             */
8451            @Override
8452            public int countByG_N_D(long groupId, String name, String description)
8453                    throws SystemException {
8454                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_D;
8455    
8456                    Object[] finderArgs = new Object[] { groupId, name, description };
8457    
8458                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8459                                    this);
8460    
8461                    if (count == null) {
8462                            StringBundler query = new StringBundler(4);
8463    
8464                            query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
8465    
8466                            query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
8467    
8468                            boolean bindName = false;
8469    
8470                            if (name == null) {
8471                                    query.append(_FINDER_COLUMN_G_N_D_NAME_1);
8472                            }
8473                            else if (name.equals(StringPool.BLANK)) {
8474                                    query.append(_FINDER_COLUMN_G_N_D_NAME_3);
8475                            }
8476                            else {
8477                                    bindName = true;
8478    
8479                                    query.append(_FINDER_COLUMN_G_N_D_NAME_2);
8480                            }
8481    
8482                            boolean bindDescription = false;
8483    
8484                            if (description == null) {
8485                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
8486                            }
8487                            else if (description.equals(StringPool.BLANK)) {
8488                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
8489                            }
8490                            else {
8491                                    bindDescription = true;
8492    
8493                                    query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
8494                            }
8495    
8496                            String sql = query.toString();
8497    
8498                            Session session = null;
8499    
8500                            try {
8501                                    session = openSession();
8502    
8503                                    Query q = session.createQuery(sql);
8504    
8505                                    QueryPos qPos = QueryPos.getInstance(q);
8506    
8507                                    qPos.add(groupId);
8508    
8509                                    if (bindName) {
8510                                            qPos.add(name);
8511                                    }
8512    
8513                                    if (bindDescription) {
8514                                            qPos.add(description);
8515                                    }
8516    
8517                                    count = (Long)q.uniqueResult();
8518    
8519                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8520                            }
8521                            catch (Exception e) {
8522                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8523    
8524                                    throw processException(e);
8525                            }
8526                            finally {
8527                                    closeSession(session);
8528                            }
8529                    }
8530    
8531                    return count.intValue();
8532            }
8533    
8534            /**
8535             * Returns the number of d d m structures that the user has permission to view where groupId = &#63; and name = &#63; and description = &#63;.
8536             *
8537             * @param groupId the group ID
8538             * @param name the name
8539             * @param description the description
8540             * @return the number of matching d d m structures that the user has permission to view
8541             * @throws SystemException if a system exception occurred
8542             */
8543            @Override
8544            public int filterCountByG_N_D(long groupId, String name, String description)
8545                    throws SystemException {
8546                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8547                            return countByG_N_D(groupId, name, description);
8548                    }
8549    
8550                    StringBundler query = new StringBundler(4);
8551    
8552                    query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
8553    
8554                    query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
8555    
8556                    boolean bindName = false;
8557    
8558                    if (name == null) {
8559                            query.append(_FINDER_COLUMN_G_N_D_NAME_1);
8560                    }
8561                    else if (name.equals(StringPool.BLANK)) {
8562                            query.append(_FINDER_COLUMN_G_N_D_NAME_3);
8563                    }
8564                    else {
8565                            bindName = true;
8566    
8567                            query.append(_FINDER_COLUMN_G_N_D_NAME_2);
8568                    }
8569    
8570                    boolean bindDescription = false;
8571    
8572                    if (description == null) {
8573                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
8574                    }
8575                    else if (description.equals(StringPool.BLANK)) {
8576                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
8577                    }
8578                    else {
8579                            bindDescription = true;
8580    
8581                            query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
8582                    }
8583    
8584                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8585                                    DDMStructure.class.getName(),
8586                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8587    
8588                    Session session = null;
8589    
8590                    try {
8591                            session = openSession();
8592    
8593                            SQLQuery q = session.createSQLQuery(sql);
8594    
8595                            q.addScalar(COUNT_COLUMN_NAME,
8596                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8597    
8598                            QueryPos qPos = QueryPos.getInstance(q);
8599    
8600                            qPos.add(groupId);
8601    
8602                            if (bindName) {
8603                                    qPos.add(name);
8604                            }
8605    
8606                            if (bindDescription) {
8607                                    qPos.add(description);
8608                            }
8609    
8610                            Long count = (Long)q.uniqueResult();
8611    
8612                            return count.intValue();
8613                    }
8614                    catch (Exception e) {
8615                            throw processException(e);
8616                    }
8617                    finally {
8618                            closeSession(session);
8619                    }
8620            }
8621    
8622            private static final String _FINDER_COLUMN_G_N_D_GROUPID_2 = "ddmStructure.groupId = ? AND ";
8623            private static final String _FINDER_COLUMN_G_N_D_NAME_1 = "ddmStructure.name IS NULL AND ";
8624            private static final String _FINDER_COLUMN_G_N_D_NAME_2 = "ddmStructure.name = ? AND ";
8625            private static final String _FINDER_COLUMN_G_N_D_NAME_3 = "(ddmStructure.name IS NULL OR ddmStructure.name = '') AND ";
8626            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_1 = "ddmStructure.description IS NULL";
8627            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_2 = "ddmStructure.description = ?";
8628            private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_3 = "(ddmStructure.description IS NULL OR ddmStructure.description = '')";
8629    
8630            public DDMStructurePersistenceImpl() {
8631                    setModelClass(DDMStructure.class);
8632            }
8633    
8634            /**
8635             * Caches the d d m structure in the entity cache if it is enabled.
8636             *
8637             * @param ddmStructure the d d m structure
8638             */
8639            @Override
8640            public void cacheResult(DDMStructure ddmStructure) {
8641                    EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
8642                            DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
8643    
8644                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
8645                            new Object[] { ddmStructure.getUuid(), ddmStructure.getGroupId() },
8646                            ddmStructure);
8647    
8648                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
8649                            new Object[] {
8650                                    ddmStructure.getGroupId(), ddmStructure.getClassNameId(),
8651                                    ddmStructure.getStructureKey()
8652                            }, ddmStructure);
8653    
8654                    ddmStructure.resetOriginalValues();
8655            }
8656    
8657            /**
8658             * Caches the d d m structures in the entity cache if it is enabled.
8659             *
8660             * @param ddmStructures the d d m structures
8661             */
8662            @Override
8663            public void cacheResult(List<DDMStructure> ddmStructures) {
8664                    for (DDMStructure ddmStructure : ddmStructures) {
8665                            if (EntityCacheUtil.getResult(
8666                                                    DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
8667                                                    DDMStructureImpl.class, ddmStructure.getPrimaryKey()) == null) {
8668                                    cacheResult(ddmStructure);
8669                            }
8670                            else {
8671                                    ddmStructure.resetOriginalValues();
8672                            }
8673                    }
8674            }
8675    
8676            /**
8677             * Clears the cache for all d d m structures.
8678             *
8679             * <p>
8680             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
8681             * </p>
8682             */
8683            @Override
8684            public void clearCache() {
8685                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
8686                            CacheRegistryUtil.clear(DDMStructureImpl.class.getName());
8687                    }
8688    
8689                    EntityCacheUtil.clearCache(DDMStructureImpl.class.getName());
8690    
8691                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8692                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8693                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8694            }
8695    
8696            /**
8697             * Clears the cache for the d d m structure.
8698             *
8699             * <p>
8700             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
8701             * </p>
8702             */
8703            @Override
8704            public void clearCache(DDMStructure ddmStructure) {
8705                    EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
8706                            DDMStructureImpl.class, ddmStructure.getPrimaryKey());
8707    
8708                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8709                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8710    
8711                    clearUniqueFindersCache(ddmStructure);
8712            }
8713    
8714            @Override
8715            public void clearCache(List<DDMStructure> ddmStructures) {
8716                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8717                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8718    
8719                    for (DDMStructure ddmStructure : ddmStructures) {
8720                            EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
8721                                    DDMStructureImpl.class, ddmStructure.getPrimaryKey());
8722    
8723                            clearUniqueFindersCache(ddmStructure);
8724                    }
8725            }
8726    
8727            protected void cacheUniqueFindersCache(DDMStructure ddmStructure) {
8728                    if (ddmStructure.isNew()) {
8729                            Object[] args = new Object[] {
8730                                            ddmStructure.getUuid(), ddmStructure.getGroupId()
8731                                    };
8732    
8733                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
8734                                    Long.valueOf(1));
8735                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
8736                                    ddmStructure);
8737    
8738                            args = new Object[] {
8739                                            ddmStructure.getGroupId(), ddmStructure.getClassNameId(),
8740                                            ddmStructure.getStructureKey()
8741                                    };
8742    
8743                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
8744                                    Long.valueOf(1));
8745                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
8746                                    ddmStructure);
8747                    }
8748                    else {
8749                            DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
8750    
8751                            if ((ddmStructureModelImpl.getColumnBitmask() &
8752                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
8753                                    Object[] args = new Object[] {
8754                                                    ddmStructure.getUuid(), ddmStructure.getGroupId()
8755                                            };
8756    
8757                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
8758                                            Long.valueOf(1));
8759                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
8760                                            ddmStructure);
8761                            }
8762    
8763                            if ((ddmStructureModelImpl.getColumnBitmask() &
8764                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
8765                                    Object[] args = new Object[] {
8766                                                    ddmStructure.getGroupId(), ddmStructure.getClassNameId(),
8767                                                    ddmStructure.getStructureKey()
8768                                            };
8769    
8770                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
8771                                            Long.valueOf(1));
8772                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
8773                                            ddmStructure);
8774                            }
8775                    }
8776            }
8777    
8778            protected void clearUniqueFindersCache(DDMStructure ddmStructure) {
8779                    DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
8780    
8781                    Object[] args = new Object[] {
8782                                    ddmStructure.getUuid(), ddmStructure.getGroupId()
8783                            };
8784    
8785                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
8786                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
8787    
8788                    if ((ddmStructureModelImpl.getColumnBitmask() &
8789                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
8790                            args = new Object[] {
8791                                            ddmStructureModelImpl.getOriginalUuid(),
8792                                            ddmStructureModelImpl.getOriginalGroupId()
8793                                    };
8794    
8795                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
8796                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
8797                    }
8798    
8799                    args = new Object[] {
8800                                    ddmStructure.getGroupId(), ddmStructure.getClassNameId(),
8801                                    ddmStructure.getStructureKey()
8802                            };
8803    
8804                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
8805                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
8806    
8807                    if ((ddmStructureModelImpl.getColumnBitmask() &
8808                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
8809                            args = new Object[] {
8810                                            ddmStructureModelImpl.getOriginalGroupId(),
8811                                            ddmStructureModelImpl.getOriginalClassNameId(),
8812                                            ddmStructureModelImpl.getOriginalStructureKey()
8813                                    };
8814    
8815                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
8816                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
8817                    }
8818            }
8819    
8820            /**
8821             * Creates a new d d m structure with the primary key. Does not add the d d m structure to the database.
8822             *
8823             * @param structureId the primary key for the new d d m structure
8824             * @return the new d d m structure
8825             */
8826            @Override
8827            public DDMStructure create(long structureId) {
8828                    DDMStructure ddmStructure = new DDMStructureImpl();
8829    
8830                    ddmStructure.setNew(true);
8831                    ddmStructure.setPrimaryKey(structureId);
8832    
8833                    String uuid = PortalUUIDUtil.generate();
8834    
8835                    ddmStructure.setUuid(uuid);
8836    
8837                    return ddmStructure;
8838            }
8839    
8840            /**
8841             * Removes the d d m structure with the primary key from the database. Also notifies the appropriate model listeners.
8842             *
8843             * @param structureId the primary key of the d d m structure
8844             * @return the d d m structure that was removed
8845             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
8846             * @throws SystemException if a system exception occurred
8847             */
8848            @Override
8849            public DDMStructure remove(long structureId)
8850                    throws NoSuchStructureException, SystemException {
8851                    return remove((Serializable)structureId);
8852            }
8853    
8854            /**
8855             * Removes the d d m structure with the primary key from the database. Also notifies the appropriate model listeners.
8856             *
8857             * @param primaryKey the primary key of the d d m structure
8858             * @return the d d m structure that was removed
8859             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
8860             * @throws SystemException if a system exception occurred
8861             */
8862            @Override
8863            public DDMStructure remove(Serializable primaryKey)
8864                    throws NoSuchStructureException, SystemException {
8865                    Session session = null;
8866    
8867                    try {
8868                            session = openSession();
8869    
8870                            DDMStructure ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
8871                                            primaryKey);
8872    
8873                            if (ddmStructure == null) {
8874                                    if (_log.isWarnEnabled()) {
8875                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8876                                    }
8877    
8878                                    throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8879                                            primaryKey);
8880                            }
8881    
8882                            return remove(ddmStructure);
8883                    }
8884                    catch (NoSuchStructureException nsee) {
8885                            throw nsee;
8886                    }
8887                    catch (Exception e) {
8888                            throw processException(e);
8889                    }
8890                    finally {
8891                            closeSession(session);
8892                    }
8893            }
8894    
8895            @Override
8896            protected DDMStructure removeImpl(DDMStructure ddmStructure)
8897                    throws SystemException {
8898                    ddmStructure = toUnwrappedModel(ddmStructure);
8899    
8900                    ddmStructureToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(ddmStructure.getPrimaryKey());
8901    
8902                    Session session = null;
8903    
8904                    try {
8905                            session = openSession();
8906    
8907                            if (!session.contains(ddmStructure)) {
8908                                    ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
8909                                                    ddmStructure.getPrimaryKeyObj());
8910                            }
8911    
8912                            if (ddmStructure != null) {
8913                                    session.delete(ddmStructure);
8914                            }
8915                    }
8916                    catch (Exception e) {
8917                            throw processException(e);
8918                    }
8919                    finally {
8920                            closeSession(session);
8921                    }
8922    
8923                    if (ddmStructure != null) {
8924                            clearCache(ddmStructure);
8925                    }
8926    
8927                    return ddmStructure;
8928            }
8929    
8930            @Override
8931            public DDMStructure updateImpl(
8932                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
8933                    throws SystemException {
8934                    ddmStructure = toUnwrappedModel(ddmStructure);
8935    
8936                    boolean isNew = ddmStructure.isNew();
8937    
8938                    DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
8939    
8940                    if (Validator.isNull(ddmStructure.getUuid())) {
8941                            String uuid = PortalUUIDUtil.generate();
8942    
8943                            ddmStructure.setUuid(uuid);
8944                    }
8945    
8946                    Session session = null;
8947    
8948                    try {
8949                            session = openSession();
8950    
8951                            if (ddmStructure.isNew()) {
8952                                    session.save(ddmStructure);
8953    
8954                                    ddmStructure.setNew(false);
8955                            }
8956                            else {
8957                                    session.merge(ddmStructure);
8958                            }
8959                    }
8960                    catch (Exception e) {
8961                            throw processException(e);
8962                    }
8963                    finally {
8964                            closeSession(session);
8965                    }
8966    
8967                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8968    
8969                    if (isNew || !DDMStructureModelImpl.COLUMN_BITMASK_ENABLED) {
8970                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8971                    }
8972    
8973                    else {
8974                            if ((ddmStructureModelImpl.getColumnBitmask() &
8975                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
8976                                    Object[] args = new Object[] {
8977                                                    ddmStructureModelImpl.getOriginalUuid()
8978                                            };
8979    
8980                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8981                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8982                                            args);
8983    
8984                                    args = new Object[] { ddmStructureModelImpl.getUuid() };
8985    
8986                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8987                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8988                                            args);
8989                            }
8990    
8991                            if ((ddmStructureModelImpl.getColumnBitmask() &
8992                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
8993                                    Object[] args = new Object[] {
8994                                                    ddmStructureModelImpl.getOriginalUuid(),
8995                                                    ddmStructureModelImpl.getOriginalCompanyId()
8996                                            };
8997    
8998                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8999                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
9000                                            args);
9001    
9002                                    args = new Object[] {
9003                                                    ddmStructureModelImpl.getUuid(),
9004                                                    ddmStructureModelImpl.getCompanyId()
9005                                            };
9006    
9007                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
9008                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
9009                                            args);
9010                            }
9011    
9012                            if ((ddmStructureModelImpl.getColumnBitmask() &
9013                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
9014                                    Object[] args = new Object[] {
9015                                                    ddmStructureModelImpl.getOriginalGroupId()
9016                                            };
9017    
9018                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
9019                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
9020                                            args);
9021    
9022                                    args = new Object[] { ddmStructureModelImpl.getGroupId() };
9023    
9024                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
9025                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
9026                                            args);
9027                            }
9028    
9029                            if ((ddmStructureModelImpl.getColumnBitmask() &
9030                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID.getColumnBitmask()) != 0) {
9031                                    Object[] args = new Object[] {
9032                                                    ddmStructureModelImpl.getOriginalParentStructureId()
9033                                            };
9034    
9035                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
9036                                            args);
9037                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID,
9038                                            args);
9039    
9040                                    args = new Object[] { ddmStructureModelImpl.getParentStructureId() };
9041    
9042                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
9043                                            args);
9044                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID,
9045                                            args);
9046                            }
9047    
9048                            if ((ddmStructureModelImpl.getColumnBitmask() &
9049                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
9050                                    Object[] args = new Object[] {
9051                                                    ddmStructureModelImpl.getOriginalClassNameId()
9052                                            };
9053    
9054                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
9055                                            args);
9056                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
9057                                            args);
9058    
9059                                    args = new Object[] { ddmStructureModelImpl.getClassNameId() };
9060    
9061                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
9062                                            args);
9063                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
9064                                            args);
9065                            }
9066    
9067                            if ((ddmStructureModelImpl.getColumnBitmask() &
9068                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREKEY.getColumnBitmask()) != 0) {
9069                                    Object[] args = new Object[] {
9070                                                    ddmStructureModelImpl.getOriginalStructureKey()
9071                                            };
9072    
9073                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREKEY,
9074                                            args);
9075                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREKEY,
9076                                            args);
9077    
9078                                    args = new Object[] { ddmStructureModelImpl.getStructureKey() };
9079    
9080                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREKEY,
9081                                            args);
9082                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREKEY,
9083                                            args);
9084                            }
9085    
9086                            if ((ddmStructureModelImpl.getColumnBitmask() &
9087                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
9088                                    Object[] args = new Object[] {
9089                                                    ddmStructureModelImpl.getOriginalGroupId(),
9090                                                    ddmStructureModelImpl.getOriginalParentStructureId()
9091                                            };
9092    
9093                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
9094                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
9095                                            args);
9096    
9097                                    args = new Object[] {
9098                                                    ddmStructureModelImpl.getGroupId(),
9099                                                    ddmStructureModelImpl.getParentStructureId()
9100                                            };
9101    
9102                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
9103                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
9104                                            args);
9105                            }
9106    
9107                            if ((ddmStructureModelImpl.getColumnBitmask() &
9108                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
9109                                    Object[] args = new Object[] {
9110                                                    ddmStructureModelImpl.getOriginalGroupId(),
9111                                                    ddmStructureModelImpl.getOriginalClassNameId()
9112                                            };
9113    
9114                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
9115                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
9116                                            args);
9117    
9118                                    args = new Object[] {
9119                                                    ddmStructureModelImpl.getGroupId(),
9120                                                    ddmStructureModelImpl.getClassNameId()
9121                                            };
9122    
9123                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
9124                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
9125                                            args);
9126                            }
9127    
9128                            if ((ddmStructureModelImpl.getColumnBitmask() &
9129                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
9130                                    Object[] args = new Object[] {
9131                                                    ddmStructureModelImpl.getOriginalCompanyId(),
9132                                                    ddmStructureModelImpl.getOriginalClassNameId()
9133                                            };
9134    
9135                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
9136                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
9137                                            args);
9138    
9139                                    args = new Object[] {
9140                                                    ddmStructureModelImpl.getCompanyId(),
9141                                                    ddmStructureModelImpl.getClassNameId()
9142                                            };
9143    
9144                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
9145                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
9146                                            args);
9147                            }
9148    
9149                            if ((ddmStructureModelImpl.getColumnBitmask() &
9150                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D.getColumnBitmask()) != 0) {
9151                                    Object[] args = new Object[] {
9152                                                    ddmStructureModelImpl.getOriginalGroupId(),
9153                                                    ddmStructureModelImpl.getOriginalName(),
9154                                                    ddmStructureModelImpl.getOriginalDescription()
9155                                            };
9156    
9157                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
9158                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
9159                                            args);
9160    
9161                                    args = new Object[] {
9162                                                    ddmStructureModelImpl.getGroupId(),
9163                                                    ddmStructureModelImpl.getName(),
9164                                                    ddmStructureModelImpl.getDescription()
9165                                            };
9166    
9167                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
9168                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
9169                                            args);
9170                            }
9171                    }
9172    
9173                    EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
9174                            DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
9175    
9176                    clearUniqueFindersCache(ddmStructure);
9177                    cacheUniqueFindersCache(ddmStructure);
9178    
9179                    return ddmStructure;
9180            }
9181    
9182            protected DDMStructure toUnwrappedModel(DDMStructure ddmStructure) {
9183                    if (ddmStructure instanceof DDMStructureImpl) {
9184                            return ddmStructure;
9185                    }
9186    
9187                    DDMStructureImpl ddmStructureImpl = new DDMStructureImpl();
9188    
9189                    ddmStructureImpl.setNew(ddmStructure.isNew());
9190                    ddmStructureImpl.setPrimaryKey(ddmStructure.getPrimaryKey());
9191    
9192                    ddmStructureImpl.setUuid(ddmStructure.getUuid());
9193                    ddmStructureImpl.setStructureId(ddmStructure.getStructureId());
9194                    ddmStructureImpl.setGroupId(ddmStructure.getGroupId());
9195                    ddmStructureImpl.setCompanyId(ddmStructure.getCompanyId());
9196                    ddmStructureImpl.setUserId(ddmStructure.getUserId());
9197                    ddmStructureImpl.setUserName(ddmStructure.getUserName());
9198                    ddmStructureImpl.setCreateDate(ddmStructure.getCreateDate());
9199                    ddmStructureImpl.setModifiedDate(ddmStructure.getModifiedDate());
9200                    ddmStructureImpl.setParentStructureId(ddmStructure.getParentStructureId());
9201                    ddmStructureImpl.setClassNameId(ddmStructure.getClassNameId());
9202                    ddmStructureImpl.setStructureKey(ddmStructure.getStructureKey());
9203                    ddmStructureImpl.setName(ddmStructure.getName());
9204                    ddmStructureImpl.setDescription(ddmStructure.getDescription());
9205                    ddmStructureImpl.setXsd(ddmStructure.getXsd());
9206                    ddmStructureImpl.setStorageType(ddmStructure.getStorageType());
9207                    ddmStructureImpl.setType(ddmStructure.getType());
9208    
9209                    return ddmStructureImpl;
9210            }
9211    
9212            /**
9213             * Returns the d d m structure with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
9214             *
9215             * @param primaryKey the primary key of the d d m structure
9216             * @return the d d m structure
9217             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
9218             * @throws SystemException if a system exception occurred
9219             */
9220            @Override
9221            public DDMStructure findByPrimaryKey(Serializable primaryKey)
9222                    throws NoSuchStructureException, SystemException {
9223                    DDMStructure ddmStructure = fetchByPrimaryKey(primaryKey);
9224    
9225                    if (ddmStructure == null) {
9226                            if (_log.isWarnEnabled()) {
9227                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
9228                            }
9229    
9230                            throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
9231                                    primaryKey);
9232                    }
9233    
9234                    return ddmStructure;
9235            }
9236    
9237            /**
9238             * 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.
9239             *
9240             * @param structureId the primary key of the d d m structure
9241             * @return the d d m structure
9242             * @throws com.liferay.portlet.dynamicdatamapping.NoSuchStructureException if a d d m structure with the primary key could not be found
9243             * @throws SystemException if a system exception occurred
9244             */
9245            @Override
9246            public DDMStructure findByPrimaryKey(long structureId)
9247                    throws NoSuchStructureException, SystemException {
9248                    return findByPrimaryKey((Serializable)structureId);
9249            }
9250    
9251            /**
9252             * Returns the d d m structure with the primary key or returns <code>null</code> if it could not be found.
9253             *
9254             * @param primaryKey the primary key of the d d m structure
9255             * @return the d d m structure, or <code>null</code> if a d d m structure with the primary key could not be found
9256             * @throws SystemException if a system exception occurred
9257             */
9258            @Override
9259            public DDMStructure fetchByPrimaryKey(Serializable primaryKey)
9260                    throws SystemException {
9261                    DDMStructure ddmStructure = (DDMStructure)EntityCacheUtil.getResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
9262                                    DDMStructureImpl.class, primaryKey);
9263    
9264                    if (ddmStructure == _nullDDMStructure) {
9265                            return null;
9266                    }
9267    
9268                    if (ddmStructure == null) {
9269                            Session session = null;
9270    
9271                            try {
9272                                    session = openSession();
9273    
9274                                    ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
9275                                                    primaryKey);
9276    
9277                                    if (ddmStructure != null) {
9278                                            cacheResult(ddmStructure);
9279                                    }
9280                                    else {
9281                                            EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
9282                                                    DDMStructureImpl.class, primaryKey, _nullDDMStructure);
9283                                    }
9284                            }
9285                            catch (Exception e) {
9286                                    EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
9287                                            DDMStructureImpl.class, primaryKey);
9288    
9289                                    throw processException(e);
9290                            }
9291                            finally {
9292                                    closeSession(session);
9293                            }
9294                    }
9295    
9296                    return ddmStructure;
9297            }
9298    
9299            /**
9300             * Returns the d d m structure with the primary key or returns <code>null</code> if it could not be found.
9301             *
9302             * @param structureId the primary key of the d d m structure
9303             * @return the d d m structure, or <code>null</code> if a d d m structure with the primary key could not be found
9304             * @throws SystemException if a system exception occurred
9305             */
9306            @Override
9307            public DDMStructure fetchByPrimaryKey(long structureId)
9308                    throws SystemException {
9309                    return fetchByPrimaryKey((Serializable)structureId);
9310            }
9311    
9312            /**
9313             * Returns all the d d m structures.
9314             *
9315             * @return the d d m structures
9316             * @throws SystemException if a system exception occurred
9317             */
9318            @Override
9319            public List<DDMStructure> findAll() throws SystemException {
9320                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9321            }
9322    
9323            /**
9324             * Returns a range of all the d d m structures.
9325             *
9326             * <p>
9327             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9328             * </p>
9329             *
9330             * @param start the lower bound of the range of d d m structures
9331             * @param end the upper bound of the range of d d m structures (not inclusive)
9332             * @return the range of d d m structures
9333             * @throws SystemException if a system exception occurred
9334             */
9335            @Override
9336            public List<DDMStructure> findAll(int start, int end)
9337                    throws SystemException {
9338                    return findAll(start, end, null);
9339            }
9340    
9341            /**
9342             * Returns an ordered range of all the d d m structures.
9343             *
9344             * <p>
9345             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9346             * </p>
9347             *
9348             * @param start the lower bound of the range of d d m structures
9349             * @param end the upper bound of the range of d d m structures (not inclusive)
9350             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9351             * @return the ordered range of d d m structures
9352             * @throws SystemException if a system exception occurred
9353             */
9354            @Override
9355            public List<DDMStructure> findAll(int start, int end,
9356                    OrderByComparator orderByComparator) throws SystemException {
9357                    boolean pagination = true;
9358                    FinderPath finderPath = null;
9359                    Object[] finderArgs = null;
9360    
9361                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9362                                    (orderByComparator == null)) {
9363                            pagination = false;
9364                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
9365                            finderArgs = FINDER_ARGS_EMPTY;
9366                    }
9367                    else {
9368                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
9369                            finderArgs = new Object[] { start, end, orderByComparator };
9370                    }
9371    
9372                    List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
9373                                    finderArgs, this);
9374    
9375                    if (list == null) {
9376                            StringBundler query = null;
9377                            String sql = null;
9378    
9379                            if (orderByComparator != null) {
9380                                    query = new StringBundler(2 +
9381                                                    (orderByComparator.getOrderByFields().length * 3));
9382    
9383                                    query.append(_SQL_SELECT_DDMSTRUCTURE);
9384    
9385                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9386                                            orderByComparator);
9387    
9388                                    sql = query.toString();
9389                            }
9390                            else {
9391                                    sql = _SQL_SELECT_DDMSTRUCTURE;
9392    
9393                                    if (pagination) {
9394                                            sql = sql.concat(DDMStructureModelImpl.ORDER_BY_JPQL);
9395                                    }
9396                            }
9397    
9398                            Session session = null;
9399    
9400                            try {
9401                                    session = openSession();
9402    
9403                                    Query q = session.createQuery(sql);
9404    
9405                                    if (!pagination) {
9406                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
9407                                                            start, end, false);
9408    
9409                                            Collections.sort(list);
9410    
9411                                            list = new UnmodifiableList<DDMStructure>(list);
9412                                    }
9413                                    else {
9414                                            list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
9415                                                            start, end);
9416                                    }
9417    
9418                                    cacheResult(list);
9419    
9420                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9421                            }
9422                            catch (Exception e) {
9423                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9424    
9425                                    throw processException(e);
9426                            }
9427                            finally {
9428                                    closeSession(session);
9429                            }
9430                    }
9431    
9432                    return list;
9433            }
9434    
9435            /**
9436             * Removes all the d d m structures from the database.
9437             *
9438             * @throws SystemException if a system exception occurred
9439             */
9440            @Override
9441            public void removeAll() throws SystemException {
9442                    for (DDMStructure ddmStructure : findAll()) {
9443                            remove(ddmStructure);
9444                    }
9445            }
9446    
9447            /**
9448             * Returns the number of d d m structures.
9449             *
9450             * @return the number of d d m structures
9451             * @throws SystemException if a system exception occurred
9452             */
9453            @Override
9454            public int countAll() throws SystemException {
9455                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9456                                    FINDER_ARGS_EMPTY, this);
9457    
9458                    if (count == null) {
9459                            Session session = null;
9460    
9461                            try {
9462                                    session = openSession();
9463    
9464                                    Query q = session.createQuery(_SQL_COUNT_DDMSTRUCTURE);
9465    
9466                                    count = (Long)q.uniqueResult();
9467    
9468                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
9469                                            FINDER_ARGS_EMPTY, count);
9470                            }
9471                            catch (Exception e) {
9472                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
9473                                            FINDER_ARGS_EMPTY);
9474    
9475                                    throw processException(e);
9476                            }
9477                            finally {
9478                                    closeSession(session);
9479                            }
9480                    }
9481    
9482                    return count.intValue();
9483            }
9484    
9485            /**
9486             * Returns all the document library file entry types associated with the d d m structure.
9487             *
9488             * @param pk the primary key of the d d m structure
9489             * @return the document library file entry types associated with the d d m structure
9490             * @throws SystemException if a system exception occurred
9491             */
9492            @Override
9493            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
9494                    long pk) throws SystemException {
9495                    return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
9496            }
9497    
9498            /**
9499             * Returns a range of all the document library file entry types associated with the d d m structure.
9500             *
9501             * <p>
9502             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9503             * </p>
9504             *
9505             * @param pk the primary key of the d d m structure
9506             * @param start the lower bound of the range of d d m structures
9507             * @param end the upper bound of the range of d d m structures (not inclusive)
9508             * @return the range of document library file entry types associated with the d d m structure
9509             * @throws SystemException if a system exception occurred
9510             */
9511            @Override
9512            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
9513                    long pk, int start, int end) throws SystemException {
9514                    return getDLFileEntryTypes(pk, start, end, null);
9515            }
9516    
9517            /**
9518             * Returns an ordered range of all the document library file entry types associated with the d d m structure.
9519             *
9520             * <p>
9521             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9522             * </p>
9523             *
9524             * @param pk the primary key of the d d m structure
9525             * @param start the lower bound of the range of d d m structures
9526             * @param end the upper bound of the range of d d m structures (not inclusive)
9527             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9528             * @return the ordered range of document library file entry types associated with the d d m structure
9529             * @throws SystemException if a system exception occurred
9530             */
9531            @Override
9532            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
9533                    long pk, int start, int end, OrderByComparator orderByComparator)
9534                    throws SystemException {
9535                    return ddmStructureToDLFileEntryTypeTableMapper.getRightBaseModels(pk,
9536                            start, end, orderByComparator);
9537            }
9538    
9539            /**
9540             * Returns the number of document library file entry types associated with the d d m structure.
9541             *
9542             * @param pk the primary key of the d d m structure
9543             * @return the number of document library file entry types associated with the d d m structure
9544             * @throws SystemException if a system exception occurred
9545             */
9546            @Override
9547            public int getDLFileEntryTypesSize(long pk) throws SystemException {
9548                    long[] pks = ddmStructureToDLFileEntryTypeTableMapper.getRightPrimaryKeys(pk);
9549    
9550                    return pks.length;
9551            }
9552    
9553            /**
9554             * Returns <code>true</code> if the document library file entry type is associated with the d d m structure.
9555             *
9556             * @param pk the primary key of the d d m structure
9557             * @param dlFileEntryTypePK the primary key of the document library file entry type
9558             * @return <code>true</code> if the document library file entry type is associated with the d d m structure; <code>false</code> otherwise
9559             * @throws SystemException if a system exception occurred
9560             */
9561            @Override
9562            public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK)
9563                    throws SystemException {
9564                    return ddmStructureToDLFileEntryTypeTableMapper.containsTableMapping(pk,
9565                            dlFileEntryTypePK);
9566            }
9567    
9568            /**
9569             * Returns <code>true</code> if the d d m structure has any document library file entry types associated with it.
9570             *
9571             * @param pk the primary key of the d d m structure to check for associations with document library file entry types
9572             * @return <code>true</code> if the d d m structure has any document library file entry types associated with it; <code>false</code> otherwise
9573             * @throws SystemException if a system exception occurred
9574             */
9575            @Override
9576            public boolean containsDLFileEntryTypes(long pk) throws SystemException {
9577                    if (getDLFileEntryTypesSize(pk) > 0) {
9578                            return true;
9579                    }
9580                    else {
9581                            return false;
9582                    }
9583            }
9584    
9585            /**
9586             * Adds an association between the d d m structure and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9587             *
9588             * @param pk the primary key of the d d m structure
9589             * @param dlFileEntryTypePK the primary key of the document library file entry type
9590             * @throws SystemException if a system exception occurred
9591             */
9592            @Override
9593            public void addDLFileEntryType(long pk, long dlFileEntryTypePK)
9594                    throws SystemException {
9595                    ddmStructureToDLFileEntryTypeTableMapper.addTableMapping(pk,
9596                            dlFileEntryTypePK);
9597            }
9598    
9599            /**
9600             * Adds an association between the d d m structure and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9601             *
9602             * @param pk the primary key of the d d m structure
9603             * @param dlFileEntryType the document library file entry type
9604             * @throws SystemException if a system exception occurred
9605             */
9606            @Override
9607            public void addDLFileEntryType(long pk,
9608                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
9609                    throws SystemException {
9610                    ddmStructureToDLFileEntryTypeTableMapper.addTableMapping(pk,
9611                            dlFileEntryType.getPrimaryKey());
9612            }
9613    
9614            /**
9615             * Adds an association between the d d m structure and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9616             *
9617             * @param pk the primary key of the d d m structure
9618             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
9619             * @throws SystemException if a system exception occurred
9620             */
9621            @Override
9622            public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
9623                    throws SystemException {
9624                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
9625                            ddmStructureToDLFileEntryTypeTableMapper.addTableMapping(pk,
9626                                    dlFileEntryTypePK);
9627                    }
9628            }
9629    
9630            /**
9631             * Adds an association between the d d m structure and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9632             *
9633             * @param pk the primary key of the d d m structure
9634             * @param dlFileEntryTypes the document library file entry types
9635             * @throws SystemException if a system exception occurred
9636             */
9637            @Override
9638            public void addDLFileEntryTypes(long pk,
9639                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
9640                    throws SystemException {
9641                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
9642                            ddmStructureToDLFileEntryTypeTableMapper.addTableMapping(pk,
9643                                    dlFileEntryType.getPrimaryKey());
9644                    }
9645            }
9646    
9647            /**
9648             * Clears all associations between the d d m structure and its document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9649             *
9650             * @param pk the primary key of the d d m structure to clear the associated document library file entry types from
9651             * @throws SystemException if a system exception occurred
9652             */
9653            @Override
9654            public void clearDLFileEntryTypes(long pk) throws SystemException {
9655                    ddmStructureToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
9656            }
9657    
9658            /**
9659             * Removes the association between the d d m structure and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9660             *
9661             * @param pk the primary key of the d d m structure
9662             * @param dlFileEntryTypePK the primary key of the document library file entry type
9663             * @throws SystemException if a system exception occurred
9664             */
9665            @Override
9666            public void removeDLFileEntryType(long pk, long dlFileEntryTypePK)
9667                    throws SystemException {
9668                    ddmStructureToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
9669                            dlFileEntryTypePK);
9670            }
9671    
9672            /**
9673             * Removes the association between the d d m structure and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9674             *
9675             * @param pk the primary key of the d d m structure
9676             * @param dlFileEntryType the document library file entry type
9677             * @throws SystemException if a system exception occurred
9678             */
9679            @Override
9680            public void removeDLFileEntryType(long pk,
9681                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
9682                    throws SystemException {
9683                    ddmStructureToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
9684                            dlFileEntryType.getPrimaryKey());
9685            }
9686    
9687            /**
9688             * Removes the association between the d d m structure and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9689             *
9690             * @param pk the primary key of the d d m structure
9691             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
9692             * @throws SystemException if a system exception occurred
9693             */
9694            @Override
9695            public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
9696                    throws SystemException {
9697                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
9698                            ddmStructureToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
9699                                    dlFileEntryTypePK);
9700                    }
9701            }
9702    
9703            /**
9704             * Removes the association between the d d m structure and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9705             *
9706             * @param pk the primary key of the d d m structure
9707             * @param dlFileEntryTypes the document library file entry types
9708             * @throws SystemException if a system exception occurred
9709             */
9710            @Override
9711            public void removeDLFileEntryTypes(long pk,
9712                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
9713                    throws SystemException {
9714                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
9715                            ddmStructureToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
9716                                    dlFileEntryType.getPrimaryKey());
9717                    }
9718            }
9719    
9720            /**
9721             * Sets the document library file entry types associated with the d d m structure, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9722             *
9723             * @param pk the primary key of the d d m structure
9724             * @param dlFileEntryTypePKs the primary keys of the document library file entry types to be associated with the d d m structure
9725             * @throws SystemException if a system exception occurred
9726             */
9727            @Override
9728            public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
9729                    throws SystemException {
9730                    ddmStructureToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
9731    
9732                    for (Long dlFileEntryTypePK : dlFileEntryTypePKs) {
9733                            ddmStructureToDLFileEntryTypeTableMapper.addTableMapping(pk,
9734                                    dlFileEntryTypePK);
9735                    }
9736            }
9737    
9738            /**
9739             * Sets the document library file entry types associated with the d d m structure, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9740             *
9741             * @param pk the primary key of the d d m structure
9742             * @param dlFileEntryTypes the document library file entry types to be associated with the d d m structure
9743             * @throws SystemException if a system exception occurred
9744             */
9745            @Override
9746            public void setDLFileEntryTypes(long pk,
9747                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
9748                    throws SystemException {
9749                    try {
9750                            long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
9751    
9752                            for (int i = 0; i < dlFileEntryTypes.size(); i++) {
9753                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
9754                                            dlFileEntryTypes.get(i);
9755    
9756                                    dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
9757                            }
9758    
9759                            setDLFileEntryTypes(pk, dlFileEntryTypePKs);
9760                    }
9761                    catch (Exception e) {
9762                            throw processException(e);
9763                    }
9764                    finally {
9765                            FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
9766                    }
9767            }
9768    
9769            @Override
9770            protected Set<String> getBadColumnNames() {
9771                    return _badColumnNames;
9772            }
9773    
9774            /**
9775             * Initializes the d d m structure persistence.
9776             */
9777            public void afterPropertiesSet() {
9778                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9779                                            com.liferay.portal.util.PropsUtil.get(
9780                                                    "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStructure")));
9781    
9782                    if (listenerClassNames.length > 0) {
9783                            try {
9784                                    List<ModelListener<DDMStructure>> listenersList = new ArrayList<ModelListener<DDMStructure>>();
9785    
9786                                    for (String listenerClassName : listenerClassNames) {
9787                                            listenersList.add((ModelListener<DDMStructure>)InstanceFactory.newInstance(
9788                                                            getClassLoader(), listenerClassName));
9789                                    }
9790    
9791                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9792                            }
9793                            catch (Exception e) {
9794                                    _log.error(e);
9795                            }
9796                    }
9797    
9798                    ddmStructureToDLFileEntryTypeTableMapper = TableMapperFactory.getTableMapper("DLFileEntryTypes_DDMStructures",
9799                                    "structureId", "fileEntryTypeId", this,
9800                                    dlFileEntryTypePersistence);
9801            }
9802    
9803            public void destroy() {
9804                    EntityCacheUtil.removeCache(DDMStructureImpl.class.getName());
9805                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9806                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9807                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9808            }
9809    
9810            @BeanReference(type = DLFileEntryTypePersistence.class)
9811            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
9812            protected TableMapper<DDMStructure, com.liferay.portlet.documentlibrary.model.DLFileEntryType> ddmStructureToDLFileEntryTypeTableMapper;
9813            private static final String _SQL_SELECT_DDMSTRUCTURE = "SELECT ddmStructure FROM DDMStructure ddmStructure";
9814            private static final String _SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT ddmStructure FROM DDMStructure ddmStructure WHERE ";
9815            private static final String _SQL_COUNT_DDMSTRUCTURE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure";
9816            private static final String _SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure WHERE ";
9817            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ddmStructure.structureId";
9818            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT DISTINCT {ddmStructure.*} FROM DDMStructure ddmStructure WHERE ";
9819            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1 =
9820                    "SELECT {DDMStructure.*} FROM (SELECT DISTINCT ddmStructure.structureId FROM DDMStructure ddmStructure WHERE ";
9821            private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2 =
9822                    ") TEMP_TABLE INNER JOIN DDMStructure ON TEMP_TABLE.structureId = DDMStructure.structureId";
9823            private static final String _FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(DISTINCT ddmStructure.structureId) AS COUNT_VALUE FROM DDMStructure ddmStructure WHERE ";
9824            private static final String _FILTER_ENTITY_ALIAS = "ddmStructure";
9825            private static final String _FILTER_ENTITY_TABLE = "DDMStructure";
9826            private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStructure.";
9827            private static final String _ORDER_BY_ENTITY_TABLE = "DDMStructure.";
9828            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStructure exists with the primary key ";
9829            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStructure exists with the key {";
9830            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
9831            private static Log _log = LogFactoryUtil.getLog(DDMStructurePersistenceImpl.class);
9832            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
9833                                    "uuid", "type"
9834                            });
9835            private static DDMStructure _nullDDMStructure = new DDMStructureImpl() {
9836                            @Override
9837                            public Object clone() {
9838                                    return this;
9839                            }
9840    
9841                            @Override
9842                            public CacheModel<DDMStructure> toCacheModel() {
9843                                    return _nullDDMStructureCacheModel;
9844                            }
9845                    };
9846    
9847            private static CacheModel<DDMStructure> _nullDDMStructureCacheModel = new CacheModel<DDMStructure>() {
9848                            @Override
9849                            public DDMStructure toEntityModel() {
9850                                    return _nullDDMStructure;
9851                            }
9852                    };
9853    }