001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.BatchSessionUtil;
041    import com.liferay.portal.service.persistence.ResourcePersistence;
042    import com.liferay.portal.service.persistence.UserPersistence;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.journal.NoSuchArticleResourceException;
046    import com.liferay.portlet.journal.model.JournalArticleResource;
047    import com.liferay.portlet.journal.model.impl.JournalArticleResourceImpl;
048    import com.liferay.portlet.journal.model.impl.JournalArticleResourceModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the journal article resource 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 JournalArticleResourcePersistence
065     * @see JournalArticleResourceUtil
066     * @generated
067     */
068    public class JournalArticleResourcePersistenceImpl extends BasePersistenceImpl<JournalArticleResource>
069            implements JournalArticleResourcePersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link JournalArticleResourceUtil} to access the journal article resource persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleResourceImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
081                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
082                            JournalArticleResourceImpl.class,
083                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
084                            new String[] {
085                                    String.class.getName(),
086                                    
087                            "java.lang.Integer", "java.lang.Integer",
088                                    "com.liferay.portal.kernel.util.OrderByComparator"
089                            });
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
091                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
092                            JournalArticleResourceImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094                            new String[] { String.class.getName() },
095                            JournalArticleResourceModelImpl.UUID_COLUMN_BITMASK);
096            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
097                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099                            new String[] { String.class.getName() });
100            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
101                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
102                            JournalArticleResourceImpl.class, FINDER_CLASS_NAME_ENTITY,
103                            "fetchByUUID_G",
104                            new String[] { String.class.getName(), Long.class.getName() },
105                            JournalArticleResourceModelImpl.UUID_COLUMN_BITMASK |
106                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
108                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
110                            new String[] { String.class.getName(), Long.class.getName() });
111            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
112                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
113                            JournalArticleResourceImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
115                            new String[] {
116                                    Long.class.getName(),
117                                    
118                            "java.lang.Integer", "java.lang.Integer",
119                                    "com.liferay.portal.kernel.util.OrderByComparator"
120                            });
121            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
122                    new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
123                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
124                            JournalArticleResourceImpl.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
126                            new String[] { Long.class.getName() },
127                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK);
128            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
129                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
130                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
131                            new String[] { Long.class.getName() });
132            public static final FinderPath FINDER_PATH_FETCH_BY_G_A = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
133                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
134                            JournalArticleResourceImpl.class, FINDER_CLASS_NAME_ENTITY,
135                            "fetchByG_A",
136                            new String[] { Long.class.getName(), String.class.getName() },
137                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK |
138                            JournalArticleResourceModelImpl.ARTICLEID_COLUMN_BITMASK);
139            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
140                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
142                            new String[] { Long.class.getName(), String.class.getName() });
143            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
144                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
145                            JournalArticleResourceImpl.class,
146                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
147            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
148                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
149                            JournalArticleResourceImpl.class,
150                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
151            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
152                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
154    
155            /**
156             * Caches the journal article resource in the entity cache if it is enabled.
157             *
158             * @param journalArticleResource the journal article resource
159             */
160            public void cacheResult(JournalArticleResource journalArticleResource) {
161                    EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
162                            JournalArticleResourceImpl.class,
163                            journalArticleResource.getPrimaryKey(), journalArticleResource);
164    
165                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
166                            new Object[] {
167                                    journalArticleResource.getUuid(),
168                                    Long.valueOf(journalArticleResource.getGroupId())
169                            }, journalArticleResource);
170    
171                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
172                            new Object[] {
173                                    Long.valueOf(journalArticleResource.getGroupId()),
174                                    
175                            journalArticleResource.getArticleId()
176                            }, journalArticleResource);
177    
178                    journalArticleResource.resetOriginalValues();
179            }
180    
181            /**
182             * Caches the journal article resources in the entity cache if it is enabled.
183             *
184             * @param journalArticleResources the journal article resources
185             */
186            public void cacheResult(
187                    List<JournalArticleResource> journalArticleResources) {
188                    for (JournalArticleResource journalArticleResource : journalArticleResources) {
189                            if (EntityCacheUtil.getResult(
190                                                    JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
191                                                    JournalArticleResourceImpl.class,
192                                                    journalArticleResource.getPrimaryKey()) == null) {
193                                    cacheResult(journalArticleResource);
194                            }
195                            else {
196                                    journalArticleResource.resetOriginalValues();
197                            }
198                    }
199            }
200    
201            /**
202             * Clears the cache for all journal article resources.
203             *
204             * <p>
205             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
206             * </p>
207             */
208            @Override
209            public void clearCache() {
210                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
211                            CacheRegistryUtil.clear(JournalArticleResourceImpl.class.getName());
212                    }
213    
214                    EntityCacheUtil.clearCache(JournalArticleResourceImpl.class.getName());
215    
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
218                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
219            }
220    
221            /**
222             * Clears the cache for the journal article resource.
223             *
224             * <p>
225             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
226             * </p>
227             */
228            @Override
229            public void clearCache(JournalArticleResource journalArticleResource) {
230                    EntityCacheUtil.removeResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
231                            JournalArticleResourceImpl.class,
232                            journalArticleResource.getPrimaryKey());
233    
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
235                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
236    
237                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
238                            new Object[] {
239                                    journalArticleResource.getUuid(),
240                                    Long.valueOf(journalArticleResource.getGroupId())
241                            });
242    
243                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A,
244                            new Object[] {
245                                    Long.valueOf(journalArticleResource.getGroupId()),
246                                    
247                            journalArticleResource.getArticleId()
248                            });
249            }
250    
251            /**
252             * Creates a new journal article resource with the primary key. Does not add the journal article resource to the database.
253             *
254             * @param resourcePrimKey the primary key for the new journal article resource
255             * @return the new journal article resource
256             */
257            public JournalArticleResource create(long resourcePrimKey) {
258                    JournalArticleResource journalArticleResource = new JournalArticleResourceImpl();
259    
260                    journalArticleResource.setNew(true);
261                    journalArticleResource.setPrimaryKey(resourcePrimKey);
262    
263                    String uuid = PortalUUIDUtil.generate();
264    
265                    journalArticleResource.setUuid(uuid);
266    
267                    return journalArticleResource;
268            }
269    
270            /**
271             * Removes the journal article resource with the primary key from the database. Also notifies the appropriate model listeners.
272             *
273             * @param primaryKey the primary key of the journal article resource
274             * @return the journal article resource that was removed
275             * @throws com.liferay.portal.NoSuchModelException if a journal article resource with the primary key could not be found
276             * @throws SystemException if a system exception occurred
277             */
278            @Override
279            public JournalArticleResource remove(Serializable primaryKey)
280                    throws NoSuchModelException, SystemException {
281                    return remove(((Long)primaryKey).longValue());
282            }
283    
284            /**
285             * Removes the journal article resource with the primary key from the database. Also notifies the appropriate model listeners.
286             *
287             * @param resourcePrimKey the primary key of the journal article resource
288             * @return the journal article resource that was removed
289             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
290             * @throws SystemException if a system exception occurred
291             */
292            public JournalArticleResource remove(long resourcePrimKey)
293                    throws NoSuchArticleResourceException, SystemException {
294                    Session session = null;
295    
296                    try {
297                            session = openSession();
298    
299                            JournalArticleResource journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
300                                            Long.valueOf(resourcePrimKey));
301    
302                            if (journalArticleResource == null) {
303                                    if (_log.isWarnEnabled()) {
304                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
305                                                    resourcePrimKey);
306                                    }
307    
308                                    throw new NoSuchArticleResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
309                                            resourcePrimKey);
310                            }
311    
312                            return journalArticleResourcePersistence.remove(journalArticleResource);
313                    }
314                    catch (NoSuchArticleResourceException nsee) {
315                            throw nsee;
316                    }
317                    catch (Exception e) {
318                            throw processException(e);
319                    }
320                    finally {
321                            closeSession(session);
322                    }
323            }
324    
325            /**
326             * Removes the journal article resource from the database. Also notifies the appropriate model listeners.
327             *
328             * @param journalArticleResource the journal article resource
329             * @return the journal article resource that was removed
330             * @throws SystemException if a system exception occurred
331             */
332            @Override
333            public JournalArticleResource remove(
334                    JournalArticleResource journalArticleResource)
335                    throws SystemException {
336                    return super.remove(journalArticleResource);
337            }
338    
339            @Override
340            protected JournalArticleResource removeImpl(
341                    JournalArticleResource journalArticleResource)
342                    throws SystemException {
343                    journalArticleResource = toUnwrappedModel(journalArticleResource);
344    
345                    Session session = null;
346    
347                    try {
348                            session = openSession();
349    
350                            BatchSessionUtil.delete(session, journalArticleResource);
351                    }
352                    catch (Exception e) {
353                            throw processException(e);
354                    }
355                    finally {
356                            closeSession(session);
357                    }
358    
359                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
360                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
361    
362                    JournalArticleResourceModelImpl journalArticleResourceModelImpl = (JournalArticleResourceModelImpl)journalArticleResource;
363    
364                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
365                            new Object[] {
366                                    journalArticleResourceModelImpl.getUuid(),
367                                    Long.valueOf(journalArticleResourceModelImpl.getGroupId())
368                            });
369    
370                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A,
371                            new Object[] {
372                                    Long.valueOf(journalArticleResourceModelImpl.getGroupId()),
373                                    
374                            journalArticleResourceModelImpl.getArticleId()
375                            });
376    
377                    EntityCacheUtil.removeResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
378                            JournalArticleResourceImpl.class,
379                            journalArticleResource.getPrimaryKey());
380    
381                    return journalArticleResource;
382            }
383    
384            @Override
385            public JournalArticleResource updateImpl(
386                    com.liferay.portlet.journal.model.JournalArticleResource journalArticleResource,
387                    boolean merge) throws SystemException {
388                    journalArticleResource = toUnwrappedModel(journalArticleResource);
389    
390                    boolean isNew = journalArticleResource.isNew();
391    
392                    JournalArticleResourceModelImpl journalArticleResourceModelImpl = (JournalArticleResourceModelImpl)journalArticleResource;
393    
394                    if (Validator.isNull(journalArticleResource.getUuid())) {
395                            String uuid = PortalUUIDUtil.generate();
396    
397                            journalArticleResource.setUuid(uuid);
398                    }
399    
400                    Session session = null;
401    
402                    try {
403                            session = openSession();
404    
405                            BatchSessionUtil.update(session, journalArticleResource, merge);
406    
407                            journalArticleResource.setNew(false);
408                    }
409                    catch (Exception e) {
410                            throw processException(e);
411                    }
412                    finally {
413                            closeSession(session);
414                    }
415    
416                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
417    
418                    if (isNew || !JournalArticleResourceModelImpl.COLUMN_BITMASK_ENABLED) {
419                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
420                    }
421    
422                    else {
423                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
424                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
425                                    Object[] args = new Object[] {
426                                                    journalArticleResourceModelImpl.getOriginalUuid()
427                                            };
428    
429                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
430                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
431                                            args);
432    
433                                    args = new Object[] { journalArticleResourceModelImpl.getUuid() };
434    
435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
437                                            args);
438                            }
439    
440                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
441                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
442                                    Object[] args = new Object[] {
443                                                    Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId())
444                                            };
445    
446                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
448                                            args);
449    
450                                    args = new Object[] {
451                                                    Long.valueOf(journalArticleResourceModelImpl.getGroupId())
452                                            };
453    
454                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
456                                            args);
457                            }
458                    }
459    
460                    EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
461                            JournalArticleResourceImpl.class,
462                            journalArticleResource.getPrimaryKey(), journalArticleResource);
463    
464                    if (isNew) {
465                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
466                                    new Object[] {
467                                            journalArticleResource.getUuid(),
468                                            Long.valueOf(journalArticleResource.getGroupId())
469                                    }, journalArticleResource);
470    
471                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
472                                    new Object[] {
473                                            Long.valueOf(journalArticleResource.getGroupId()),
474                                            
475                                    journalArticleResource.getArticleId()
476                                    }, journalArticleResource);
477                    }
478                    else {
479                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
480                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
481                                    Object[] args = new Object[] {
482                                                    journalArticleResourceModelImpl.getOriginalUuid(),
483                                                    Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId())
484                                            };
485    
486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
487                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
488    
489                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
490                                            new Object[] {
491                                                    journalArticleResource.getUuid(),
492                                                    Long.valueOf(journalArticleResource.getGroupId())
493                                            }, journalArticleResource);
494                            }
495    
496                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
497                                            FINDER_PATH_FETCH_BY_G_A.getColumnBitmask()) != 0) {
498                                    Object[] args = new Object[] {
499                                                    Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId()),
500                                                    
501                                                    journalArticleResourceModelImpl.getOriginalArticleId()
502                                            };
503    
504                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
505                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A, args);
506    
507                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
508                                            new Object[] {
509                                                    Long.valueOf(journalArticleResource.getGroupId()),
510                                                    
511                                            journalArticleResource.getArticleId()
512                                            }, journalArticleResource);
513                            }
514                    }
515    
516                    return journalArticleResource;
517            }
518    
519            protected JournalArticleResource toUnwrappedModel(
520                    JournalArticleResource journalArticleResource) {
521                    if (journalArticleResource instanceof JournalArticleResourceImpl) {
522                            return journalArticleResource;
523                    }
524    
525                    JournalArticleResourceImpl journalArticleResourceImpl = new JournalArticleResourceImpl();
526    
527                    journalArticleResourceImpl.setNew(journalArticleResource.isNew());
528                    journalArticleResourceImpl.setPrimaryKey(journalArticleResource.getPrimaryKey());
529    
530                    journalArticleResourceImpl.setUuid(journalArticleResource.getUuid());
531                    journalArticleResourceImpl.setResourcePrimKey(journalArticleResource.getResourcePrimKey());
532                    journalArticleResourceImpl.setGroupId(journalArticleResource.getGroupId());
533                    journalArticleResourceImpl.setArticleId(journalArticleResource.getArticleId());
534    
535                    return journalArticleResourceImpl;
536            }
537    
538            /**
539             * Returns the journal article resource with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
540             *
541             * @param primaryKey the primary key of the journal article resource
542             * @return the journal article resource
543             * @throws com.liferay.portal.NoSuchModelException if a journal article resource with the primary key could not be found
544             * @throws SystemException if a system exception occurred
545             */
546            @Override
547            public JournalArticleResource findByPrimaryKey(Serializable primaryKey)
548                    throws NoSuchModelException, SystemException {
549                    return findByPrimaryKey(((Long)primaryKey).longValue());
550            }
551    
552            /**
553             * Returns the journal article resource with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
554             *
555             * @param resourcePrimKey the primary key of the journal article resource
556             * @return the journal article resource
557             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
558             * @throws SystemException if a system exception occurred
559             */
560            public JournalArticleResource findByPrimaryKey(long resourcePrimKey)
561                    throws NoSuchArticleResourceException, SystemException {
562                    JournalArticleResource journalArticleResource = fetchByPrimaryKey(resourcePrimKey);
563    
564                    if (journalArticleResource == null) {
565                            if (_log.isWarnEnabled()) {
566                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + resourcePrimKey);
567                            }
568    
569                            throw new NoSuchArticleResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
570                                    resourcePrimKey);
571                    }
572    
573                    return journalArticleResource;
574            }
575    
576            /**
577             * Returns the journal article resource with the primary key or returns <code>null</code> if it could not be found.
578             *
579             * @param primaryKey the primary key of the journal article resource
580             * @return the journal article resource, or <code>null</code> if a journal article resource with the primary key could not be found
581             * @throws SystemException if a system exception occurred
582             */
583            @Override
584            public JournalArticleResource fetchByPrimaryKey(Serializable primaryKey)
585                    throws SystemException {
586                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
587            }
588    
589            /**
590             * Returns the journal article resource with the primary key or returns <code>null</code> if it could not be found.
591             *
592             * @param resourcePrimKey the primary key of the journal article resource
593             * @return the journal article resource, or <code>null</code> if a journal article resource with the primary key could not be found
594             * @throws SystemException if a system exception occurred
595             */
596            public JournalArticleResource fetchByPrimaryKey(long resourcePrimKey)
597                    throws SystemException {
598                    JournalArticleResource journalArticleResource = (JournalArticleResource)EntityCacheUtil.getResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
599                                    JournalArticleResourceImpl.class, resourcePrimKey);
600    
601                    if (journalArticleResource == _nullJournalArticleResource) {
602                            return null;
603                    }
604    
605                    if (journalArticleResource == null) {
606                            Session session = null;
607    
608                            boolean hasException = false;
609    
610                            try {
611                                    session = openSession();
612    
613                                    journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
614                                                    Long.valueOf(resourcePrimKey));
615                            }
616                            catch (Exception e) {
617                                    hasException = true;
618    
619                                    throw processException(e);
620                            }
621                            finally {
622                                    if (journalArticleResource != null) {
623                                            cacheResult(journalArticleResource);
624                                    }
625                                    else if (!hasException) {
626                                            EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
627                                                    JournalArticleResourceImpl.class, resourcePrimKey,
628                                                    _nullJournalArticleResource);
629                                    }
630    
631                                    closeSession(session);
632                            }
633                    }
634    
635                    return journalArticleResource;
636            }
637    
638            /**
639             * Returns all the journal article resources where uuid = &#63;.
640             *
641             * @param uuid the uuid
642             * @return the matching journal article resources
643             * @throws SystemException if a system exception occurred
644             */
645            public List<JournalArticleResource> findByUuid(String uuid)
646                    throws SystemException {
647                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
648            }
649    
650            /**
651             * Returns a range of all the journal article resources where uuid = &#63;.
652             *
653             * <p>
654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
655             * </p>
656             *
657             * @param uuid the uuid
658             * @param start the lower bound of the range of journal article resources
659             * @param end the upper bound of the range of journal article resources (not inclusive)
660             * @return the range of matching journal article resources
661             * @throws SystemException if a system exception occurred
662             */
663            public List<JournalArticleResource> findByUuid(String uuid, int start,
664                    int end) throws SystemException {
665                    return findByUuid(uuid, start, end, null);
666            }
667    
668            /**
669             * Returns an ordered range of all the journal article resources where uuid = &#63;.
670             *
671             * <p>
672             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
673             * </p>
674             *
675             * @param uuid the uuid
676             * @param start the lower bound of the range of journal article resources
677             * @param end the upper bound of the range of journal article resources (not inclusive)
678             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
679             * @return the ordered range of matching journal article resources
680             * @throws SystemException if a system exception occurred
681             */
682            public List<JournalArticleResource> findByUuid(String uuid, int start,
683                    int end, OrderByComparator orderByComparator) throws SystemException {
684                    FinderPath finderPath = null;
685                    Object[] finderArgs = null;
686    
687                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
688                                    (orderByComparator == null)) {
689                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
690                            finderArgs = new Object[] { uuid };
691                    }
692                    else {
693                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
694                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
695                    }
696    
697                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
698                                    finderArgs, this);
699    
700                    if (list == null) {
701                            StringBundler query = null;
702    
703                            if (orderByComparator != null) {
704                                    query = new StringBundler(3 +
705                                                    (orderByComparator.getOrderByFields().length * 3));
706                            }
707                            else {
708                                    query = new StringBundler(2);
709                            }
710    
711                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
712    
713                            if (uuid == null) {
714                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
715                            }
716                            else {
717                                    if (uuid.equals(StringPool.BLANK)) {
718                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
719                                    }
720                                    else {
721                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
722                                    }
723                            }
724    
725                            if (orderByComparator != null) {
726                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
727                                            orderByComparator);
728                            }
729    
730                            String sql = query.toString();
731    
732                            Session session = null;
733    
734                            try {
735                                    session = openSession();
736    
737                                    Query q = session.createQuery(sql);
738    
739                                    QueryPos qPos = QueryPos.getInstance(q);
740    
741                                    if (uuid != null) {
742                                            qPos.add(uuid);
743                                    }
744    
745                                    list = (List<JournalArticleResource>)QueryUtil.list(q,
746                                                    getDialect(), start, end);
747                            }
748                            catch (Exception e) {
749                                    throw processException(e);
750                            }
751                            finally {
752                                    if (list == null) {
753                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
754                                    }
755                                    else {
756                                            cacheResult(list);
757    
758                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
759                                    }
760    
761                                    closeSession(session);
762                            }
763                    }
764    
765                    return list;
766            }
767    
768            /**
769             * Returns the first journal article resource in the ordered set where uuid = &#63;.
770             *
771             * <p>
772             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
773             * </p>
774             *
775             * @param uuid the uuid
776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
777             * @return the first matching journal article resource
778             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
779             * @throws SystemException if a system exception occurred
780             */
781            public JournalArticleResource findByUuid_First(String uuid,
782                    OrderByComparator orderByComparator)
783                    throws NoSuchArticleResourceException, SystemException {
784                    List<JournalArticleResource> list = findByUuid(uuid, 0, 1,
785                                    orderByComparator);
786    
787                    if (list.isEmpty()) {
788                            StringBundler msg = new StringBundler(4);
789    
790                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
791    
792                            msg.append("uuid=");
793                            msg.append(uuid);
794    
795                            msg.append(StringPool.CLOSE_CURLY_BRACE);
796    
797                            throw new NoSuchArticleResourceException(msg.toString());
798                    }
799                    else {
800                            return list.get(0);
801                    }
802            }
803    
804            /**
805             * Returns the last journal article resource in the ordered set where uuid = &#63;.
806             *
807             * <p>
808             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
809             * </p>
810             *
811             * @param uuid the uuid
812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
813             * @return the last matching journal article resource
814             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
815             * @throws SystemException if a system exception occurred
816             */
817            public JournalArticleResource findByUuid_Last(String uuid,
818                    OrderByComparator orderByComparator)
819                    throws NoSuchArticleResourceException, SystemException {
820                    int count = countByUuid(uuid);
821    
822                    List<JournalArticleResource> list = findByUuid(uuid, count - 1, count,
823                                    orderByComparator);
824    
825                    if (list.isEmpty()) {
826                            StringBundler msg = new StringBundler(4);
827    
828                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
829    
830                            msg.append("uuid=");
831                            msg.append(uuid);
832    
833                            msg.append(StringPool.CLOSE_CURLY_BRACE);
834    
835                            throw new NoSuchArticleResourceException(msg.toString());
836                    }
837                    else {
838                            return list.get(0);
839                    }
840            }
841    
842            /**
843             * Returns the journal article resources before and after the current journal article resource in the ordered set where uuid = &#63;.
844             *
845             * <p>
846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
847             * </p>
848             *
849             * @param resourcePrimKey the primary key of the current journal article resource
850             * @param uuid the uuid
851             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
852             * @return the previous, current, and next journal article resource
853             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
854             * @throws SystemException if a system exception occurred
855             */
856            public JournalArticleResource[] findByUuid_PrevAndNext(
857                    long resourcePrimKey, String uuid, OrderByComparator orderByComparator)
858                    throws NoSuchArticleResourceException, SystemException {
859                    JournalArticleResource journalArticleResource = findByPrimaryKey(resourcePrimKey);
860    
861                    Session session = null;
862    
863                    try {
864                            session = openSession();
865    
866                            JournalArticleResource[] array = new JournalArticleResourceImpl[3];
867    
868                            array[0] = getByUuid_PrevAndNext(session, journalArticleResource,
869                                            uuid, orderByComparator, true);
870    
871                            array[1] = journalArticleResource;
872    
873                            array[2] = getByUuid_PrevAndNext(session, journalArticleResource,
874                                            uuid, orderByComparator, false);
875    
876                            return array;
877                    }
878                    catch (Exception e) {
879                            throw processException(e);
880                    }
881                    finally {
882                            closeSession(session);
883                    }
884            }
885    
886            protected JournalArticleResource getByUuid_PrevAndNext(Session session,
887                    JournalArticleResource journalArticleResource, String uuid,
888                    OrderByComparator orderByComparator, boolean previous) {
889                    StringBundler query = null;
890    
891                    if (orderByComparator != null) {
892                            query = new StringBundler(6 +
893                                            (orderByComparator.getOrderByFields().length * 6));
894                    }
895                    else {
896                            query = new StringBundler(3);
897                    }
898    
899                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
900    
901                    if (uuid == null) {
902                            query.append(_FINDER_COLUMN_UUID_UUID_1);
903                    }
904                    else {
905                            if (uuid.equals(StringPool.BLANK)) {
906                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
907                            }
908                            else {
909                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
910                            }
911                    }
912    
913                    if (orderByComparator != null) {
914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
915    
916                            if (orderByConditionFields.length > 0) {
917                                    query.append(WHERE_AND);
918                            }
919    
920                            for (int i = 0; i < orderByConditionFields.length; i++) {
921                                    query.append(_ORDER_BY_ENTITY_ALIAS);
922                                    query.append(orderByConditionFields[i]);
923    
924                                    if ((i + 1) < orderByConditionFields.length) {
925                                            if (orderByComparator.isAscending() ^ previous) {
926                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
927                                            }
928                                            else {
929                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
930                                            }
931                                    }
932                                    else {
933                                            if (orderByComparator.isAscending() ^ previous) {
934                                                    query.append(WHERE_GREATER_THAN);
935                                            }
936                                            else {
937                                                    query.append(WHERE_LESSER_THAN);
938                                            }
939                                    }
940                            }
941    
942                            query.append(ORDER_BY_CLAUSE);
943    
944                            String[] orderByFields = orderByComparator.getOrderByFields();
945    
946                            for (int i = 0; i < orderByFields.length; i++) {
947                                    query.append(_ORDER_BY_ENTITY_ALIAS);
948                                    query.append(orderByFields[i]);
949    
950                                    if ((i + 1) < orderByFields.length) {
951                                            if (orderByComparator.isAscending() ^ previous) {
952                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
953                                            }
954                                            else {
955                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
956                                            }
957                                    }
958                                    else {
959                                            if (orderByComparator.isAscending() ^ previous) {
960                                                    query.append(ORDER_BY_ASC);
961                                            }
962                                            else {
963                                                    query.append(ORDER_BY_DESC);
964                                            }
965                                    }
966                            }
967                    }
968    
969                    String sql = query.toString();
970    
971                    Query q = session.createQuery(sql);
972    
973                    q.setFirstResult(0);
974                    q.setMaxResults(2);
975    
976                    QueryPos qPos = QueryPos.getInstance(q);
977    
978                    if (uuid != null) {
979                            qPos.add(uuid);
980                    }
981    
982                    if (orderByComparator != null) {
983                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticleResource);
984    
985                            for (Object value : values) {
986                                    qPos.add(value);
987                            }
988                    }
989    
990                    List<JournalArticleResource> list = q.list();
991    
992                    if (list.size() == 2) {
993                            return list.get(1);
994                    }
995                    else {
996                            return null;
997                    }
998            }
999    
1000            /**
1001             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
1002             *
1003             * @param uuid the uuid
1004             * @param groupId the group ID
1005             * @return the matching journal article resource
1006             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1007             * @throws SystemException if a system exception occurred
1008             */
1009            public JournalArticleResource findByUUID_G(String uuid, long groupId)
1010                    throws NoSuchArticleResourceException, SystemException {
1011                    JournalArticleResource journalArticleResource = fetchByUUID_G(uuid,
1012                                    groupId);
1013    
1014                    if (journalArticleResource == null) {
1015                            StringBundler msg = new StringBundler(6);
1016    
1017                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1018    
1019                            msg.append("uuid=");
1020                            msg.append(uuid);
1021    
1022                            msg.append(", groupId=");
1023                            msg.append(groupId);
1024    
1025                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1026    
1027                            if (_log.isWarnEnabled()) {
1028                                    _log.warn(msg.toString());
1029                            }
1030    
1031                            throw new NoSuchArticleResourceException(msg.toString());
1032                    }
1033    
1034                    return journalArticleResource;
1035            }
1036    
1037            /**
1038             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1039             *
1040             * @param uuid the uuid
1041             * @param groupId the group ID
1042             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1043             * @throws SystemException if a system exception occurred
1044             */
1045            public JournalArticleResource fetchByUUID_G(String uuid, long groupId)
1046                    throws SystemException {
1047                    return fetchByUUID_G(uuid, groupId, true);
1048            }
1049    
1050            /**
1051             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1052             *
1053             * @param uuid the uuid
1054             * @param groupId the group ID
1055             * @param retrieveFromCache whether to use the finder cache
1056             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1057             * @throws SystemException if a system exception occurred
1058             */
1059            public JournalArticleResource fetchByUUID_G(String uuid, long groupId,
1060                    boolean retrieveFromCache) throws SystemException {
1061                    Object[] finderArgs = new Object[] { uuid, groupId };
1062    
1063                    Object result = null;
1064    
1065                    if (retrieveFromCache) {
1066                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1067                                            finderArgs, this);
1068                    }
1069    
1070                    if (result == null) {
1071                            StringBundler query = new StringBundler(3);
1072    
1073                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1074    
1075                            if (uuid == null) {
1076                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1077                            }
1078                            else {
1079                                    if (uuid.equals(StringPool.BLANK)) {
1080                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1081                                    }
1082                                    else {
1083                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1084                                    }
1085                            }
1086    
1087                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1088    
1089                            String sql = query.toString();
1090    
1091                            Session session = null;
1092    
1093                            try {
1094                                    session = openSession();
1095    
1096                                    Query q = session.createQuery(sql);
1097    
1098                                    QueryPos qPos = QueryPos.getInstance(q);
1099    
1100                                    if (uuid != null) {
1101                                            qPos.add(uuid);
1102                                    }
1103    
1104                                    qPos.add(groupId);
1105    
1106                                    List<JournalArticleResource> list = q.list();
1107    
1108                                    result = list;
1109    
1110                                    JournalArticleResource journalArticleResource = null;
1111    
1112                                    if (list.isEmpty()) {
1113                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1114                                                    finderArgs, list);
1115                                    }
1116                                    else {
1117                                            journalArticleResource = list.get(0);
1118    
1119                                            cacheResult(journalArticleResource);
1120    
1121                                            if ((journalArticleResource.getUuid() == null) ||
1122                                                            !journalArticleResource.getUuid().equals(uuid) ||
1123                                                            (journalArticleResource.getGroupId() != groupId)) {
1124                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1125                                                            finderArgs, journalArticleResource);
1126                                            }
1127                                    }
1128    
1129                                    return journalArticleResource;
1130                            }
1131                            catch (Exception e) {
1132                                    throw processException(e);
1133                            }
1134                            finally {
1135                                    if (result == null) {
1136                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1137                                                    finderArgs);
1138                                    }
1139    
1140                                    closeSession(session);
1141                            }
1142                    }
1143                    else {
1144                            if (result instanceof List<?>) {
1145                                    return null;
1146                            }
1147                            else {
1148                                    return (JournalArticleResource)result;
1149                            }
1150                    }
1151            }
1152    
1153            /**
1154             * Returns all the journal article resources where groupId = &#63;.
1155             *
1156             * @param groupId the group ID
1157             * @return the matching journal article resources
1158             * @throws SystemException if a system exception occurred
1159             */
1160            public List<JournalArticleResource> findByGroupId(long groupId)
1161                    throws SystemException {
1162                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1163            }
1164    
1165            /**
1166             * Returns a range of all the journal article resources where groupId = &#63;.
1167             *
1168             * <p>
1169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1170             * </p>
1171             *
1172             * @param groupId the group ID
1173             * @param start the lower bound of the range of journal article resources
1174             * @param end the upper bound of the range of journal article resources (not inclusive)
1175             * @return the range of matching journal article resources
1176             * @throws SystemException if a system exception occurred
1177             */
1178            public List<JournalArticleResource> findByGroupId(long groupId, int start,
1179                    int end) throws SystemException {
1180                    return findByGroupId(groupId, start, end, null);
1181            }
1182    
1183            /**
1184             * Returns an ordered range of all the journal article resources where groupId = &#63;.
1185             *
1186             * <p>
1187             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1188             * </p>
1189             *
1190             * @param groupId the group ID
1191             * @param start the lower bound of the range of journal article resources
1192             * @param end the upper bound of the range of journal article resources (not inclusive)
1193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1194             * @return the ordered range of matching journal article resources
1195             * @throws SystemException if a system exception occurred
1196             */
1197            public List<JournalArticleResource> findByGroupId(long groupId, int start,
1198                    int end, OrderByComparator orderByComparator) throws SystemException {
1199                    FinderPath finderPath = null;
1200                    Object[] finderArgs = null;
1201    
1202                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1203                                    (orderByComparator == null)) {
1204                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1205                            finderArgs = new Object[] { groupId };
1206                    }
1207                    else {
1208                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1209                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1210                    }
1211    
1212                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
1213                                    finderArgs, this);
1214    
1215                    if (list == null) {
1216                            StringBundler query = null;
1217    
1218                            if (orderByComparator != null) {
1219                                    query = new StringBundler(3 +
1220                                                    (orderByComparator.getOrderByFields().length * 3));
1221                            }
1222                            else {
1223                                    query = new StringBundler(2);
1224                            }
1225    
1226                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1227    
1228                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1229    
1230                            if (orderByComparator != null) {
1231                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1232                                            orderByComparator);
1233                            }
1234    
1235                            String sql = query.toString();
1236    
1237                            Session session = null;
1238    
1239                            try {
1240                                    session = openSession();
1241    
1242                                    Query q = session.createQuery(sql);
1243    
1244                                    QueryPos qPos = QueryPos.getInstance(q);
1245    
1246                                    qPos.add(groupId);
1247    
1248                                    list = (List<JournalArticleResource>)QueryUtil.list(q,
1249                                                    getDialect(), start, end);
1250                            }
1251                            catch (Exception e) {
1252                                    throw processException(e);
1253                            }
1254                            finally {
1255                                    if (list == null) {
1256                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1257                                    }
1258                                    else {
1259                                            cacheResult(list);
1260    
1261                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1262                                    }
1263    
1264                                    closeSession(session);
1265                            }
1266                    }
1267    
1268                    return list;
1269            }
1270    
1271            /**
1272             * Returns the first journal article resource in the ordered set where groupId = &#63;.
1273             *
1274             * <p>
1275             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1276             * </p>
1277             *
1278             * @param groupId the group ID
1279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1280             * @return the first matching journal article resource
1281             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1282             * @throws SystemException if a system exception occurred
1283             */
1284            public JournalArticleResource findByGroupId_First(long groupId,
1285                    OrderByComparator orderByComparator)
1286                    throws NoSuchArticleResourceException, SystemException {
1287                    List<JournalArticleResource> list = findByGroupId(groupId, 0, 1,
1288                                    orderByComparator);
1289    
1290                    if (list.isEmpty()) {
1291                            StringBundler msg = new StringBundler(4);
1292    
1293                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1294    
1295                            msg.append("groupId=");
1296                            msg.append(groupId);
1297    
1298                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1299    
1300                            throw new NoSuchArticleResourceException(msg.toString());
1301                    }
1302                    else {
1303                            return list.get(0);
1304                    }
1305            }
1306    
1307            /**
1308             * Returns the last journal article resource in the ordered set where groupId = &#63;.
1309             *
1310             * <p>
1311             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1312             * </p>
1313             *
1314             * @param groupId the group ID
1315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1316             * @return the last matching journal article resource
1317             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1318             * @throws SystemException if a system exception occurred
1319             */
1320            public JournalArticleResource findByGroupId_Last(long groupId,
1321                    OrderByComparator orderByComparator)
1322                    throws NoSuchArticleResourceException, SystemException {
1323                    int count = countByGroupId(groupId);
1324    
1325                    List<JournalArticleResource> list = findByGroupId(groupId, count - 1,
1326                                    count, orderByComparator);
1327    
1328                    if (list.isEmpty()) {
1329                            StringBundler msg = new StringBundler(4);
1330    
1331                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1332    
1333                            msg.append("groupId=");
1334                            msg.append(groupId);
1335    
1336                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1337    
1338                            throw new NoSuchArticleResourceException(msg.toString());
1339                    }
1340                    else {
1341                            return list.get(0);
1342                    }
1343            }
1344    
1345            /**
1346             * Returns the journal article resources before and after the current journal article resource in the ordered set where groupId = &#63;.
1347             *
1348             * <p>
1349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1350             * </p>
1351             *
1352             * @param resourcePrimKey the primary key of the current journal article resource
1353             * @param groupId the group ID
1354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1355             * @return the previous, current, and next journal article resource
1356             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public JournalArticleResource[] findByGroupId_PrevAndNext(
1360                    long resourcePrimKey, long groupId, OrderByComparator orderByComparator)
1361                    throws NoSuchArticleResourceException, SystemException {
1362                    JournalArticleResource journalArticleResource = findByPrimaryKey(resourcePrimKey);
1363    
1364                    Session session = null;
1365    
1366                    try {
1367                            session = openSession();
1368    
1369                            JournalArticleResource[] array = new JournalArticleResourceImpl[3];
1370    
1371                            array[0] = getByGroupId_PrevAndNext(session,
1372                                            journalArticleResource, groupId, orderByComparator, true);
1373    
1374                            array[1] = journalArticleResource;
1375    
1376                            array[2] = getByGroupId_PrevAndNext(session,
1377                                            journalArticleResource, groupId, orderByComparator, false);
1378    
1379                            return array;
1380                    }
1381                    catch (Exception e) {
1382                            throw processException(e);
1383                    }
1384                    finally {
1385                            closeSession(session);
1386                    }
1387            }
1388    
1389            protected JournalArticleResource getByGroupId_PrevAndNext(Session session,
1390                    JournalArticleResource journalArticleResource, long groupId,
1391                    OrderByComparator orderByComparator, boolean previous) {
1392                    StringBundler query = null;
1393    
1394                    if (orderByComparator != null) {
1395                            query = new StringBundler(6 +
1396                                            (orderByComparator.getOrderByFields().length * 6));
1397                    }
1398                    else {
1399                            query = new StringBundler(3);
1400                    }
1401    
1402                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1403    
1404                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1405    
1406                    if (orderByComparator != null) {
1407                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1408    
1409                            if (orderByConditionFields.length > 0) {
1410                                    query.append(WHERE_AND);
1411                            }
1412    
1413                            for (int i = 0; i < orderByConditionFields.length; i++) {
1414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1415                                    query.append(orderByConditionFields[i]);
1416    
1417                                    if ((i + 1) < orderByConditionFields.length) {
1418                                            if (orderByComparator.isAscending() ^ previous) {
1419                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1420                                            }
1421                                            else {
1422                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1423                                            }
1424                                    }
1425                                    else {
1426                                            if (orderByComparator.isAscending() ^ previous) {
1427                                                    query.append(WHERE_GREATER_THAN);
1428                                            }
1429                                            else {
1430                                                    query.append(WHERE_LESSER_THAN);
1431                                            }
1432                                    }
1433                            }
1434    
1435                            query.append(ORDER_BY_CLAUSE);
1436    
1437                            String[] orderByFields = orderByComparator.getOrderByFields();
1438    
1439                            for (int i = 0; i < orderByFields.length; i++) {
1440                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1441                                    query.append(orderByFields[i]);
1442    
1443                                    if ((i + 1) < orderByFields.length) {
1444                                            if (orderByComparator.isAscending() ^ previous) {
1445                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1446                                            }
1447                                            else {
1448                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1449                                            }
1450                                    }
1451                                    else {
1452                                            if (orderByComparator.isAscending() ^ previous) {
1453                                                    query.append(ORDER_BY_ASC);
1454                                            }
1455                                            else {
1456                                                    query.append(ORDER_BY_DESC);
1457                                            }
1458                                    }
1459                            }
1460                    }
1461    
1462                    String sql = query.toString();
1463    
1464                    Query q = session.createQuery(sql);
1465    
1466                    q.setFirstResult(0);
1467                    q.setMaxResults(2);
1468    
1469                    QueryPos qPos = QueryPos.getInstance(q);
1470    
1471                    qPos.add(groupId);
1472    
1473                    if (orderByComparator != null) {
1474                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticleResource);
1475    
1476                            for (Object value : values) {
1477                                    qPos.add(value);
1478                            }
1479                    }
1480    
1481                    List<JournalArticleResource> list = q.list();
1482    
1483                    if (list.size() == 2) {
1484                            return list.get(1);
1485                    }
1486                    else {
1487                            return null;
1488                    }
1489            }
1490    
1491            /**
1492             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
1493             *
1494             * @param groupId the group ID
1495             * @param articleId the article ID
1496             * @return the matching journal article resource
1497             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1498             * @throws SystemException if a system exception occurred
1499             */
1500            public JournalArticleResource findByG_A(long groupId, String articleId)
1501                    throws NoSuchArticleResourceException, SystemException {
1502                    JournalArticleResource journalArticleResource = fetchByG_A(groupId,
1503                                    articleId);
1504    
1505                    if (journalArticleResource == null) {
1506                            StringBundler msg = new StringBundler(6);
1507    
1508                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1509    
1510                            msg.append("groupId=");
1511                            msg.append(groupId);
1512    
1513                            msg.append(", articleId=");
1514                            msg.append(articleId);
1515    
1516                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1517    
1518                            if (_log.isWarnEnabled()) {
1519                                    _log.warn(msg.toString());
1520                            }
1521    
1522                            throw new NoSuchArticleResourceException(msg.toString());
1523                    }
1524    
1525                    return journalArticleResource;
1526            }
1527    
1528            /**
1529             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1530             *
1531             * @param groupId the group ID
1532             * @param articleId the article ID
1533             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1534             * @throws SystemException if a system exception occurred
1535             */
1536            public JournalArticleResource fetchByG_A(long groupId, String articleId)
1537                    throws SystemException {
1538                    return fetchByG_A(groupId, articleId, true);
1539            }
1540    
1541            /**
1542             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1543             *
1544             * @param groupId the group ID
1545             * @param articleId the article ID
1546             * @param retrieveFromCache whether to use the finder cache
1547             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1548             * @throws SystemException if a system exception occurred
1549             */
1550            public JournalArticleResource fetchByG_A(long groupId, String articleId,
1551                    boolean retrieveFromCache) throws SystemException {
1552                    Object[] finderArgs = new Object[] { groupId, articleId };
1553    
1554                    Object result = null;
1555    
1556                    if (retrieveFromCache) {
1557                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A,
1558                                            finderArgs, this);
1559                    }
1560    
1561                    if (result == null) {
1562                            StringBundler query = new StringBundler(3);
1563    
1564                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1565    
1566                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1567    
1568                            if (articleId == null) {
1569                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1570                            }
1571                            else {
1572                                    if (articleId.equals(StringPool.BLANK)) {
1573                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1574                                    }
1575                                    else {
1576                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1577                                    }
1578                            }
1579    
1580                            String sql = query.toString();
1581    
1582                            Session session = null;
1583    
1584                            try {
1585                                    session = openSession();
1586    
1587                                    Query q = session.createQuery(sql);
1588    
1589                                    QueryPos qPos = QueryPos.getInstance(q);
1590    
1591                                    qPos.add(groupId);
1592    
1593                                    if (articleId != null) {
1594                                            qPos.add(articleId);
1595                                    }
1596    
1597                                    List<JournalArticleResource> list = q.list();
1598    
1599                                    result = list;
1600    
1601                                    JournalArticleResource journalArticleResource = null;
1602    
1603                                    if (list.isEmpty()) {
1604                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
1605                                                    finderArgs, list);
1606                                    }
1607                                    else {
1608                                            journalArticleResource = list.get(0);
1609    
1610                                            cacheResult(journalArticleResource);
1611    
1612                                            if ((journalArticleResource.getGroupId() != groupId) ||
1613                                                            (journalArticleResource.getArticleId() == null) ||
1614                                                            !journalArticleResource.getArticleId()
1615                                                                                                               .equals(articleId)) {
1616                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
1617                                                            finderArgs, journalArticleResource);
1618                                            }
1619                                    }
1620    
1621                                    return journalArticleResource;
1622                            }
1623                            catch (Exception e) {
1624                                    throw processException(e);
1625                            }
1626                            finally {
1627                                    if (result == null) {
1628                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A,
1629                                                    finderArgs);
1630                                    }
1631    
1632                                    closeSession(session);
1633                            }
1634                    }
1635                    else {
1636                            if (result instanceof List<?>) {
1637                                    return null;
1638                            }
1639                            else {
1640                                    return (JournalArticleResource)result;
1641                            }
1642                    }
1643            }
1644    
1645            /**
1646             * Returns all the journal article resources.
1647             *
1648             * @return the journal article resources
1649             * @throws SystemException if a system exception occurred
1650             */
1651            public List<JournalArticleResource> findAll() throws SystemException {
1652                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1653            }
1654    
1655            /**
1656             * Returns a range of all the journal article resources.
1657             *
1658             * <p>
1659             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1660             * </p>
1661             *
1662             * @param start the lower bound of the range of journal article resources
1663             * @param end the upper bound of the range of journal article resources (not inclusive)
1664             * @return the range of journal article resources
1665             * @throws SystemException if a system exception occurred
1666             */
1667            public List<JournalArticleResource> findAll(int start, int end)
1668                    throws SystemException {
1669                    return findAll(start, end, null);
1670            }
1671    
1672            /**
1673             * Returns an ordered range of all the journal article resources.
1674             *
1675             * <p>
1676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1677             * </p>
1678             *
1679             * @param start the lower bound of the range of journal article resources
1680             * @param end the upper bound of the range of journal article resources (not inclusive)
1681             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1682             * @return the ordered range of journal article resources
1683             * @throws SystemException if a system exception occurred
1684             */
1685            public List<JournalArticleResource> findAll(int start, int end,
1686                    OrderByComparator orderByComparator) throws SystemException {
1687                    FinderPath finderPath = null;
1688                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1689    
1690                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1691                                    (orderByComparator == null)) {
1692                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1693                            finderArgs = FINDER_ARGS_EMPTY;
1694                    }
1695                    else {
1696                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1697                            finderArgs = new Object[] { start, end, orderByComparator };
1698                    }
1699    
1700                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
1701                                    finderArgs, this);
1702    
1703                    if (list == null) {
1704                            StringBundler query = null;
1705                            String sql = null;
1706    
1707                            if (orderByComparator != null) {
1708                                    query = new StringBundler(2 +
1709                                                    (orderByComparator.getOrderByFields().length * 3));
1710    
1711                                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE);
1712    
1713                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1714                                            orderByComparator);
1715    
1716                                    sql = query.toString();
1717                            }
1718                            else {
1719                                    sql = _SQL_SELECT_JOURNALARTICLERESOURCE;
1720                            }
1721    
1722                            Session session = null;
1723    
1724                            try {
1725                                    session = openSession();
1726    
1727                                    Query q = session.createQuery(sql);
1728    
1729                                    if (orderByComparator == null) {
1730                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
1731                                                            getDialect(), start, end, false);
1732    
1733                                            Collections.sort(list);
1734                                    }
1735                                    else {
1736                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
1737                                                            getDialect(), start, end);
1738                                    }
1739                            }
1740                            catch (Exception e) {
1741                                    throw processException(e);
1742                            }
1743                            finally {
1744                                    if (list == null) {
1745                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1746                                    }
1747                                    else {
1748                                            cacheResult(list);
1749    
1750                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1751                                    }
1752    
1753                                    closeSession(session);
1754                            }
1755                    }
1756    
1757                    return list;
1758            }
1759    
1760            /**
1761             * Removes all the journal article resources where uuid = &#63; from the database.
1762             *
1763             * @param uuid the uuid
1764             * @throws SystemException if a system exception occurred
1765             */
1766            public void removeByUuid(String uuid) throws SystemException {
1767                    for (JournalArticleResource journalArticleResource : findByUuid(uuid)) {
1768                            journalArticleResourcePersistence.remove(journalArticleResource);
1769                    }
1770            }
1771    
1772            /**
1773             * Removes the journal article resource where uuid = &#63; and groupId = &#63; from the database.
1774             *
1775             * @param uuid the uuid
1776             * @param groupId the group ID
1777             * @throws SystemException if a system exception occurred
1778             */
1779            public void removeByUUID_G(String uuid, long groupId)
1780                    throws NoSuchArticleResourceException, SystemException {
1781                    JournalArticleResource journalArticleResource = findByUUID_G(uuid,
1782                                    groupId);
1783    
1784                    journalArticleResourcePersistence.remove(journalArticleResource);
1785            }
1786    
1787            /**
1788             * Removes all the journal article resources where groupId = &#63; from the database.
1789             *
1790             * @param groupId the group ID
1791             * @throws SystemException if a system exception occurred
1792             */
1793            public void removeByGroupId(long groupId) throws SystemException {
1794                    for (JournalArticleResource journalArticleResource : findByGroupId(
1795                                    groupId)) {
1796                            journalArticleResourcePersistence.remove(journalArticleResource);
1797                    }
1798            }
1799    
1800            /**
1801             * Removes the journal article resource where groupId = &#63; and articleId = &#63; from the database.
1802             *
1803             * @param groupId the group ID
1804             * @param articleId the article ID
1805             * @throws SystemException if a system exception occurred
1806             */
1807            public void removeByG_A(long groupId, String articleId)
1808                    throws NoSuchArticleResourceException, SystemException {
1809                    JournalArticleResource journalArticleResource = findByG_A(groupId,
1810                                    articleId);
1811    
1812                    journalArticleResourcePersistence.remove(journalArticleResource);
1813            }
1814    
1815            /**
1816             * Removes all the journal article resources from the database.
1817             *
1818             * @throws SystemException if a system exception occurred
1819             */
1820            public void removeAll() throws SystemException {
1821                    for (JournalArticleResource journalArticleResource : findAll()) {
1822                            journalArticleResourcePersistence.remove(journalArticleResource);
1823                    }
1824            }
1825    
1826            /**
1827             * Returns the number of journal article resources where uuid = &#63;.
1828             *
1829             * @param uuid the uuid
1830             * @return the number of matching journal article resources
1831             * @throws SystemException if a system exception occurred
1832             */
1833            public int countByUuid(String uuid) throws SystemException {
1834                    Object[] finderArgs = new Object[] { uuid };
1835    
1836                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1837                                    finderArgs, this);
1838    
1839                    if (count == null) {
1840                            StringBundler query = new StringBundler(2);
1841    
1842                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
1843    
1844                            if (uuid == null) {
1845                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1846                            }
1847                            else {
1848                                    if (uuid.equals(StringPool.BLANK)) {
1849                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1850                                    }
1851                                    else {
1852                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1853                                    }
1854                            }
1855    
1856                            String sql = query.toString();
1857    
1858                            Session session = null;
1859    
1860                            try {
1861                                    session = openSession();
1862    
1863                                    Query q = session.createQuery(sql);
1864    
1865                                    QueryPos qPos = QueryPos.getInstance(q);
1866    
1867                                    if (uuid != null) {
1868                                            qPos.add(uuid);
1869                                    }
1870    
1871                                    count = (Long)q.uniqueResult();
1872                            }
1873                            catch (Exception e) {
1874                                    throw processException(e);
1875                            }
1876                            finally {
1877                                    if (count == null) {
1878                                            count = Long.valueOf(0);
1879                                    }
1880    
1881                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1882                                            finderArgs, count);
1883    
1884                                    closeSession(session);
1885                            }
1886                    }
1887    
1888                    return count.intValue();
1889            }
1890    
1891            /**
1892             * Returns the number of journal article resources where uuid = &#63; and groupId = &#63;.
1893             *
1894             * @param uuid the uuid
1895             * @param groupId the group ID
1896             * @return the number of matching journal article resources
1897             * @throws SystemException if a system exception occurred
1898             */
1899            public int countByUUID_G(String uuid, long groupId)
1900                    throws SystemException {
1901                    Object[] finderArgs = new Object[] { uuid, groupId };
1902    
1903                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1904                                    finderArgs, this);
1905    
1906                    if (count == null) {
1907                            StringBundler query = new StringBundler(3);
1908    
1909                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
1910    
1911                            if (uuid == null) {
1912                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1913                            }
1914                            else {
1915                                    if (uuid.equals(StringPool.BLANK)) {
1916                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1917                                    }
1918                                    else {
1919                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1920                                    }
1921                            }
1922    
1923                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1924    
1925                            String sql = query.toString();
1926    
1927                            Session session = null;
1928    
1929                            try {
1930                                    session = openSession();
1931    
1932                                    Query q = session.createQuery(sql);
1933    
1934                                    QueryPos qPos = QueryPos.getInstance(q);
1935    
1936                                    if (uuid != null) {
1937                                            qPos.add(uuid);
1938                                    }
1939    
1940                                    qPos.add(groupId);
1941    
1942                                    count = (Long)q.uniqueResult();
1943                            }
1944                            catch (Exception e) {
1945                                    throw processException(e);
1946                            }
1947                            finally {
1948                                    if (count == null) {
1949                                            count = Long.valueOf(0);
1950                                    }
1951    
1952                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1953                                            finderArgs, count);
1954    
1955                                    closeSession(session);
1956                            }
1957                    }
1958    
1959                    return count.intValue();
1960            }
1961    
1962            /**
1963             * Returns the number of journal article resources where groupId = &#63;.
1964             *
1965             * @param groupId the group ID
1966             * @return the number of matching journal article resources
1967             * @throws SystemException if a system exception occurred
1968             */
1969            public int countByGroupId(long groupId) throws SystemException {
1970                    Object[] finderArgs = new Object[] { groupId };
1971    
1972                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1973                                    finderArgs, this);
1974    
1975                    if (count == null) {
1976                            StringBundler query = new StringBundler(2);
1977    
1978                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
1979    
1980                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1981    
1982                            String sql = query.toString();
1983    
1984                            Session session = null;
1985    
1986                            try {
1987                                    session = openSession();
1988    
1989                                    Query q = session.createQuery(sql);
1990    
1991                                    QueryPos qPos = QueryPos.getInstance(q);
1992    
1993                                    qPos.add(groupId);
1994    
1995                                    count = (Long)q.uniqueResult();
1996                            }
1997                            catch (Exception e) {
1998                                    throw processException(e);
1999                            }
2000                            finally {
2001                                    if (count == null) {
2002                                            count = Long.valueOf(0);
2003                                    }
2004    
2005                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2006                                            finderArgs, count);
2007    
2008                                    closeSession(session);
2009                            }
2010                    }
2011    
2012                    return count.intValue();
2013            }
2014    
2015            /**
2016             * Returns the number of journal article resources where groupId = &#63; and articleId = &#63;.
2017             *
2018             * @param groupId the group ID
2019             * @param articleId the article ID
2020             * @return the number of matching journal article resources
2021             * @throws SystemException if a system exception occurred
2022             */
2023            public int countByG_A(long groupId, String articleId)
2024                    throws SystemException {
2025                    Object[] finderArgs = new Object[] { groupId, articleId };
2026    
2027                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
2028                                    finderArgs, this);
2029    
2030                    if (count == null) {
2031                            StringBundler query = new StringBundler(3);
2032    
2033                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
2034    
2035                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2036    
2037                            if (articleId == null) {
2038                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2039                            }
2040                            else {
2041                                    if (articleId.equals(StringPool.BLANK)) {
2042                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2043                                    }
2044                                    else {
2045                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2046                                    }
2047                            }
2048    
2049                            String sql = query.toString();
2050    
2051                            Session session = null;
2052    
2053                            try {
2054                                    session = openSession();
2055    
2056                                    Query q = session.createQuery(sql);
2057    
2058                                    QueryPos qPos = QueryPos.getInstance(q);
2059    
2060                                    qPos.add(groupId);
2061    
2062                                    if (articleId != null) {
2063                                            qPos.add(articleId);
2064                                    }
2065    
2066                                    count = (Long)q.uniqueResult();
2067                            }
2068                            catch (Exception e) {
2069                                    throw processException(e);
2070                            }
2071                            finally {
2072                                    if (count == null) {
2073                                            count = Long.valueOf(0);
2074                                    }
2075    
2076                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
2077                                            count);
2078    
2079                                    closeSession(session);
2080                            }
2081                    }
2082    
2083                    return count.intValue();
2084            }
2085    
2086            /**
2087             * Returns the number of journal article resources.
2088             *
2089             * @return the number of journal article resources
2090             * @throws SystemException if a system exception occurred
2091             */
2092            public int countAll() throws SystemException {
2093                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2094                                    FINDER_ARGS_EMPTY, this);
2095    
2096                    if (count == null) {
2097                            Session session = null;
2098    
2099                            try {
2100                                    session = openSession();
2101    
2102                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLERESOURCE);
2103    
2104                                    count = (Long)q.uniqueResult();
2105                            }
2106                            catch (Exception e) {
2107                                    throw processException(e);
2108                            }
2109                            finally {
2110                                    if (count == null) {
2111                                            count = Long.valueOf(0);
2112                                    }
2113    
2114                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2115                                            FINDER_ARGS_EMPTY, count);
2116    
2117                                    closeSession(session);
2118                            }
2119                    }
2120    
2121                    return count.intValue();
2122            }
2123    
2124            /**
2125             * Initializes the journal article resource persistence.
2126             */
2127            public void afterPropertiesSet() {
2128                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2129                                            com.liferay.portal.util.PropsUtil.get(
2130                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticleResource")));
2131    
2132                    if (listenerClassNames.length > 0) {
2133                            try {
2134                                    List<ModelListener<JournalArticleResource>> listenersList = new ArrayList<ModelListener<JournalArticleResource>>();
2135    
2136                                    for (String listenerClassName : listenerClassNames) {
2137                                            listenersList.add((ModelListener<JournalArticleResource>)InstanceFactory.newInstance(
2138                                                            listenerClassName));
2139                                    }
2140    
2141                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2142                            }
2143                            catch (Exception e) {
2144                                    _log.error(e);
2145                            }
2146                    }
2147            }
2148    
2149            public void destroy() {
2150                    EntityCacheUtil.removeCache(JournalArticleResourceImpl.class.getName());
2151                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2152                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2153            }
2154    
2155            @BeanReference(type = JournalArticlePersistence.class)
2156            protected JournalArticlePersistence journalArticlePersistence;
2157            @BeanReference(type = JournalArticleImagePersistence.class)
2158            protected JournalArticleImagePersistence journalArticleImagePersistence;
2159            @BeanReference(type = JournalArticleResourcePersistence.class)
2160            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2161            @BeanReference(type = JournalContentSearchPersistence.class)
2162            protected JournalContentSearchPersistence journalContentSearchPersistence;
2163            @BeanReference(type = JournalFeedPersistence.class)
2164            protected JournalFeedPersistence journalFeedPersistence;
2165            @BeanReference(type = JournalStructurePersistence.class)
2166            protected JournalStructurePersistence journalStructurePersistence;
2167            @BeanReference(type = JournalTemplatePersistence.class)
2168            protected JournalTemplatePersistence journalTemplatePersistence;
2169            @BeanReference(type = ResourcePersistence.class)
2170            protected ResourcePersistence resourcePersistence;
2171            @BeanReference(type = UserPersistence.class)
2172            protected UserPersistence userPersistence;
2173            private static final String _SQL_SELECT_JOURNALARTICLERESOURCE = "SELECT journalArticleResource FROM JournalArticleResource journalArticleResource";
2174            private static final String _SQL_SELECT_JOURNALARTICLERESOURCE_WHERE = "SELECT journalArticleResource FROM JournalArticleResource journalArticleResource WHERE ";
2175            private static final String _SQL_COUNT_JOURNALARTICLERESOURCE = "SELECT COUNT(journalArticleResource) FROM JournalArticleResource journalArticleResource";
2176            private static final String _SQL_COUNT_JOURNALARTICLERESOURCE_WHERE = "SELECT COUNT(journalArticleResource) FROM JournalArticleResource journalArticleResource WHERE ";
2177            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticleResource.uuid IS NULL";
2178            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticleResource.uuid = ?";
2179            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticleResource.uuid IS NULL OR journalArticleResource.uuid = ?)";
2180            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticleResource.uuid IS NULL AND ";
2181            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticleResource.uuid = ? AND ";
2182            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticleResource.uuid IS NULL OR journalArticleResource.uuid = ?) AND ";
2183            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticleResource.groupId = ?";
2184            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticleResource.groupId = ?";
2185            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticleResource.groupId = ? AND ";
2186            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticleResource.articleId IS NULL";
2187            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticleResource.articleId = ?";
2188            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticleResource.articleId IS NULL OR journalArticleResource.articleId = ?)";
2189            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticleResource.";
2190            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticleResource exists with the primary key ";
2191            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticleResource exists with the key {";
2192            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2193            private static Log _log = LogFactoryUtil.getLog(JournalArticleResourcePersistenceImpl.class);
2194            private static JournalArticleResource _nullJournalArticleResource = new JournalArticleResourceImpl() {
2195                            @Override
2196                            public Object clone() {
2197                                    return this;
2198                            }
2199    
2200                            @Override
2201                            public CacheModel<JournalArticleResource> toCacheModel() {
2202                                    return _nullJournalArticleResourceCacheModel;
2203                            }
2204                    };
2205    
2206            private static CacheModel<JournalArticleResource> _nullJournalArticleResourceCacheModel =
2207                    new CacheModel<JournalArticleResource>() {
2208                            public JournalArticleResource toEntityModel() {
2209                                    return _nullJournalArticleResource;
2210                            }
2211                    };
2212    }