001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
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.Session;
026    import com.liferay.portal.kernel.log.Log;
027    import com.liferay.portal.kernel.log.LogFactoryUtil;
028    import com.liferay.portal.kernel.util.OrderByComparator;
029    import com.liferay.portal.kernel.util.SetUtil;
030    import com.liferay.portal.kernel.util.StringBundler;
031    import com.liferay.portal.kernel.util.StringPool;
032    import com.liferay.portal.kernel.util.Validator;
033    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
034    import com.liferay.portal.model.CacheModel;
035    import com.liferay.portal.service.ServiceContext;
036    import com.liferay.portal.service.ServiceContextThreadLocal;
037    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
038    
039    import com.liferay.portlet.dynamicdatamapping.NoSuchContentException;
040    import com.liferay.portlet.dynamicdatamapping.model.DDMContent;
041    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMContentImpl;
042    import com.liferay.portlet.dynamicdatamapping.model.impl.DDMContentModelImpl;
043    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMContentPersistence;
044    
045    import java.io.Serializable;
046    
047    import java.util.Collections;
048    import java.util.Date;
049    import java.util.HashMap;
050    import java.util.HashSet;
051    import java.util.Iterator;
052    import java.util.List;
053    import java.util.Map;
054    import java.util.Set;
055    
056    /**
057     * The persistence implementation for the d d m content service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see DDMContentPersistence
065     * @see com.liferay.portlet.dynamicdatamapping.service.persistence.DDMContentUtil
066     * @generated
067     */
068    @ProviderType
069    public class DDMContentPersistenceImpl extends BasePersistenceImpl<DDMContent>
070            implements DDMContentPersistence {
071            /*
072             * NOTE FOR DEVELOPERS:
073             *
074             * Never modify or reference this class directly. Always use {@link DDMContentUtil} to access the d d m content persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
075             */
076            public static final String FINDER_CLASS_NAME_ENTITY = DDMContentImpl.class.getName();
077            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List1";
079            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List2";
081            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
082                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
083                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
085                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
088                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
091                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
092                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093                            new String[] {
094                                    String.class.getName(),
095                                    
096                            Integer.class.getName(), Integer.class.getName(),
097                                    OrderByComparator.class.getName()
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
100                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102                            new String[] { String.class.getName() },
103                            DDMContentModelImpl.UUID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
105                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107                            new String[] { String.class.getName() });
108    
109            /**
110             * Returns all the d d m contents where uuid = &#63;.
111             *
112             * @param uuid the uuid
113             * @return the matching d d m contents
114             */
115            @Override
116            public List<DDMContent> findByUuid(String uuid) {
117                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
118            }
119    
120            /**
121             * Returns a range of all the d d m contents where uuid = &#63;.
122             *
123             * <p>
124             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
125             * </p>
126             *
127             * @param uuid the uuid
128             * @param start the lower bound of the range of d d m contents
129             * @param end the upper bound of the range of d d m contents (not inclusive)
130             * @return the range of matching d d m contents
131             */
132            @Override
133            public List<DDMContent> findByUuid(String uuid, int start, int end) {
134                    return findByUuid(uuid, start, end, null);
135            }
136    
137            /**
138             * Returns an ordered range of all the d d m contents where uuid = &#63;.
139             *
140             * <p>
141             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
142             * </p>
143             *
144             * @param uuid the uuid
145             * @param start the lower bound of the range of d d m contents
146             * @param end the upper bound of the range of d d m contents (not inclusive)
147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
148             * @return the ordered range of matching d d m contents
149             */
150            @Override
151            public List<DDMContent> findByUuid(String uuid, int start, int end,
152                    OrderByComparator<DDMContent> orderByComparator) {
153                    boolean pagination = true;
154                    FinderPath finderPath = null;
155                    Object[] finderArgs = null;
156    
157                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
158                                    (orderByComparator == null)) {
159                            pagination = false;
160                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
161                            finderArgs = new Object[] { uuid };
162                    }
163                    else {
164                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
165                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
166                    }
167    
168                    List<DDMContent> list = (List<DDMContent>)FinderCacheUtil.getResult(finderPath,
169                                    finderArgs, this);
170    
171                    if ((list != null) && !list.isEmpty()) {
172                            for (DDMContent ddmContent : list) {
173                                    if (!Validator.equals(uuid, ddmContent.getUuid())) {
174                                            list = null;
175    
176                                            break;
177                                    }
178                            }
179                    }
180    
181                    if (list == null) {
182                            StringBundler query = null;
183    
184                            if (orderByComparator != null) {
185                                    query = new StringBundler(3 +
186                                                    (orderByComparator.getOrderByFields().length * 3));
187                            }
188                            else {
189                                    query = new StringBundler(3);
190                            }
191    
192                            query.append(_SQL_SELECT_DDMCONTENT_WHERE);
193    
194                            boolean bindUuid = false;
195    
196                            if (uuid == null) {
197                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
198                            }
199                            else if (uuid.equals(StringPool.BLANK)) {
200                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
201                            }
202                            else {
203                                    bindUuid = true;
204    
205                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
206                            }
207    
208                            if (orderByComparator != null) {
209                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
210                                            orderByComparator);
211                            }
212                            else
213                             if (pagination) {
214                                    query.append(DDMContentModelImpl.ORDER_BY_JPQL);
215                            }
216    
217                            String sql = query.toString();
218    
219                            Session session = null;
220    
221                            try {
222                                    session = openSession();
223    
224                                    Query q = session.createQuery(sql);
225    
226                                    QueryPos qPos = QueryPos.getInstance(q);
227    
228                                    if (bindUuid) {
229                                            qPos.add(uuid);
230                                    }
231    
232                                    if (!pagination) {
233                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
234                                                            start, end, false);
235    
236                                            Collections.sort(list);
237    
238                                            list = Collections.unmodifiableList(list);
239                                    }
240                                    else {
241                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
242                                                            start, end);
243                                    }
244    
245                                    cacheResult(list);
246    
247                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
248                            }
249                            catch (Exception e) {
250                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
251    
252                                    throw processException(e);
253                            }
254                            finally {
255                                    closeSession(session);
256                            }
257                    }
258    
259                    return list;
260            }
261    
262            /**
263             * Returns the first d d m content in the ordered set where uuid = &#63;.
264             *
265             * @param uuid the uuid
266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
267             * @return the first matching d d m content
268             * @throws NoSuchContentException if a matching d d m content could not be found
269             */
270            @Override
271            public DDMContent findByUuid_First(String uuid,
272                    OrderByComparator<DDMContent> orderByComparator)
273                    throws NoSuchContentException {
274                    DDMContent ddmContent = fetchByUuid_First(uuid, orderByComparator);
275    
276                    if (ddmContent != null) {
277                            return ddmContent;
278                    }
279    
280                    StringBundler msg = new StringBundler(4);
281    
282                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
283    
284                    msg.append("uuid=");
285                    msg.append(uuid);
286    
287                    msg.append(StringPool.CLOSE_CURLY_BRACE);
288    
289                    throw new NoSuchContentException(msg.toString());
290            }
291    
292            /**
293             * Returns the first d d m content in the ordered set where uuid = &#63;.
294             *
295             * @param uuid the uuid
296             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
297             * @return the first matching d d m content, or <code>null</code> if a matching d d m content could not be found
298             */
299            @Override
300            public DDMContent fetchByUuid_First(String uuid,
301                    OrderByComparator<DDMContent> orderByComparator) {
302                    List<DDMContent> list = findByUuid(uuid, 0, 1, orderByComparator);
303    
304                    if (!list.isEmpty()) {
305                            return list.get(0);
306                    }
307    
308                    return null;
309            }
310    
311            /**
312             * Returns the last d d m content in the ordered set where uuid = &#63;.
313             *
314             * @param uuid the uuid
315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
316             * @return the last matching d d m content
317             * @throws NoSuchContentException if a matching d d m content could not be found
318             */
319            @Override
320            public DDMContent findByUuid_Last(String uuid,
321                    OrderByComparator<DDMContent> orderByComparator)
322                    throws NoSuchContentException {
323                    DDMContent ddmContent = fetchByUuid_Last(uuid, orderByComparator);
324    
325                    if (ddmContent != null) {
326                            return ddmContent;
327                    }
328    
329                    StringBundler msg = new StringBundler(4);
330    
331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
332    
333                    msg.append("uuid=");
334                    msg.append(uuid);
335    
336                    msg.append(StringPool.CLOSE_CURLY_BRACE);
337    
338                    throw new NoSuchContentException(msg.toString());
339            }
340    
341            /**
342             * Returns the last d d m content in the ordered set where uuid = &#63;.
343             *
344             * @param uuid the uuid
345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
346             * @return the last matching d d m content, or <code>null</code> if a matching d d m content could not be found
347             */
348            @Override
349            public DDMContent fetchByUuid_Last(String uuid,
350                    OrderByComparator<DDMContent> orderByComparator) {
351                    int count = countByUuid(uuid);
352    
353                    if (count == 0) {
354                            return null;
355                    }
356    
357                    List<DDMContent> list = findByUuid(uuid, count - 1, count,
358                                    orderByComparator);
359    
360                    if (!list.isEmpty()) {
361                            return list.get(0);
362                    }
363    
364                    return null;
365            }
366    
367            /**
368             * Returns the d d m contents before and after the current d d m content in the ordered set where uuid = &#63;.
369             *
370             * @param contentId the primary key of the current d d m content
371             * @param uuid the uuid
372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
373             * @return the previous, current, and next d d m content
374             * @throws NoSuchContentException if a d d m content with the primary key could not be found
375             */
376            @Override
377            public DDMContent[] findByUuid_PrevAndNext(long contentId, String uuid,
378                    OrderByComparator<DDMContent> orderByComparator)
379                    throws NoSuchContentException {
380                    DDMContent ddmContent = findByPrimaryKey(contentId);
381    
382                    Session session = null;
383    
384                    try {
385                            session = openSession();
386    
387                            DDMContent[] array = new DDMContentImpl[3];
388    
389                            array[0] = getByUuid_PrevAndNext(session, ddmContent, uuid,
390                                            orderByComparator, true);
391    
392                            array[1] = ddmContent;
393    
394                            array[2] = getByUuid_PrevAndNext(session, ddmContent, uuid,
395                                            orderByComparator, false);
396    
397                            return array;
398                    }
399                    catch (Exception e) {
400                            throw processException(e);
401                    }
402                    finally {
403                            closeSession(session);
404                    }
405            }
406    
407            protected DDMContent getByUuid_PrevAndNext(Session session,
408                    DDMContent ddmContent, String uuid,
409                    OrderByComparator<DDMContent> orderByComparator, boolean previous) {
410                    StringBundler query = null;
411    
412                    if (orderByComparator != null) {
413                            query = new StringBundler(6 +
414                                            (orderByComparator.getOrderByFields().length * 6));
415                    }
416                    else {
417                            query = new StringBundler(3);
418                    }
419    
420                    query.append(_SQL_SELECT_DDMCONTENT_WHERE);
421    
422                    boolean bindUuid = false;
423    
424                    if (uuid == null) {
425                            query.append(_FINDER_COLUMN_UUID_UUID_1);
426                    }
427                    else if (uuid.equals(StringPool.BLANK)) {
428                            query.append(_FINDER_COLUMN_UUID_UUID_3);
429                    }
430                    else {
431                            bindUuid = true;
432    
433                            query.append(_FINDER_COLUMN_UUID_UUID_2);
434                    }
435    
436                    if (orderByComparator != null) {
437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438    
439                            if (orderByConditionFields.length > 0) {
440                                    query.append(WHERE_AND);
441                            }
442    
443                            for (int i = 0; i < orderByConditionFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByConditionFields[i]);
446    
447                                    if ((i + 1) < orderByConditionFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN);
461                                            }
462                                    }
463                            }
464    
465                            query.append(ORDER_BY_CLAUSE);
466    
467                            String[] orderByFields = orderByComparator.getOrderByFields();
468    
469                            for (int i = 0; i < orderByFields.length; i++) {
470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
471                                    query.append(orderByFields[i]);
472    
473                                    if ((i + 1) < orderByFields.length) {
474                                            if (orderByComparator.isAscending() ^ previous) {
475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
476                                            }
477                                            else {
478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
479                                            }
480                                    }
481                                    else {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC);
487                                            }
488                                    }
489                            }
490                    }
491                    else {
492                            query.append(DDMContentModelImpl.ORDER_BY_JPQL);
493                    }
494    
495                    String sql = query.toString();
496    
497                    Query q = session.createQuery(sql);
498    
499                    q.setFirstResult(0);
500                    q.setMaxResults(2);
501    
502                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                    if (bindUuid) {
505                            qPos.add(uuid);
506                    }
507    
508                    if (orderByComparator != null) {
509                            Object[] values = orderByComparator.getOrderByConditionValues(ddmContent);
510    
511                            for (Object value : values) {
512                                    qPos.add(value);
513                            }
514                    }
515    
516                    List<DDMContent> list = q.list();
517    
518                    if (list.size() == 2) {
519                            return list.get(1);
520                    }
521                    else {
522                            return null;
523                    }
524            }
525    
526            /**
527             * Removes all the d d m contents where uuid = &#63; from the database.
528             *
529             * @param uuid the uuid
530             */
531            @Override
532            public void removeByUuid(String uuid) {
533                    for (DDMContent ddmContent : findByUuid(uuid, QueryUtil.ALL_POS,
534                                    QueryUtil.ALL_POS, null)) {
535                            remove(ddmContent);
536                    }
537            }
538    
539            /**
540             * Returns the number of d d m contents where uuid = &#63;.
541             *
542             * @param uuid the uuid
543             * @return the number of matching d d m contents
544             */
545            @Override
546            public int countByUuid(String uuid) {
547                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
548    
549                    Object[] finderArgs = new Object[] { uuid };
550    
551                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
552                                    this);
553    
554                    if (count == null) {
555                            StringBundler query = new StringBundler(2);
556    
557                            query.append(_SQL_COUNT_DDMCONTENT_WHERE);
558    
559                            boolean bindUuid = false;
560    
561                            if (uuid == null) {
562                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
563                            }
564                            else if (uuid.equals(StringPool.BLANK)) {
565                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
566                            }
567                            else {
568                                    bindUuid = true;
569    
570                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
571                            }
572    
573                            String sql = query.toString();
574    
575                            Session session = null;
576    
577                            try {
578                                    session = openSession();
579    
580                                    Query q = session.createQuery(sql);
581    
582                                    QueryPos qPos = QueryPos.getInstance(q);
583    
584                                    if (bindUuid) {
585                                            qPos.add(uuid);
586                                    }
587    
588                                    count = (Long)q.uniqueResult();
589    
590                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
591                            }
592                            catch (Exception e) {
593                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
594    
595                                    throw processException(e);
596                            }
597                            finally {
598                                    closeSession(session);
599                            }
600                    }
601    
602                    return count.intValue();
603            }
604    
605            private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmContent.uuid IS NULL";
606            private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmContent.uuid = ?";
607            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmContent.uuid IS NULL OR ddmContent.uuid = '')";
608            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
609                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
610                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
611                            new String[] { String.class.getName(), Long.class.getName() },
612                            DDMContentModelImpl.UUID_COLUMN_BITMASK |
613                            DDMContentModelImpl.GROUPID_COLUMN_BITMASK);
614            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
615                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
617                            new String[] { String.class.getName(), Long.class.getName() });
618    
619            /**
620             * Returns the d d m content where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchContentException} if it could not be found.
621             *
622             * @param uuid the uuid
623             * @param groupId the group ID
624             * @return the matching d d m content
625             * @throws NoSuchContentException if a matching d d m content could not be found
626             */
627            @Override
628            public DDMContent findByUUID_G(String uuid, long groupId)
629                    throws NoSuchContentException {
630                    DDMContent ddmContent = fetchByUUID_G(uuid, groupId);
631    
632                    if (ddmContent == null) {
633                            StringBundler msg = new StringBundler(6);
634    
635                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
636    
637                            msg.append("uuid=");
638                            msg.append(uuid);
639    
640                            msg.append(", groupId=");
641                            msg.append(groupId);
642    
643                            msg.append(StringPool.CLOSE_CURLY_BRACE);
644    
645                            if (_log.isWarnEnabled()) {
646                                    _log.warn(msg.toString());
647                            }
648    
649                            throw new NoSuchContentException(msg.toString());
650                    }
651    
652                    return ddmContent;
653            }
654    
655            /**
656             * Returns the d d m content where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
657             *
658             * @param uuid the uuid
659             * @param groupId the group ID
660             * @return the matching d d m content, or <code>null</code> if a matching d d m content could not be found
661             */
662            @Override
663            public DDMContent fetchByUUID_G(String uuid, long groupId) {
664                    return fetchByUUID_G(uuid, groupId, true);
665            }
666    
667            /**
668             * Returns the d d m content where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @param retrieveFromCache whether to use the finder cache
673             * @return the matching d d m content, or <code>null</code> if a matching d d m content could not be found
674             */
675            @Override
676            public DDMContent fetchByUUID_G(String uuid, long groupId,
677                    boolean retrieveFromCache) {
678                    Object[] finderArgs = new Object[] { uuid, groupId };
679    
680                    Object result = null;
681    
682                    if (retrieveFromCache) {
683                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
684                                            finderArgs, this);
685                    }
686    
687                    if (result instanceof DDMContent) {
688                            DDMContent ddmContent = (DDMContent)result;
689    
690                            if (!Validator.equals(uuid, ddmContent.getUuid()) ||
691                                            (groupId != ddmContent.getGroupId())) {
692                                    result = null;
693                            }
694                    }
695    
696                    if (result == null) {
697                            StringBundler query = new StringBundler(4);
698    
699                            query.append(_SQL_SELECT_DDMCONTENT_WHERE);
700    
701                            boolean bindUuid = false;
702    
703                            if (uuid == null) {
704                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
705                            }
706                            else if (uuid.equals(StringPool.BLANK)) {
707                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
708                            }
709                            else {
710                                    bindUuid = true;
711    
712                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
713                            }
714    
715                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
716    
717                            String sql = query.toString();
718    
719                            Session session = null;
720    
721                            try {
722                                    session = openSession();
723    
724                                    Query q = session.createQuery(sql);
725    
726                                    QueryPos qPos = QueryPos.getInstance(q);
727    
728                                    if (bindUuid) {
729                                            qPos.add(uuid);
730                                    }
731    
732                                    qPos.add(groupId);
733    
734                                    List<DDMContent> list = q.list();
735    
736                                    if (list.isEmpty()) {
737                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
738                                                    finderArgs, list);
739                                    }
740                                    else {
741                                            DDMContent ddmContent = list.get(0);
742    
743                                            result = ddmContent;
744    
745                                            cacheResult(ddmContent);
746    
747                                            if ((ddmContent.getUuid() == null) ||
748                                                            !ddmContent.getUuid().equals(uuid) ||
749                                                            (ddmContent.getGroupId() != groupId)) {
750                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751                                                            finderArgs, ddmContent);
752                                            }
753                                    }
754                            }
755                            catch (Exception e) {
756                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                            finderArgs);
758    
759                                    throw processException(e);
760                            }
761                            finally {
762                                    closeSession(session);
763                            }
764                    }
765    
766                    if (result instanceof List<?>) {
767                            return null;
768                    }
769                    else {
770                            return (DDMContent)result;
771                    }
772            }
773    
774            /**
775             * Removes the d d m content where uuid = &#63; and groupId = &#63; from the database.
776             *
777             * @param uuid the uuid
778             * @param groupId the group ID
779             * @return the d d m content that was removed
780             */
781            @Override
782            public DDMContent removeByUUID_G(String uuid, long groupId)
783                    throws NoSuchContentException {
784                    DDMContent ddmContent = findByUUID_G(uuid, groupId);
785    
786                    return remove(ddmContent);
787            }
788    
789            /**
790             * Returns the number of d d m contents where uuid = &#63; and groupId = &#63;.
791             *
792             * @param uuid the uuid
793             * @param groupId the group ID
794             * @return the number of matching d d m contents
795             */
796            @Override
797            public int countByUUID_G(String uuid, long groupId) {
798                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
799    
800                    Object[] finderArgs = new Object[] { uuid, groupId };
801    
802                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
803                                    this);
804    
805                    if (count == null) {
806                            StringBundler query = new StringBundler(3);
807    
808                            query.append(_SQL_COUNT_DDMCONTENT_WHERE);
809    
810                            boolean bindUuid = false;
811    
812                            if (uuid == null) {
813                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
814                            }
815                            else if (uuid.equals(StringPool.BLANK)) {
816                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
817                            }
818                            else {
819                                    bindUuid = true;
820    
821                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
822                            }
823    
824                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
825    
826                            String sql = query.toString();
827    
828                            Session session = null;
829    
830                            try {
831                                    session = openSession();
832    
833                                    Query q = session.createQuery(sql);
834    
835                                    QueryPos qPos = QueryPos.getInstance(q);
836    
837                                    if (bindUuid) {
838                                            qPos.add(uuid);
839                                    }
840    
841                                    qPos.add(groupId);
842    
843                                    count = (Long)q.uniqueResult();
844    
845                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
846                            }
847                            catch (Exception e) {
848                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
849    
850                                    throw processException(e);
851                            }
852                            finally {
853                                    closeSession(session);
854                            }
855                    }
856    
857                    return count.intValue();
858            }
859    
860            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddmContent.uuid IS NULL AND ";
861            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddmContent.uuid = ? AND ";
862            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddmContent.uuid IS NULL OR ddmContent.uuid = '') AND ";
863            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddmContent.groupId = ?";
864            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
865                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
866                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
867                            new String[] {
868                                    String.class.getName(), Long.class.getName(),
869                                    
870                            Integer.class.getName(), Integer.class.getName(),
871                                    OrderByComparator.class.getName()
872                            });
873            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
874                    new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
875                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
876                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
877                            new String[] { String.class.getName(), Long.class.getName() },
878                            DDMContentModelImpl.UUID_COLUMN_BITMASK |
879                            DDMContentModelImpl.COMPANYID_COLUMN_BITMASK);
880            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
881                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
882                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
883                            new String[] { String.class.getName(), Long.class.getName() });
884    
885            /**
886             * Returns all the d d m contents where uuid = &#63; and companyId = &#63;.
887             *
888             * @param uuid the uuid
889             * @param companyId the company ID
890             * @return the matching d d m contents
891             */
892            @Override
893            public List<DDMContent> findByUuid_C(String uuid, long companyId) {
894                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
895                            QueryUtil.ALL_POS, null);
896            }
897    
898            /**
899             * Returns a range of all the d d m contents where uuid = &#63; and companyId = &#63;.
900             *
901             * <p>
902             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
903             * </p>
904             *
905             * @param uuid the uuid
906             * @param companyId the company ID
907             * @param start the lower bound of the range of d d m contents
908             * @param end the upper bound of the range of d d m contents (not inclusive)
909             * @return the range of matching d d m contents
910             */
911            @Override
912            public List<DDMContent> findByUuid_C(String uuid, long companyId,
913                    int start, int end) {
914                    return findByUuid_C(uuid, companyId, start, end, null);
915            }
916    
917            /**
918             * Returns an ordered range of all the d d m contents where uuid = &#63; and companyId = &#63;.
919             *
920             * <p>
921             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
922             * </p>
923             *
924             * @param uuid the uuid
925             * @param companyId the company ID
926             * @param start the lower bound of the range of d d m contents
927             * @param end the upper bound of the range of d d m contents (not inclusive)
928             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
929             * @return the ordered range of matching d d m contents
930             */
931            @Override
932            public List<DDMContent> findByUuid_C(String uuid, long companyId,
933                    int start, int end, OrderByComparator<DDMContent> orderByComparator) {
934                    boolean pagination = true;
935                    FinderPath finderPath = null;
936                    Object[] finderArgs = null;
937    
938                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
939                                    (orderByComparator == null)) {
940                            pagination = false;
941                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
942                            finderArgs = new Object[] { uuid, companyId };
943                    }
944                    else {
945                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
946                            finderArgs = new Object[] {
947                                            uuid, companyId,
948                                            
949                                            start, end, orderByComparator
950                                    };
951                    }
952    
953                    List<DDMContent> list = (List<DDMContent>)FinderCacheUtil.getResult(finderPath,
954                                    finderArgs, this);
955    
956                    if ((list != null) && !list.isEmpty()) {
957                            for (DDMContent ddmContent : list) {
958                                    if (!Validator.equals(uuid, ddmContent.getUuid()) ||
959                                                    (companyId != ddmContent.getCompanyId())) {
960                                            list = null;
961    
962                                            break;
963                                    }
964                            }
965                    }
966    
967                    if (list == null) {
968                            StringBundler query = null;
969    
970                            if (orderByComparator != null) {
971                                    query = new StringBundler(4 +
972                                                    (orderByComparator.getOrderByFields().length * 3));
973                            }
974                            else {
975                                    query = new StringBundler(4);
976                            }
977    
978                            query.append(_SQL_SELECT_DDMCONTENT_WHERE);
979    
980                            boolean bindUuid = false;
981    
982                            if (uuid == null) {
983                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
984                            }
985                            else if (uuid.equals(StringPool.BLANK)) {
986                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
987                            }
988                            else {
989                                    bindUuid = true;
990    
991                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
992                            }
993    
994                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
995    
996                            if (orderByComparator != null) {
997                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
998                                            orderByComparator);
999                            }
1000                            else
1001                             if (pagination) {
1002                                    query.append(DDMContentModelImpl.ORDER_BY_JPQL);
1003                            }
1004    
1005                            String sql = query.toString();
1006    
1007                            Session session = null;
1008    
1009                            try {
1010                                    session = openSession();
1011    
1012                                    Query q = session.createQuery(sql);
1013    
1014                                    QueryPos qPos = QueryPos.getInstance(q);
1015    
1016                                    if (bindUuid) {
1017                                            qPos.add(uuid);
1018                                    }
1019    
1020                                    qPos.add(companyId);
1021    
1022                                    if (!pagination) {
1023                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
1024                                                            start, end, false);
1025    
1026                                            Collections.sort(list);
1027    
1028                                            list = Collections.unmodifiableList(list);
1029                                    }
1030                                    else {
1031                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
1032                                                            start, end);
1033                                    }
1034    
1035                                    cacheResult(list);
1036    
1037                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1038                            }
1039                            catch (Exception e) {
1040                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1041    
1042                                    throw processException(e);
1043                            }
1044                            finally {
1045                                    closeSession(session);
1046                            }
1047                    }
1048    
1049                    return list;
1050            }
1051    
1052            /**
1053             * Returns the first d d m content in the ordered set where uuid = &#63; and companyId = &#63;.
1054             *
1055             * @param uuid the uuid
1056             * @param companyId the company ID
1057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1058             * @return the first matching d d m content
1059             * @throws NoSuchContentException if a matching d d m content could not be found
1060             */
1061            @Override
1062            public DDMContent findByUuid_C_First(String uuid, long companyId,
1063                    OrderByComparator<DDMContent> orderByComparator)
1064                    throws NoSuchContentException {
1065                    DDMContent ddmContent = fetchByUuid_C_First(uuid, companyId,
1066                                    orderByComparator);
1067    
1068                    if (ddmContent != null) {
1069                            return ddmContent;
1070                    }
1071    
1072                    StringBundler msg = new StringBundler(6);
1073    
1074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1075    
1076                    msg.append("uuid=");
1077                    msg.append(uuid);
1078    
1079                    msg.append(", companyId=");
1080                    msg.append(companyId);
1081    
1082                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1083    
1084                    throw new NoSuchContentException(msg.toString());
1085            }
1086    
1087            /**
1088             * Returns the first d d m content in the ordered set where uuid = &#63; and companyId = &#63;.
1089             *
1090             * @param uuid the uuid
1091             * @param companyId the company ID
1092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1093             * @return the first matching d d m content, or <code>null</code> if a matching d d m content could not be found
1094             */
1095            @Override
1096            public DDMContent fetchByUuid_C_First(String uuid, long companyId,
1097                    OrderByComparator<DDMContent> orderByComparator) {
1098                    List<DDMContent> list = findByUuid_C(uuid, companyId, 0, 1,
1099                                    orderByComparator);
1100    
1101                    if (!list.isEmpty()) {
1102                            return list.get(0);
1103                    }
1104    
1105                    return null;
1106            }
1107    
1108            /**
1109             * Returns the last d d m content in the ordered set where uuid = &#63; and companyId = &#63;.
1110             *
1111             * @param uuid the uuid
1112             * @param companyId the company ID
1113             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1114             * @return the last matching d d m content
1115             * @throws NoSuchContentException if a matching d d m content could not be found
1116             */
1117            @Override
1118            public DDMContent findByUuid_C_Last(String uuid, long companyId,
1119                    OrderByComparator<DDMContent> orderByComparator)
1120                    throws NoSuchContentException {
1121                    DDMContent ddmContent = fetchByUuid_C_Last(uuid, companyId,
1122                                    orderByComparator);
1123    
1124                    if (ddmContent != null) {
1125                            return ddmContent;
1126                    }
1127    
1128                    StringBundler msg = new StringBundler(6);
1129    
1130                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1131    
1132                    msg.append("uuid=");
1133                    msg.append(uuid);
1134    
1135                    msg.append(", companyId=");
1136                    msg.append(companyId);
1137    
1138                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1139    
1140                    throw new NoSuchContentException(msg.toString());
1141            }
1142    
1143            /**
1144             * Returns the last d d m content in the ordered set where uuid = &#63; and companyId = &#63;.
1145             *
1146             * @param uuid the uuid
1147             * @param companyId the company ID
1148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1149             * @return the last matching d d m content, or <code>null</code> if a matching d d m content could not be found
1150             */
1151            @Override
1152            public DDMContent fetchByUuid_C_Last(String uuid, long companyId,
1153                    OrderByComparator<DDMContent> orderByComparator) {
1154                    int count = countByUuid_C(uuid, companyId);
1155    
1156                    if (count == 0) {
1157                            return null;
1158                    }
1159    
1160                    List<DDMContent> list = findByUuid_C(uuid, companyId, count - 1, count,
1161                                    orderByComparator);
1162    
1163                    if (!list.isEmpty()) {
1164                            return list.get(0);
1165                    }
1166    
1167                    return null;
1168            }
1169    
1170            /**
1171             * Returns the d d m contents before and after the current d d m content in the ordered set where uuid = &#63; and companyId = &#63;.
1172             *
1173             * @param contentId the primary key of the current d d m content
1174             * @param uuid the uuid
1175             * @param companyId the company ID
1176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1177             * @return the previous, current, and next d d m content
1178             * @throws NoSuchContentException if a d d m content with the primary key could not be found
1179             */
1180            @Override
1181            public DDMContent[] findByUuid_C_PrevAndNext(long contentId, String uuid,
1182                    long companyId, OrderByComparator<DDMContent> orderByComparator)
1183                    throws NoSuchContentException {
1184                    DDMContent ddmContent = findByPrimaryKey(contentId);
1185    
1186                    Session session = null;
1187    
1188                    try {
1189                            session = openSession();
1190    
1191                            DDMContent[] array = new DDMContentImpl[3];
1192    
1193                            array[0] = getByUuid_C_PrevAndNext(session, ddmContent, uuid,
1194                                            companyId, orderByComparator, true);
1195    
1196                            array[1] = ddmContent;
1197    
1198                            array[2] = getByUuid_C_PrevAndNext(session, ddmContent, uuid,
1199                                            companyId, orderByComparator, false);
1200    
1201                            return array;
1202                    }
1203                    catch (Exception e) {
1204                            throw processException(e);
1205                    }
1206                    finally {
1207                            closeSession(session);
1208                    }
1209            }
1210    
1211            protected DDMContent getByUuid_C_PrevAndNext(Session session,
1212                    DDMContent ddmContent, String uuid, long companyId,
1213                    OrderByComparator<DDMContent> orderByComparator, boolean previous) {
1214                    StringBundler query = null;
1215    
1216                    if (orderByComparator != null) {
1217                            query = new StringBundler(6 +
1218                                            (orderByComparator.getOrderByFields().length * 6));
1219                    }
1220                    else {
1221                            query = new StringBundler(3);
1222                    }
1223    
1224                    query.append(_SQL_SELECT_DDMCONTENT_WHERE);
1225    
1226                    boolean bindUuid = false;
1227    
1228                    if (uuid == null) {
1229                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1230                    }
1231                    else if (uuid.equals(StringPool.BLANK)) {
1232                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1233                    }
1234                    else {
1235                            bindUuid = true;
1236    
1237                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1238                    }
1239    
1240                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1241    
1242                    if (orderByComparator != null) {
1243                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1244    
1245                            if (orderByConditionFields.length > 0) {
1246                                    query.append(WHERE_AND);
1247                            }
1248    
1249                            for (int i = 0; i < orderByConditionFields.length; i++) {
1250                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1251                                    query.append(orderByConditionFields[i]);
1252    
1253                                    if ((i + 1) < orderByConditionFields.length) {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1256                                            }
1257                                            else {
1258                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1259                                            }
1260                                    }
1261                                    else {
1262                                            if (orderByComparator.isAscending() ^ previous) {
1263                                                    query.append(WHERE_GREATER_THAN);
1264                                            }
1265                                            else {
1266                                                    query.append(WHERE_LESSER_THAN);
1267                                            }
1268                                    }
1269                            }
1270    
1271                            query.append(ORDER_BY_CLAUSE);
1272    
1273                            String[] orderByFields = orderByComparator.getOrderByFields();
1274    
1275                            for (int i = 0; i < orderByFields.length; i++) {
1276                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1277                                    query.append(orderByFields[i]);
1278    
1279                                    if ((i + 1) < orderByFields.length) {
1280                                            if (orderByComparator.isAscending() ^ previous) {
1281                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1282                                            }
1283                                            else {
1284                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1285                                            }
1286                                    }
1287                                    else {
1288                                            if (orderByComparator.isAscending() ^ previous) {
1289                                                    query.append(ORDER_BY_ASC);
1290                                            }
1291                                            else {
1292                                                    query.append(ORDER_BY_DESC);
1293                                            }
1294                                    }
1295                            }
1296                    }
1297                    else {
1298                            query.append(DDMContentModelImpl.ORDER_BY_JPQL);
1299                    }
1300    
1301                    String sql = query.toString();
1302    
1303                    Query q = session.createQuery(sql);
1304    
1305                    q.setFirstResult(0);
1306                    q.setMaxResults(2);
1307    
1308                    QueryPos qPos = QueryPos.getInstance(q);
1309    
1310                    if (bindUuid) {
1311                            qPos.add(uuid);
1312                    }
1313    
1314                    qPos.add(companyId);
1315    
1316                    if (orderByComparator != null) {
1317                            Object[] values = orderByComparator.getOrderByConditionValues(ddmContent);
1318    
1319                            for (Object value : values) {
1320                                    qPos.add(value);
1321                            }
1322                    }
1323    
1324                    List<DDMContent> list = q.list();
1325    
1326                    if (list.size() == 2) {
1327                            return list.get(1);
1328                    }
1329                    else {
1330                            return null;
1331                    }
1332            }
1333    
1334            /**
1335             * Removes all the d d m contents where uuid = &#63; and companyId = &#63; from the database.
1336             *
1337             * @param uuid the uuid
1338             * @param companyId the company ID
1339             */
1340            @Override
1341            public void removeByUuid_C(String uuid, long companyId) {
1342                    for (DDMContent ddmContent : findByUuid_C(uuid, companyId,
1343                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1344                            remove(ddmContent);
1345                    }
1346            }
1347    
1348            /**
1349             * Returns the number of d d m contents where uuid = &#63; and companyId = &#63;.
1350             *
1351             * @param uuid the uuid
1352             * @param companyId the company ID
1353             * @return the number of matching d d m contents
1354             */
1355            @Override
1356            public int countByUuid_C(String uuid, long companyId) {
1357                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1358    
1359                    Object[] finderArgs = new Object[] { uuid, companyId };
1360    
1361                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1362                                    this);
1363    
1364                    if (count == null) {
1365                            StringBundler query = new StringBundler(3);
1366    
1367                            query.append(_SQL_COUNT_DDMCONTENT_WHERE);
1368    
1369                            boolean bindUuid = false;
1370    
1371                            if (uuid == null) {
1372                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1373                            }
1374                            else if (uuid.equals(StringPool.BLANK)) {
1375                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1376                            }
1377                            else {
1378                                    bindUuid = true;
1379    
1380                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1381                            }
1382    
1383                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1384    
1385                            String sql = query.toString();
1386    
1387                            Session session = null;
1388    
1389                            try {
1390                                    session = openSession();
1391    
1392                                    Query q = session.createQuery(sql);
1393    
1394                                    QueryPos qPos = QueryPos.getInstance(q);
1395    
1396                                    if (bindUuid) {
1397                                            qPos.add(uuid);
1398                                    }
1399    
1400                                    qPos.add(companyId);
1401    
1402                                    count = (Long)q.uniqueResult();
1403    
1404                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1405                            }
1406                            catch (Exception e) {
1407                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1408    
1409                                    throw processException(e);
1410                            }
1411                            finally {
1412                                    closeSession(session);
1413                            }
1414                    }
1415    
1416                    return count.intValue();
1417            }
1418    
1419            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "ddmContent.uuid IS NULL AND ";
1420            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ddmContent.uuid = ? AND ";
1421            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ddmContent.uuid IS NULL OR ddmContent.uuid = '') AND ";
1422            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ddmContent.companyId = ?";
1423            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1424                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
1425                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1426                            new String[] {
1427                                    Long.class.getName(),
1428                                    
1429                            Integer.class.getName(), Integer.class.getName(),
1430                                    OrderByComparator.class.getName()
1431                            });
1432            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1433                    new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1434                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
1435                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1436                            new String[] { Long.class.getName() },
1437                            DDMContentModelImpl.GROUPID_COLUMN_BITMASK);
1438            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1439                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
1440                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1441                            new String[] { Long.class.getName() });
1442    
1443            /**
1444             * Returns all the d d m contents where groupId = &#63;.
1445             *
1446             * @param groupId the group ID
1447             * @return the matching d d m contents
1448             */
1449            @Override
1450            public List<DDMContent> findByGroupId(long groupId) {
1451                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1452            }
1453    
1454            /**
1455             * Returns a range of all the d d m contents where groupId = &#63;.
1456             *
1457             * <p>
1458             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
1459             * </p>
1460             *
1461             * @param groupId the group ID
1462             * @param start the lower bound of the range of d d m contents
1463             * @param end the upper bound of the range of d d m contents (not inclusive)
1464             * @return the range of matching d d m contents
1465             */
1466            @Override
1467            public List<DDMContent> findByGroupId(long groupId, int start, int end) {
1468                    return findByGroupId(groupId, start, end, null);
1469            }
1470    
1471            /**
1472             * Returns an ordered range of all the d d m contents where groupId = &#63;.
1473             *
1474             * <p>
1475             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
1476             * </p>
1477             *
1478             * @param groupId the group ID
1479             * @param start the lower bound of the range of d d m contents
1480             * @param end the upper bound of the range of d d m contents (not inclusive)
1481             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1482             * @return the ordered range of matching d d m contents
1483             */
1484            @Override
1485            public List<DDMContent> findByGroupId(long groupId, int start, int end,
1486                    OrderByComparator<DDMContent> orderByComparator) {
1487                    boolean pagination = true;
1488                    FinderPath finderPath = null;
1489                    Object[] finderArgs = null;
1490    
1491                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1492                                    (orderByComparator == null)) {
1493                            pagination = false;
1494                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1495                            finderArgs = new Object[] { groupId };
1496                    }
1497                    else {
1498                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1499                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1500                    }
1501    
1502                    List<DDMContent> list = (List<DDMContent>)FinderCacheUtil.getResult(finderPath,
1503                                    finderArgs, this);
1504    
1505                    if ((list != null) && !list.isEmpty()) {
1506                            for (DDMContent ddmContent : list) {
1507                                    if ((groupId != ddmContent.getGroupId())) {
1508                                            list = null;
1509    
1510                                            break;
1511                                    }
1512                            }
1513                    }
1514    
1515                    if (list == null) {
1516                            StringBundler query = null;
1517    
1518                            if (orderByComparator != null) {
1519                                    query = new StringBundler(3 +
1520                                                    (orderByComparator.getOrderByFields().length * 3));
1521                            }
1522                            else {
1523                                    query = new StringBundler(3);
1524                            }
1525    
1526                            query.append(_SQL_SELECT_DDMCONTENT_WHERE);
1527    
1528                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1529    
1530                            if (orderByComparator != null) {
1531                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1532                                            orderByComparator);
1533                            }
1534                            else
1535                             if (pagination) {
1536                                    query.append(DDMContentModelImpl.ORDER_BY_JPQL);
1537                            }
1538    
1539                            String sql = query.toString();
1540    
1541                            Session session = null;
1542    
1543                            try {
1544                                    session = openSession();
1545    
1546                                    Query q = session.createQuery(sql);
1547    
1548                                    QueryPos qPos = QueryPos.getInstance(q);
1549    
1550                                    qPos.add(groupId);
1551    
1552                                    if (!pagination) {
1553                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
1554                                                            start, end, false);
1555    
1556                                            Collections.sort(list);
1557    
1558                                            list = Collections.unmodifiableList(list);
1559                                    }
1560                                    else {
1561                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
1562                                                            start, end);
1563                                    }
1564    
1565                                    cacheResult(list);
1566    
1567                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1568                            }
1569                            catch (Exception e) {
1570                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1571    
1572                                    throw processException(e);
1573                            }
1574                            finally {
1575                                    closeSession(session);
1576                            }
1577                    }
1578    
1579                    return list;
1580            }
1581    
1582            /**
1583             * Returns the first d d m content in the ordered set where groupId = &#63;.
1584             *
1585             * @param groupId the group ID
1586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1587             * @return the first matching d d m content
1588             * @throws NoSuchContentException if a matching d d m content could not be found
1589             */
1590            @Override
1591            public DDMContent findByGroupId_First(long groupId,
1592                    OrderByComparator<DDMContent> orderByComparator)
1593                    throws NoSuchContentException {
1594                    DDMContent ddmContent = fetchByGroupId_First(groupId, orderByComparator);
1595    
1596                    if (ddmContent != null) {
1597                            return ddmContent;
1598                    }
1599    
1600                    StringBundler msg = new StringBundler(4);
1601    
1602                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1603    
1604                    msg.append("groupId=");
1605                    msg.append(groupId);
1606    
1607                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1608    
1609                    throw new NoSuchContentException(msg.toString());
1610            }
1611    
1612            /**
1613             * Returns the first d d m content in the ordered set where groupId = &#63;.
1614             *
1615             * @param groupId the group ID
1616             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1617             * @return the first matching d d m content, or <code>null</code> if a matching d d m content could not be found
1618             */
1619            @Override
1620            public DDMContent fetchByGroupId_First(long groupId,
1621                    OrderByComparator<DDMContent> orderByComparator) {
1622                    List<DDMContent> list = findByGroupId(groupId, 0, 1, orderByComparator);
1623    
1624                    if (!list.isEmpty()) {
1625                            return list.get(0);
1626                    }
1627    
1628                    return null;
1629            }
1630    
1631            /**
1632             * Returns the last d d m content in the ordered set where groupId = &#63;.
1633             *
1634             * @param groupId the group ID
1635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1636             * @return the last matching d d m content
1637             * @throws NoSuchContentException if a matching d d m content could not be found
1638             */
1639            @Override
1640            public DDMContent findByGroupId_Last(long groupId,
1641                    OrderByComparator<DDMContent> orderByComparator)
1642                    throws NoSuchContentException {
1643                    DDMContent ddmContent = fetchByGroupId_Last(groupId, orderByComparator);
1644    
1645                    if (ddmContent != null) {
1646                            return ddmContent;
1647                    }
1648    
1649                    StringBundler msg = new StringBundler(4);
1650    
1651                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1652    
1653                    msg.append("groupId=");
1654                    msg.append(groupId);
1655    
1656                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1657    
1658                    throw new NoSuchContentException(msg.toString());
1659            }
1660    
1661            /**
1662             * Returns the last d d m content in the ordered set where groupId = &#63;.
1663             *
1664             * @param groupId the group ID
1665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1666             * @return the last matching d d m content, or <code>null</code> if a matching d d m content could not be found
1667             */
1668            @Override
1669            public DDMContent fetchByGroupId_Last(long groupId,
1670                    OrderByComparator<DDMContent> orderByComparator) {
1671                    int count = countByGroupId(groupId);
1672    
1673                    if (count == 0) {
1674                            return null;
1675                    }
1676    
1677                    List<DDMContent> list = findByGroupId(groupId, count - 1, count,
1678                                    orderByComparator);
1679    
1680                    if (!list.isEmpty()) {
1681                            return list.get(0);
1682                    }
1683    
1684                    return null;
1685            }
1686    
1687            /**
1688             * Returns the d d m contents before and after the current d d m content in the ordered set where groupId = &#63;.
1689             *
1690             * @param contentId the primary key of the current d d m content
1691             * @param groupId the group ID
1692             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1693             * @return the previous, current, and next d d m content
1694             * @throws NoSuchContentException if a d d m content with the primary key could not be found
1695             */
1696            @Override
1697            public DDMContent[] findByGroupId_PrevAndNext(long contentId, long groupId,
1698                    OrderByComparator<DDMContent> orderByComparator)
1699                    throws NoSuchContentException {
1700                    DDMContent ddmContent = findByPrimaryKey(contentId);
1701    
1702                    Session session = null;
1703    
1704                    try {
1705                            session = openSession();
1706    
1707                            DDMContent[] array = new DDMContentImpl[3];
1708    
1709                            array[0] = getByGroupId_PrevAndNext(session, ddmContent, groupId,
1710                                            orderByComparator, true);
1711    
1712                            array[1] = ddmContent;
1713    
1714                            array[2] = getByGroupId_PrevAndNext(session, ddmContent, groupId,
1715                                            orderByComparator, false);
1716    
1717                            return array;
1718                    }
1719                    catch (Exception e) {
1720                            throw processException(e);
1721                    }
1722                    finally {
1723                            closeSession(session);
1724                    }
1725            }
1726    
1727            protected DDMContent getByGroupId_PrevAndNext(Session session,
1728                    DDMContent ddmContent, long groupId,
1729                    OrderByComparator<DDMContent> orderByComparator, boolean previous) {
1730                    StringBundler query = null;
1731    
1732                    if (orderByComparator != null) {
1733                            query = new StringBundler(6 +
1734                                            (orderByComparator.getOrderByFields().length * 6));
1735                    }
1736                    else {
1737                            query = new StringBundler(3);
1738                    }
1739    
1740                    query.append(_SQL_SELECT_DDMCONTENT_WHERE);
1741    
1742                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1743    
1744                    if (orderByComparator != null) {
1745                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1746    
1747                            if (orderByConditionFields.length > 0) {
1748                                    query.append(WHERE_AND);
1749                            }
1750    
1751                            for (int i = 0; i < orderByConditionFields.length; i++) {
1752                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1753                                    query.append(orderByConditionFields[i]);
1754    
1755                                    if ((i + 1) < orderByConditionFields.length) {
1756                                            if (orderByComparator.isAscending() ^ previous) {
1757                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1758                                            }
1759                                            else {
1760                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1761                                            }
1762                                    }
1763                                    else {
1764                                            if (orderByComparator.isAscending() ^ previous) {
1765                                                    query.append(WHERE_GREATER_THAN);
1766                                            }
1767                                            else {
1768                                                    query.append(WHERE_LESSER_THAN);
1769                                            }
1770                                    }
1771                            }
1772    
1773                            query.append(ORDER_BY_CLAUSE);
1774    
1775                            String[] orderByFields = orderByComparator.getOrderByFields();
1776    
1777                            for (int i = 0; i < orderByFields.length; i++) {
1778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1779                                    query.append(orderByFields[i]);
1780    
1781                                    if ((i + 1) < orderByFields.length) {
1782                                            if (orderByComparator.isAscending() ^ previous) {
1783                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1784                                            }
1785                                            else {
1786                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1787                                            }
1788                                    }
1789                                    else {
1790                                            if (orderByComparator.isAscending() ^ previous) {
1791                                                    query.append(ORDER_BY_ASC);
1792                                            }
1793                                            else {
1794                                                    query.append(ORDER_BY_DESC);
1795                                            }
1796                                    }
1797                            }
1798                    }
1799                    else {
1800                            query.append(DDMContentModelImpl.ORDER_BY_JPQL);
1801                    }
1802    
1803                    String sql = query.toString();
1804    
1805                    Query q = session.createQuery(sql);
1806    
1807                    q.setFirstResult(0);
1808                    q.setMaxResults(2);
1809    
1810                    QueryPos qPos = QueryPos.getInstance(q);
1811    
1812                    qPos.add(groupId);
1813    
1814                    if (orderByComparator != null) {
1815                            Object[] values = orderByComparator.getOrderByConditionValues(ddmContent);
1816    
1817                            for (Object value : values) {
1818                                    qPos.add(value);
1819                            }
1820                    }
1821    
1822                    List<DDMContent> list = q.list();
1823    
1824                    if (list.size() == 2) {
1825                            return list.get(1);
1826                    }
1827                    else {
1828                            return null;
1829                    }
1830            }
1831    
1832            /**
1833             * Removes all the d d m contents where groupId = &#63; from the database.
1834             *
1835             * @param groupId the group ID
1836             */
1837            @Override
1838            public void removeByGroupId(long groupId) {
1839                    for (DDMContent ddmContent : findByGroupId(groupId, QueryUtil.ALL_POS,
1840                                    QueryUtil.ALL_POS, null)) {
1841                            remove(ddmContent);
1842                    }
1843            }
1844    
1845            /**
1846             * Returns the number of d d m contents where groupId = &#63;.
1847             *
1848             * @param groupId the group ID
1849             * @return the number of matching d d m contents
1850             */
1851            @Override
1852            public int countByGroupId(long groupId) {
1853                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
1854    
1855                    Object[] finderArgs = new Object[] { groupId };
1856    
1857                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1858                                    this);
1859    
1860                    if (count == null) {
1861                            StringBundler query = new StringBundler(2);
1862    
1863                            query.append(_SQL_COUNT_DDMCONTENT_WHERE);
1864    
1865                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1866    
1867                            String sql = query.toString();
1868    
1869                            Session session = null;
1870    
1871                            try {
1872                                    session = openSession();
1873    
1874                                    Query q = session.createQuery(sql);
1875    
1876                                    QueryPos qPos = QueryPos.getInstance(q);
1877    
1878                                    qPos.add(groupId);
1879    
1880                                    count = (Long)q.uniqueResult();
1881    
1882                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1883                            }
1884                            catch (Exception e) {
1885                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1886    
1887                                    throw processException(e);
1888                            }
1889                            finally {
1890                                    closeSession(session);
1891                            }
1892                    }
1893    
1894                    return count.intValue();
1895            }
1896    
1897            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddmContent.groupId = ?";
1898            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1899                    new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1900                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
1901                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1902                            new String[] {
1903                                    Long.class.getName(),
1904                                    
1905                            Integer.class.getName(), Integer.class.getName(),
1906                                    OrderByComparator.class.getName()
1907                            });
1908            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1909                    new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1910                            DDMContentModelImpl.FINDER_CACHE_ENABLED, DDMContentImpl.class,
1911                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1912                            new String[] { Long.class.getName() },
1913                            DDMContentModelImpl.COMPANYID_COLUMN_BITMASK);
1914            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
1915                            DDMContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
1916                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1917                            new String[] { Long.class.getName() });
1918    
1919            /**
1920             * Returns all the d d m contents where companyId = &#63;.
1921             *
1922             * @param companyId the company ID
1923             * @return the matching d d m contents
1924             */
1925            @Override
1926            public List<DDMContent> findByCompanyId(long companyId) {
1927                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1928                            null);
1929            }
1930    
1931            /**
1932             * Returns a range of all the d d m contents where companyId = &#63;.
1933             *
1934             * <p>
1935             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
1936             * </p>
1937             *
1938             * @param companyId the company ID
1939             * @param start the lower bound of the range of d d m contents
1940             * @param end the upper bound of the range of d d m contents (not inclusive)
1941             * @return the range of matching d d m contents
1942             */
1943            @Override
1944            public List<DDMContent> findByCompanyId(long companyId, int start, int end) {
1945                    return findByCompanyId(companyId, start, end, null);
1946            }
1947    
1948            /**
1949             * Returns an ordered range of all the d d m contents where companyId = &#63;.
1950             *
1951             * <p>
1952             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
1953             * </p>
1954             *
1955             * @param companyId the company ID
1956             * @param start the lower bound of the range of d d m contents
1957             * @param end the upper bound of the range of d d m contents (not inclusive)
1958             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1959             * @return the ordered range of matching d d m contents
1960             */
1961            @Override
1962            public List<DDMContent> findByCompanyId(long companyId, int start, int end,
1963                    OrderByComparator<DDMContent> orderByComparator) {
1964                    boolean pagination = true;
1965                    FinderPath finderPath = null;
1966                    Object[] finderArgs = null;
1967    
1968                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1969                                    (orderByComparator == null)) {
1970                            pagination = false;
1971                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1972                            finderArgs = new Object[] { companyId };
1973                    }
1974                    else {
1975                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1976                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1977                    }
1978    
1979                    List<DDMContent> list = (List<DDMContent>)FinderCacheUtil.getResult(finderPath,
1980                                    finderArgs, this);
1981    
1982                    if ((list != null) && !list.isEmpty()) {
1983                            for (DDMContent ddmContent : list) {
1984                                    if ((companyId != ddmContent.getCompanyId())) {
1985                                            list = null;
1986    
1987                                            break;
1988                                    }
1989                            }
1990                    }
1991    
1992                    if (list == null) {
1993                            StringBundler query = null;
1994    
1995                            if (orderByComparator != null) {
1996                                    query = new StringBundler(3 +
1997                                                    (orderByComparator.getOrderByFields().length * 3));
1998                            }
1999                            else {
2000                                    query = new StringBundler(3);
2001                            }
2002    
2003                            query.append(_SQL_SELECT_DDMCONTENT_WHERE);
2004    
2005                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2006    
2007                            if (orderByComparator != null) {
2008                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2009                                            orderByComparator);
2010                            }
2011                            else
2012                             if (pagination) {
2013                                    query.append(DDMContentModelImpl.ORDER_BY_JPQL);
2014                            }
2015    
2016                            String sql = query.toString();
2017    
2018                            Session session = null;
2019    
2020                            try {
2021                                    session = openSession();
2022    
2023                                    Query q = session.createQuery(sql);
2024    
2025                                    QueryPos qPos = QueryPos.getInstance(q);
2026    
2027                                    qPos.add(companyId);
2028    
2029                                    if (!pagination) {
2030                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
2031                                                            start, end, false);
2032    
2033                                            Collections.sort(list);
2034    
2035                                            list = Collections.unmodifiableList(list);
2036                                    }
2037                                    else {
2038                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
2039                                                            start, end);
2040                                    }
2041    
2042                                    cacheResult(list);
2043    
2044                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2045                            }
2046                            catch (Exception e) {
2047                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2048    
2049                                    throw processException(e);
2050                            }
2051                            finally {
2052                                    closeSession(session);
2053                            }
2054                    }
2055    
2056                    return list;
2057            }
2058    
2059            /**
2060             * Returns the first d d m content in the ordered set where companyId = &#63;.
2061             *
2062             * @param companyId the company ID
2063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2064             * @return the first matching d d m content
2065             * @throws NoSuchContentException if a matching d d m content could not be found
2066             */
2067            @Override
2068            public DDMContent findByCompanyId_First(long companyId,
2069                    OrderByComparator<DDMContent> orderByComparator)
2070                    throws NoSuchContentException {
2071                    DDMContent ddmContent = fetchByCompanyId_First(companyId,
2072                                    orderByComparator);
2073    
2074                    if (ddmContent != null) {
2075                            return ddmContent;
2076                    }
2077    
2078                    StringBundler msg = new StringBundler(4);
2079    
2080                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2081    
2082                    msg.append("companyId=");
2083                    msg.append(companyId);
2084    
2085                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2086    
2087                    throw new NoSuchContentException(msg.toString());
2088            }
2089    
2090            /**
2091             * Returns the first d d m content in the ordered set where companyId = &#63;.
2092             *
2093             * @param companyId the company ID
2094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2095             * @return the first matching d d m content, or <code>null</code> if a matching d d m content could not be found
2096             */
2097            @Override
2098            public DDMContent fetchByCompanyId_First(long companyId,
2099                    OrderByComparator<DDMContent> orderByComparator) {
2100                    List<DDMContent> list = findByCompanyId(companyId, 0, 1,
2101                                    orderByComparator);
2102    
2103                    if (!list.isEmpty()) {
2104                            return list.get(0);
2105                    }
2106    
2107                    return null;
2108            }
2109    
2110            /**
2111             * Returns the last d d m content in the ordered set where companyId = &#63;.
2112             *
2113             * @param companyId the company ID
2114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2115             * @return the last matching d d m content
2116             * @throws NoSuchContentException if a matching d d m content could not be found
2117             */
2118            @Override
2119            public DDMContent findByCompanyId_Last(long companyId,
2120                    OrderByComparator<DDMContent> orderByComparator)
2121                    throws NoSuchContentException {
2122                    DDMContent ddmContent = fetchByCompanyId_Last(companyId,
2123                                    orderByComparator);
2124    
2125                    if (ddmContent != null) {
2126                            return ddmContent;
2127                    }
2128    
2129                    StringBundler msg = new StringBundler(4);
2130    
2131                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2132    
2133                    msg.append("companyId=");
2134                    msg.append(companyId);
2135    
2136                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2137    
2138                    throw new NoSuchContentException(msg.toString());
2139            }
2140    
2141            /**
2142             * Returns the last d d m content in the ordered set where companyId = &#63;.
2143             *
2144             * @param companyId the company ID
2145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2146             * @return the last matching d d m content, or <code>null</code> if a matching d d m content could not be found
2147             */
2148            @Override
2149            public DDMContent fetchByCompanyId_Last(long companyId,
2150                    OrderByComparator<DDMContent> orderByComparator) {
2151                    int count = countByCompanyId(companyId);
2152    
2153                    if (count == 0) {
2154                            return null;
2155                    }
2156    
2157                    List<DDMContent> list = findByCompanyId(companyId, count - 1, count,
2158                                    orderByComparator);
2159    
2160                    if (!list.isEmpty()) {
2161                            return list.get(0);
2162                    }
2163    
2164                    return null;
2165            }
2166    
2167            /**
2168             * Returns the d d m contents before and after the current d d m content in the ordered set where companyId = &#63;.
2169             *
2170             * @param contentId the primary key of the current d d m content
2171             * @param companyId the company ID
2172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2173             * @return the previous, current, and next d d m content
2174             * @throws NoSuchContentException if a d d m content with the primary key could not be found
2175             */
2176            @Override
2177            public DDMContent[] findByCompanyId_PrevAndNext(long contentId,
2178                    long companyId, OrderByComparator<DDMContent> orderByComparator)
2179                    throws NoSuchContentException {
2180                    DDMContent ddmContent = findByPrimaryKey(contentId);
2181    
2182                    Session session = null;
2183    
2184                    try {
2185                            session = openSession();
2186    
2187                            DDMContent[] array = new DDMContentImpl[3];
2188    
2189                            array[0] = getByCompanyId_PrevAndNext(session, ddmContent,
2190                                            companyId, orderByComparator, true);
2191    
2192                            array[1] = ddmContent;
2193    
2194                            array[2] = getByCompanyId_PrevAndNext(session, ddmContent,
2195                                            companyId, orderByComparator, false);
2196    
2197                            return array;
2198                    }
2199                    catch (Exception e) {
2200                            throw processException(e);
2201                    }
2202                    finally {
2203                            closeSession(session);
2204                    }
2205            }
2206    
2207            protected DDMContent getByCompanyId_PrevAndNext(Session session,
2208                    DDMContent ddmContent, long companyId,
2209                    OrderByComparator<DDMContent> orderByComparator, boolean previous) {
2210                    StringBundler query = null;
2211    
2212                    if (orderByComparator != null) {
2213                            query = new StringBundler(6 +
2214                                            (orderByComparator.getOrderByFields().length * 6));
2215                    }
2216                    else {
2217                            query = new StringBundler(3);
2218                    }
2219    
2220                    query.append(_SQL_SELECT_DDMCONTENT_WHERE);
2221    
2222                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2223    
2224                    if (orderByComparator != null) {
2225                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2226    
2227                            if (orderByConditionFields.length > 0) {
2228                                    query.append(WHERE_AND);
2229                            }
2230    
2231                            for (int i = 0; i < orderByConditionFields.length; i++) {
2232                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2233                                    query.append(orderByConditionFields[i]);
2234    
2235                                    if ((i + 1) < orderByConditionFields.length) {
2236                                            if (orderByComparator.isAscending() ^ previous) {
2237                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2238                                            }
2239                                            else {
2240                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2241                                            }
2242                                    }
2243                                    else {
2244                                            if (orderByComparator.isAscending() ^ previous) {
2245                                                    query.append(WHERE_GREATER_THAN);
2246                                            }
2247                                            else {
2248                                                    query.append(WHERE_LESSER_THAN);
2249                                            }
2250                                    }
2251                            }
2252    
2253                            query.append(ORDER_BY_CLAUSE);
2254    
2255                            String[] orderByFields = orderByComparator.getOrderByFields();
2256    
2257                            for (int i = 0; i < orderByFields.length; i++) {
2258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2259                                    query.append(orderByFields[i]);
2260    
2261                                    if ((i + 1) < orderByFields.length) {
2262                                            if (orderByComparator.isAscending() ^ previous) {
2263                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2264                                            }
2265                                            else {
2266                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2267                                            }
2268                                    }
2269                                    else {
2270                                            if (orderByComparator.isAscending() ^ previous) {
2271                                                    query.append(ORDER_BY_ASC);
2272                                            }
2273                                            else {
2274                                                    query.append(ORDER_BY_DESC);
2275                                            }
2276                                    }
2277                            }
2278                    }
2279                    else {
2280                            query.append(DDMContentModelImpl.ORDER_BY_JPQL);
2281                    }
2282    
2283                    String sql = query.toString();
2284    
2285                    Query q = session.createQuery(sql);
2286    
2287                    q.setFirstResult(0);
2288                    q.setMaxResults(2);
2289    
2290                    QueryPos qPos = QueryPos.getInstance(q);
2291    
2292                    qPos.add(companyId);
2293    
2294                    if (orderByComparator != null) {
2295                            Object[] values = orderByComparator.getOrderByConditionValues(ddmContent);
2296    
2297                            for (Object value : values) {
2298                                    qPos.add(value);
2299                            }
2300                    }
2301    
2302                    List<DDMContent> list = q.list();
2303    
2304                    if (list.size() == 2) {
2305                            return list.get(1);
2306                    }
2307                    else {
2308                            return null;
2309                    }
2310            }
2311    
2312            /**
2313             * Removes all the d d m contents where companyId = &#63; from the database.
2314             *
2315             * @param companyId the company ID
2316             */
2317            @Override
2318            public void removeByCompanyId(long companyId) {
2319                    for (DDMContent ddmContent : findByCompanyId(companyId,
2320                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2321                            remove(ddmContent);
2322                    }
2323            }
2324    
2325            /**
2326             * Returns the number of d d m contents where companyId = &#63;.
2327             *
2328             * @param companyId the company ID
2329             * @return the number of matching d d m contents
2330             */
2331            @Override
2332            public int countByCompanyId(long companyId) {
2333                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2334    
2335                    Object[] finderArgs = new Object[] { companyId };
2336    
2337                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2338                                    this);
2339    
2340                    if (count == null) {
2341                            StringBundler query = new StringBundler(2);
2342    
2343                            query.append(_SQL_COUNT_DDMCONTENT_WHERE);
2344    
2345                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2346    
2347                            String sql = query.toString();
2348    
2349                            Session session = null;
2350    
2351                            try {
2352                                    session = openSession();
2353    
2354                                    Query q = session.createQuery(sql);
2355    
2356                                    QueryPos qPos = QueryPos.getInstance(q);
2357    
2358                                    qPos.add(companyId);
2359    
2360                                    count = (Long)q.uniqueResult();
2361    
2362                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2363                            }
2364                            catch (Exception e) {
2365                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2366    
2367                                    throw processException(e);
2368                            }
2369                            finally {
2370                                    closeSession(session);
2371                            }
2372                    }
2373    
2374                    return count.intValue();
2375            }
2376    
2377            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "ddmContent.companyId = ?";
2378    
2379            public DDMContentPersistenceImpl() {
2380                    setModelClass(DDMContent.class);
2381            }
2382    
2383            /**
2384             * Caches the d d m content in the entity cache if it is enabled.
2385             *
2386             * @param ddmContent the d d m content
2387             */
2388            @Override
2389            public void cacheResult(DDMContent ddmContent) {
2390                    EntityCacheUtil.putResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2391                            DDMContentImpl.class, ddmContent.getPrimaryKey(), ddmContent);
2392    
2393                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2394                            new Object[] { ddmContent.getUuid(), ddmContent.getGroupId() },
2395                            ddmContent);
2396    
2397                    ddmContent.resetOriginalValues();
2398            }
2399    
2400            /**
2401             * Caches the d d m contents in the entity cache if it is enabled.
2402             *
2403             * @param ddmContents the d d m contents
2404             */
2405            @Override
2406            public void cacheResult(List<DDMContent> ddmContents) {
2407                    for (DDMContent ddmContent : ddmContents) {
2408                            if (EntityCacheUtil.getResult(
2409                                                    DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2410                                                    DDMContentImpl.class, ddmContent.getPrimaryKey()) == null) {
2411                                    cacheResult(ddmContent);
2412                            }
2413                            else {
2414                                    ddmContent.resetOriginalValues();
2415                            }
2416                    }
2417            }
2418    
2419            /**
2420             * Clears the cache for all d d m contents.
2421             *
2422             * <p>
2423             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2424             * </p>
2425             */
2426            @Override
2427            public void clearCache() {
2428                    EntityCacheUtil.clearCache(DDMContentImpl.class);
2429    
2430                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2431                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2432                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2433            }
2434    
2435            /**
2436             * Clears the cache for the d d m content.
2437             *
2438             * <p>
2439             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2440             * </p>
2441             */
2442            @Override
2443            public void clearCache(DDMContent ddmContent) {
2444                    EntityCacheUtil.removeResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2445                            DDMContentImpl.class, ddmContent.getPrimaryKey());
2446    
2447                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2448                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2449    
2450                    clearUniqueFindersCache(ddmContent);
2451            }
2452    
2453            @Override
2454            public void clearCache(List<DDMContent> ddmContents) {
2455                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2456                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2457    
2458                    for (DDMContent ddmContent : ddmContents) {
2459                            EntityCacheUtil.removeResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2460                                    DDMContentImpl.class, ddmContent.getPrimaryKey());
2461    
2462                            clearUniqueFindersCache(ddmContent);
2463                    }
2464            }
2465    
2466            protected void cacheUniqueFindersCache(DDMContent ddmContent) {
2467                    if (ddmContent.isNew()) {
2468                            Object[] args = new Object[] {
2469                                            ddmContent.getUuid(), ddmContent.getGroupId()
2470                                    };
2471    
2472                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2473                                    Long.valueOf(1));
2474                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2475                                    ddmContent);
2476                    }
2477                    else {
2478                            DDMContentModelImpl ddmContentModelImpl = (DDMContentModelImpl)ddmContent;
2479    
2480                            if ((ddmContentModelImpl.getColumnBitmask() &
2481                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2482                                    Object[] args = new Object[] {
2483                                                    ddmContent.getUuid(), ddmContent.getGroupId()
2484                                            };
2485    
2486                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2487                                            Long.valueOf(1));
2488                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2489                                            ddmContent);
2490                            }
2491                    }
2492            }
2493    
2494            protected void clearUniqueFindersCache(DDMContent ddmContent) {
2495                    DDMContentModelImpl ddmContentModelImpl = (DDMContentModelImpl)ddmContent;
2496    
2497                    Object[] args = new Object[] {
2498                                    ddmContent.getUuid(), ddmContent.getGroupId()
2499                            };
2500    
2501                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2502                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2503    
2504                    if ((ddmContentModelImpl.getColumnBitmask() &
2505                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2506                            args = new Object[] {
2507                                            ddmContentModelImpl.getOriginalUuid(),
2508                                            ddmContentModelImpl.getOriginalGroupId()
2509                                    };
2510    
2511                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2512                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2513                    }
2514            }
2515    
2516            /**
2517             * Creates a new d d m content with the primary key. Does not add the d d m content to the database.
2518             *
2519             * @param contentId the primary key for the new d d m content
2520             * @return the new d d m content
2521             */
2522            @Override
2523            public DDMContent create(long contentId) {
2524                    DDMContent ddmContent = new DDMContentImpl();
2525    
2526                    ddmContent.setNew(true);
2527                    ddmContent.setPrimaryKey(contentId);
2528    
2529                    String uuid = PortalUUIDUtil.generate();
2530    
2531                    ddmContent.setUuid(uuid);
2532    
2533                    return ddmContent;
2534            }
2535    
2536            /**
2537             * Removes the d d m content with the primary key from the database. Also notifies the appropriate model listeners.
2538             *
2539             * @param contentId the primary key of the d d m content
2540             * @return the d d m content that was removed
2541             * @throws NoSuchContentException if a d d m content with the primary key could not be found
2542             */
2543            @Override
2544            public DDMContent remove(long contentId) throws NoSuchContentException {
2545                    return remove((Serializable)contentId);
2546            }
2547    
2548            /**
2549             * Removes the d d m content with the primary key from the database. Also notifies the appropriate model listeners.
2550             *
2551             * @param primaryKey the primary key of the d d m content
2552             * @return the d d m content that was removed
2553             * @throws NoSuchContentException if a d d m content with the primary key could not be found
2554             */
2555            @Override
2556            public DDMContent remove(Serializable primaryKey)
2557                    throws NoSuchContentException {
2558                    Session session = null;
2559    
2560                    try {
2561                            session = openSession();
2562    
2563                            DDMContent ddmContent = (DDMContent)session.get(DDMContentImpl.class,
2564                                            primaryKey);
2565    
2566                            if (ddmContent == null) {
2567                                    if (_log.isWarnEnabled()) {
2568                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2569                                    }
2570    
2571                                    throw new NoSuchContentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2572                                            primaryKey);
2573                            }
2574    
2575                            return remove(ddmContent);
2576                    }
2577                    catch (NoSuchContentException nsee) {
2578                            throw nsee;
2579                    }
2580                    catch (Exception e) {
2581                            throw processException(e);
2582                    }
2583                    finally {
2584                            closeSession(session);
2585                    }
2586            }
2587    
2588            @Override
2589            protected DDMContent removeImpl(DDMContent ddmContent) {
2590                    ddmContent = toUnwrappedModel(ddmContent);
2591    
2592                    Session session = null;
2593    
2594                    try {
2595                            session = openSession();
2596    
2597                            if (!session.contains(ddmContent)) {
2598                                    ddmContent = (DDMContent)session.get(DDMContentImpl.class,
2599                                                    ddmContent.getPrimaryKeyObj());
2600                            }
2601    
2602                            if (ddmContent != null) {
2603                                    session.delete(ddmContent);
2604                            }
2605                    }
2606                    catch (Exception e) {
2607                            throw processException(e);
2608                    }
2609                    finally {
2610                            closeSession(session);
2611                    }
2612    
2613                    if (ddmContent != null) {
2614                            clearCache(ddmContent);
2615                    }
2616    
2617                    return ddmContent;
2618            }
2619    
2620            @Override
2621            public DDMContent updateImpl(DDMContent ddmContent) {
2622                    ddmContent = toUnwrappedModel(ddmContent);
2623    
2624                    boolean isNew = ddmContent.isNew();
2625    
2626                    DDMContentModelImpl ddmContentModelImpl = (DDMContentModelImpl)ddmContent;
2627    
2628                    if (Validator.isNull(ddmContent.getUuid())) {
2629                            String uuid = PortalUUIDUtil.generate();
2630    
2631                            ddmContent.setUuid(uuid);
2632                    }
2633    
2634                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2635    
2636                    Date now = new Date();
2637    
2638                    if (isNew && (ddmContent.getCreateDate() == null)) {
2639                            if (serviceContext == null) {
2640                                    ddmContent.setCreateDate(now);
2641                            }
2642                            else {
2643                                    ddmContent.setCreateDate(serviceContext.getCreateDate(now));
2644                            }
2645                    }
2646    
2647                    if (!ddmContentModelImpl.hasSetModifiedDate()) {
2648                            if (serviceContext == null) {
2649                                    ddmContent.setModifiedDate(now);
2650                            }
2651                            else {
2652                                    ddmContent.setModifiedDate(serviceContext.getModifiedDate(now));
2653                            }
2654                    }
2655    
2656                    Session session = null;
2657    
2658                    try {
2659                            session = openSession();
2660    
2661                            if (ddmContent.isNew()) {
2662                                    session.save(ddmContent);
2663    
2664                                    ddmContent.setNew(false);
2665                            }
2666                            else {
2667                                    session.merge(ddmContent);
2668                            }
2669                    }
2670                    catch (Exception e) {
2671                            throw processException(e);
2672                    }
2673                    finally {
2674                            closeSession(session);
2675                    }
2676    
2677                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2678    
2679                    if (isNew || !DDMContentModelImpl.COLUMN_BITMASK_ENABLED) {
2680                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2681                    }
2682    
2683                    else {
2684                            if ((ddmContentModelImpl.getColumnBitmask() &
2685                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2686                                    Object[] args = new Object[] {
2687                                                    ddmContentModelImpl.getOriginalUuid()
2688                                            };
2689    
2690                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2691                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2692                                            args);
2693    
2694                                    args = new Object[] { ddmContentModelImpl.getUuid() };
2695    
2696                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2697                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2698                                            args);
2699                            }
2700    
2701                            if ((ddmContentModelImpl.getColumnBitmask() &
2702                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2703                                    Object[] args = new Object[] {
2704                                                    ddmContentModelImpl.getOriginalUuid(),
2705                                                    ddmContentModelImpl.getOriginalCompanyId()
2706                                            };
2707    
2708                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2709                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2710                                            args);
2711    
2712                                    args = new Object[] {
2713                                                    ddmContentModelImpl.getUuid(),
2714                                                    ddmContentModelImpl.getCompanyId()
2715                                            };
2716    
2717                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2718                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2719                                            args);
2720                            }
2721    
2722                            if ((ddmContentModelImpl.getColumnBitmask() &
2723                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2724                                    Object[] args = new Object[] {
2725                                                    ddmContentModelImpl.getOriginalGroupId()
2726                                            };
2727    
2728                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2729                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2730                                            args);
2731    
2732                                    args = new Object[] { ddmContentModelImpl.getGroupId() };
2733    
2734                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2735                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2736                                            args);
2737                            }
2738    
2739                            if ((ddmContentModelImpl.getColumnBitmask() &
2740                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2741                                    Object[] args = new Object[] {
2742                                                    ddmContentModelImpl.getOriginalCompanyId()
2743                                            };
2744    
2745                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2746                                            args);
2747                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2748                                            args);
2749    
2750                                    args = new Object[] { ddmContentModelImpl.getCompanyId() };
2751    
2752                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2753                                            args);
2754                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2755                                            args);
2756                            }
2757                    }
2758    
2759                    EntityCacheUtil.putResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2760                            DDMContentImpl.class, ddmContent.getPrimaryKey(), ddmContent, false);
2761    
2762                    clearUniqueFindersCache(ddmContent);
2763                    cacheUniqueFindersCache(ddmContent);
2764    
2765                    ddmContent.resetOriginalValues();
2766    
2767                    return ddmContent;
2768            }
2769    
2770            protected DDMContent toUnwrappedModel(DDMContent ddmContent) {
2771                    if (ddmContent instanceof DDMContentImpl) {
2772                            return ddmContent;
2773                    }
2774    
2775                    DDMContentImpl ddmContentImpl = new DDMContentImpl();
2776    
2777                    ddmContentImpl.setNew(ddmContent.isNew());
2778                    ddmContentImpl.setPrimaryKey(ddmContent.getPrimaryKey());
2779    
2780                    ddmContentImpl.setUuid(ddmContent.getUuid());
2781                    ddmContentImpl.setContentId(ddmContent.getContentId());
2782                    ddmContentImpl.setGroupId(ddmContent.getGroupId());
2783                    ddmContentImpl.setCompanyId(ddmContent.getCompanyId());
2784                    ddmContentImpl.setUserId(ddmContent.getUserId());
2785                    ddmContentImpl.setUserName(ddmContent.getUserName());
2786                    ddmContentImpl.setCreateDate(ddmContent.getCreateDate());
2787                    ddmContentImpl.setModifiedDate(ddmContent.getModifiedDate());
2788                    ddmContentImpl.setName(ddmContent.getName());
2789                    ddmContentImpl.setDescription(ddmContent.getDescription());
2790                    ddmContentImpl.setData(ddmContent.getData());
2791    
2792                    return ddmContentImpl;
2793            }
2794    
2795            /**
2796             * Returns the d d m content with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2797             *
2798             * @param primaryKey the primary key of the d d m content
2799             * @return the d d m content
2800             * @throws NoSuchContentException if a d d m content with the primary key could not be found
2801             */
2802            @Override
2803            public DDMContent findByPrimaryKey(Serializable primaryKey)
2804                    throws NoSuchContentException {
2805                    DDMContent ddmContent = fetchByPrimaryKey(primaryKey);
2806    
2807                    if (ddmContent == null) {
2808                            if (_log.isWarnEnabled()) {
2809                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2810                            }
2811    
2812                            throw new NoSuchContentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2813                                    primaryKey);
2814                    }
2815    
2816                    return ddmContent;
2817            }
2818    
2819            /**
2820             * Returns the d d m content with the primary key or throws a {@link NoSuchContentException} if it could not be found.
2821             *
2822             * @param contentId the primary key of the d d m content
2823             * @return the d d m content
2824             * @throws NoSuchContentException if a d d m content with the primary key could not be found
2825             */
2826            @Override
2827            public DDMContent findByPrimaryKey(long contentId)
2828                    throws NoSuchContentException {
2829                    return findByPrimaryKey((Serializable)contentId);
2830            }
2831    
2832            /**
2833             * Returns the d d m content with the primary key or returns <code>null</code> if it could not be found.
2834             *
2835             * @param primaryKey the primary key of the d d m content
2836             * @return the d d m content, or <code>null</code> if a d d m content with the primary key could not be found
2837             */
2838            @Override
2839            public DDMContent fetchByPrimaryKey(Serializable primaryKey) {
2840                    DDMContent ddmContent = (DDMContent)EntityCacheUtil.getResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2841                                    DDMContentImpl.class, primaryKey);
2842    
2843                    if (ddmContent == _nullDDMContent) {
2844                            return null;
2845                    }
2846    
2847                    if (ddmContent == null) {
2848                            Session session = null;
2849    
2850                            try {
2851                                    session = openSession();
2852    
2853                                    ddmContent = (DDMContent)session.get(DDMContentImpl.class,
2854                                                    primaryKey);
2855    
2856                                    if (ddmContent != null) {
2857                                            cacheResult(ddmContent);
2858                                    }
2859                                    else {
2860                                            EntityCacheUtil.putResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2861                                                    DDMContentImpl.class, primaryKey, _nullDDMContent);
2862                                    }
2863                            }
2864                            catch (Exception e) {
2865                                    EntityCacheUtil.removeResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2866                                            DDMContentImpl.class, primaryKey);
2867    
2868                                    throw processException(e);
2869                            }
2870                            finally {
2871                                    closeSession(session);
2872                            }
2873                    }
2874    
2875                    return ddmContent;
2876            }
2877    
2878            /**
2879             * Returns the d d m content with the primary key or returns <code>null</code> if it could not be found.
2880             *
2881             * @param contentId the primary key of the d d m content
2882             * @return the d d m content, or <code>null</code> if a d d m content with the primary key could not be found
2883             */
2884            @Override
2885            public DDMContent fetchByPrimaryKey(long contentId) {
2886                    return fetchByPrimaryKey((Serializable)contentId);
2887            }
2888    
2889            @Override
2890            public Map<Serializable, DDMContent> fetchByPrimaryKeys(
2891                    Set<Serializable> primaryKeys) {
2892                    if (primaryKeys.isEmpty()) {
2893                            return Collections.emptyMap();
2894                    }
2895    
2896                    Map<Serializable, DDMContent> map = new HashMap<Serializable, DDMContent>();
2897    
2898                    if (primaryKeys.size() == 1) {
2899                            Iterator<Serializable> iterator = primaryKeys.iterator();
2900    
2901                            Serializable primaryKey = iterator.next();
2902    
2903                            DDMContent ddmContent = fetchByPrimaryKey(primaryKey);
2904    
2905                            if (ddmContent != null) {
2906                                    map.put(primaryKey, ddmContent);
2907                            }
2908    
2909                            return map;
2910                    }
2911    
2912                    Set<Serializable> uncachedPrimaryKeys = null;
2913    
2914                    for (Serializable primaryKey : primaryKeys) {
2915                            DDMContent ddmContent = (DDMContent)EntityCacheUtil.getResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2916                                            DDMContentImpl.class, primaryKey);
2917    
2918                            if (ddmContent == null) {
2919                                    if (uncachedPrimaryKeys == null) {
2920                                            uncachedPrimaryKeys = new HashSet<Serializable>();
2921                                    }
2922    
2923                                    uncachedPrimaryKeys.add(primaryKey);
2924                            }
2925                            else {
2926                                    map.put(primaryKey, ddmContent);
2927                            }
2928                    }
2929    
2930                    if (uncachedPrimaryKeys == null) {
2931                            return map;
2932                    }
2933    
2934                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2935                                    1);
2936    
2937                    query.append(_SQL_SELECT_DDMCONTENT_WHERE_PKS_IN);
2938    
2939                    for (Serializable primaryKey : uncachedPrimaryKeys) {
2940                            query.append(String.valueOf(primaryKey));
2941    
2942                            query.append(StringPool.COMMA);
2943                    }
2944    
2945                    query.setIndex(query.index() - 1);
2946    
2947                    query.append(StringPool.CLOSE_PARENTHESIS);
2948    
2949                    String sql = query.toString();
2950    
2951                    Session session = null;
2952    
2953                    try {
2954                            session = openSession();
2955    
2956                            Query q = session.createQuery(sql);
2957    
2958                            for (DDMContent ddmContent : (List<DDMContent>)q.list()) {
2959                                    map.put(ddmContent.getPrimaryKeyObj(), ddmContent);
2960    
2961                                    cacheResult(ddmContent);
2962    
2963                                    uncachedPrimaryKeys.remove(ddmContent.getPrimaryKeyObj());
2964                            }
2965    
2966                            for (Serializable primaryKey : uncachedPrimaryKeys) {
2967                                    EntityCacheUtil.putResult(DDMContentModelImpl.ENTITY_CACHE_ENABLED,
2968                                            DDMContentImpl.class, primaryKey, _nullDDMContent);
2969                            }
2970                    }
2971                    catch (Exception e) {
2972                            throw processException(e);
2973                    }
2974                    finally {
2975                            closeSession(session);
2976                    }
2977    
2978                    return map;
2979            }
2980    
2981            /**
2982             * Returns all the d d m contents.
2983             *
2984             * @return the d d m contents
2985             */
2986            @Override
2987            public List<DDMContent> findAll() {
2988                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2989            }
2990    
2991            /**
2992             * Returns a range of all the d d m contents.
2993             *
2994             * <p>
2995             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
2996             * </p>
2997             *
2998             * @param start the lower bound of the range of d d m contents
2999             * @param end the upper bound of the range of d d m contents (not inclusive)
3000             * @return the range of d d m contents
3001             */
3002            @Override
3003            public List<DDMContent> findAll(int start, int end) {
3004                    return findAll(start, end, null);
3005            }
3006    
3007            /**
3008             * Returns an ordered range of all the d d m contents.
3009             *
3010             * <p>
3011             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDMContentModelImpl}. 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.
3012             * </p>
3013             *
3014             * @param start the lower bound of the range of d d m contents
3015             * @param end the upper bound of the range of d d m contents (not inclusive)
3016             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3017             * @return the ordered range of d d m contents
3018             */
3019            @Override
3020            public List<DDMContent> findAll(int start, int end,
3021                    OrderByComparator<DDMContent> orderByComparator) {
3022                    boolean pagination = true;
3023                    FinderPath finderPath = null;
3024                    Object[] finderArgs = null;
3025    
3026                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3027                                    (orderByComparator == null)) {
3028                            pagination = false;
3029                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3030                            finderArgs = FINDER_ARGS_EMPTY;
3031                    }
3032                    else {
3033                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3034                            finderArgs = new Object[] { start, end, orderByComparator };
3035                    }
3036    
3037                    List<DDMContent> list = (List<DDMContent>)FinderCacheUtil.getResult(finderPath,
3038                                    finderArgs, this);
3039    
3040                    if (list == null) {
3041                            StringBundler query = null;
3042                            String sql = null;
3043    
3044                            if (orderByComparator != null) {
3045                                    query = new StringBundler(2 +
3046                                                    (orderByComparator.getOrderByFields().length * 3));
3047    
3048                                    query.append(_SQL_SELECT_DDMCONTENT);
3049    
3050                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3051                                            orderByComparator);
3052    
3053                                    sql = query.toString();
3054                            }
3055                            else {
3056                                    sql = _SQL_SELECT_DDMCONTENT;
3057    
3058                                    if (pagination) {
3059                                            sql = sql.concat(DDMContentModelImpl.ORDER_BY_JPQL);
3060                                    }
3061                            }
3062    
3063                            Session session = null;
3064    
3065                            try {
3066                                    session = openSession();
3067    
3068                                    Query q = session.createQuery(sql);
3069    
3070                                    if (!pagination) {
3071                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
3072                                                            start, end, false);
3073    
3074                                            Collections.sort(list);
3075    
3076                                            list = Collections.unmodifiableList(list);
3077                                    }
3078                                    else {
3079                                            list = (List<DDMContent>)QueryUtil.list(q, getDialect(),
3080                                                            start, end);
3081                                    }
3082    
3083                                    cacheResult(list);
3084    
3085                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3086                            }
3087                            catch (Exception e) {
3088                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3089    
3090                                    throw processException(e);
3091                            }
3092                            finally {
3093                                    closeSession(session);
3094                            }
3095                    }
3096    
3097                    return list;
3098            }
3099    
3100            /**
3101             * Removes all the d d m contents from the database.
3102             *
3103             */
3104            @Override
3105            public void removeAll() {
3106                    for (DDMContent ddmContent : findAll()) {
3107                            remove(ddmContent);
3108                    }
3109            }
3110    
3111            /**
3112             * Returns the number of d d m contents.
3113             *
3114             * @return the number of d d m contents
3115             */
3116            @Override
3117            public int countAll() {
3118                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3119                                    FINDER_ARGS_EMPTY, this);
3120    
3121                    if (count == null) {
3122                            Session session = null;
3123    
3124                            try {
3125                                    session = openSession();
3126    
3127                                    Query q = session.createQuery(_SQL_COUNT_DDMCONTENT);
3128    
3129                                    count = (Long)q.uniqueResult();
3130    
3131                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3132                                            FINDER_ARGS_EMPTY, count);
3133                            }
3134                            catch (Exception e) {
3135                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3136                                            FINDER_ARGS_EMPTY);
3137    
3138                                    throw processException(e);
3139                            }
3140                            finally {
3141                                    closeSession(session);
3142                            }
3143                    }
3144    
3145                    return count.intValue();
3146            }
3147    
3148            @Override
3149            protected Set<String> getBadColumnNames() {
3150                    return _badColumnNames;
3151            }
3152    
3153            /**
3154             * Initializes the d d m content persistence.
3155             */
3156            public void afterPropertiesSet() {
3157            }
3158    
3159            public void destroy() {
3160                    EntityCacheUtil.removeCache(DDMContentImpl.class.getName());
3161                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3162                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3163                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3164            }
3165    
3166            private static final String _SQL_SELECT_DDMCONTENT = "SELECT ddmContent FROM DDMContent ddmContent";
3167            private static final String _SQL_SELECT_DDMCONTENT_WHERE_PKS_IN = "SELECT ddmContent FROM DDMContent ddmContent WHERE contentId IN (";
3168            private static final String _SQL_SELECT_DDMCONTENT_WHERE = "SELECT ddmContent FROM DDMContent ddmContent WHERE ";
3169            private static final String _SQL_COUNT_DDMCONTENT = "SELECT COUNT(ddmContent) FROM DDMContent ddmContent";
3170            private static final String _SQL_COUNT_DDMCONTENT_WHERE = "SELECT COUNT(ddmContent) FROM DDMContent ddmContent WHERE ";
3171            private static final String _ORDER_BY_ENTITY_ALIAS = "ddmContent.";
3172            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMContent exists with the primary key ";
3173            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMContent exists with the key {";
3174            private static final Log _log = LogFactoryUtil.getLog(DDMContentPersistenceImpl.class);
3175            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3176                                    "uuid", "data"
3177                            });
3178            private static final DDMContent _nullDDMContent = new DDMContentImpl() {
3179                            @Override
3180                            public Object clone() {
3181                                    return this;
3182                            }
3183    
3184                            @Override
3185                            public CacheModel<DDMContent> toCacheModel() {
3186                                    return _nullDDMContentCacheModel;
3187                            }
3188                    };
3189    
3190            private static final CacheModel<DDMContent> _nullDDMContentCacheModel = new CacheModel<DDMContent>() {
3191                            @Override
3192                            public DDMContent toEntityModel() {
3193                                    return _nullDDMContent;
3194                            }
3195                    };
3196    }