001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.sanitizer.Sanitizer;
032    import com.liferay.portal.kernel.sanitizer.SanitizerException;
033    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034    import com.liferay.portal.kernel.util.CalendarUtil;
035    import com.liferay.portal.kernel.util.ContentTypes;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.StringBundler;
040    import com.liferay.portal.kernel.util.StringPool;
041    import com.liferay.portal.kernel.util.StringUtil;
042    import com.liferay.portal.kernel.util.Validator;
043    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
044    import com.liferay.portal.model.CacheModel;
045    import com.liferay.portal.model.ModelListener;
046    import com.liferay.portal.security.auth.PrincipalThreadLocal;
047    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048    import com.liferay.portal.service.persistence.BatchSessionUtil;
049    import com.liferay.portal.service.persistence.CompanyPersistence;
050    import com.liferay.portal.service.persistence.GroupPersistence;
051    import com.liferay.portal.service.persistence.ImagePersistence;
052    import com.liferay.portal.service.persistence.OrganizationPersistence;
053    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
054    import com.liferay.portal.service.persistence.ResourcePersistence;
055    import com.liferay.portal.service.persistence.SubscriptionPersistence;
056    import com.liferay.portal.service.persistence.UserPersistence;
057    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
058    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
059    
060    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
061    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
062    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
063    import com.liferay.portlet.blogs.NoSuchEntryException;
064    import com.liferay.portlet.blogs.model.BlogsEntry;
065    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
066    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
067    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
068    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
069    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
070    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
071    
072    import java.io.Serializable;
073    
074    import java.util.ArrayList;
075    import java.util.Collections;
076    import java.util.Date;
077    import java.util.List;
078    
079    /**
080     * The persistence implementation for the blogs entry service.
081     *
082     * <p>
083     * Caching information and settings can be found in <code>portal.properties</code>
084     * </p>
085     *
086     * @author Brian Wing Shun Chan
087     * @see BlogsEntryPersistence
088     * @see BlogsEntryUtil
089     * @generated
090     */
091    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
092            implements BlogsEntryPersistence {
093            /*
094             * NOTE FOR DEVELOPERS:
095             *
096             * Never modify or reference this class directly. Always use {@link BlogsEntryUtil} to access the blogs entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
097             */
098            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
099            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100                    ".List1";
101            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
102                    ".List2";
103            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
106                            new String[] {
107                                    String.class.getName(),
108                                    
109                            "java.lang.Integer", "java.lang.Integer",
110                                    "com.liferay.portal.kernel.util.OrderByComparator"
111                            });
112            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
115                            new String[] { String.class.getName() },
116                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
120                            new String[] { String.class.getName() });
121            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
122                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
123                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
124                            new String[] { String.class.getName(), Long.class.getName() },
125                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
126                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
127            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
128                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
130                            new String[] { String.class.getName(), Long.class.getName() });
131            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
132                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
133                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
134                            new String[] {
135                                    Long.class.getName(),
136                                    
137                            "java.lang.Integer", "java.lang.Integer",
138                                    "com.liferay.portal.kernel.util.OrderByComparator"
139                            });
140            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
141                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
142                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
144                            new String[] { Long.class.getName() },
145                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
146            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
147                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
149                            new String[] { Long.class.getName() });
150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
151                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
152                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
153                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
154                            new String[] {
155                                    Long.class.getName(),
156                                    
157                            "java.lang.Integer", "java.lang.Integer",
158                                    "com.liferay.portal.kernel.util.OrderByComparator"
159                            });
160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
161                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
162                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
164                            new String[] { Long.class.getName() },
165                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK);
166            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
167                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
169                            new String[] { Long.class.getName() });
170            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
171                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
172                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
173                            new String[] {
174                                    Long.class.getName(), Long.class.getName(),
175                                    
176                            "java.lang.Integer", "java.lang.Integer",
177                                    "com.liferay.portal.kernel.util.OrderByComparator"
178                            });
179            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
180                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
181                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
182                            new String[] { Long.class.getName(), Long.class.getName() },
183                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
184                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK);
185            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
186                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
187                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
188                            new String[] { Long.class.getName(), Long.class.getName() });
189            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
190                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
191                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
192                            new String[] {
193                                    Long.class.getName(), Date.class.getName(),
194                                    
195                            "java.lang.Integer", "java.lang.Integer",
196                                    "com.liferay.portal.kernel.util.OrderByComparator"
197                            });
198            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
199                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
200                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
201                            new String[] { Long.class.getName(), Date.class.getName() });
202            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
203                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
204                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
205                            new String[] {
206                                    Long.class.getName(), Integer.class.getName(),
207                                    
208                            "java.lang.Integer", "java.lang.Integer",
209                                    "com.liferay.portal.kernel.util.OrderByComparator"
210                            });
211            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
212                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
213                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
214                            new String[] { Long.class.getName(), Integer.class.getName() },
215                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
216                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
217            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
218                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
219                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
220                            new String[] { Long.class.getName(), Integer.class.getName() });
221            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
222                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
223                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
224                            new String[] { Long.class.getName(), String.class.getName() },
225                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
226                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
227            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
228                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
229                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
230                            new String[] { Long.class.getName(), String.class.getName() });
231            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
232                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
233                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
234                            new String[] {
235                                    Long.class.getName(), Date.class.getName(),
236                                    
237                            "java.lang.Integer", "java.lang.Integer",
238                                    "com.liferay.portal.kernel.util.OrderByComparator"
239                            });
240            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
241                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
242                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
243                            new String[] { Long.class.getName(), Date.class.getName() });
244            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
245                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
246                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
247                            new String[] {
248                                    Long.class.getName(), Integer.class.getName(),
249                                    
250                            "java.lang.Integer", "java.lang.Integer",
251                                    "com.liferay.portal.kernel.util.OrderByComparator"
252                            });
253            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
254                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
255                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
256                            new String[] { Long.class.getName(), Integer.class.getName() },
257                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
258                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
259            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
260                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
261                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
262                            new String[] { Long.class.getName(), Integer.class.getName() });
263            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
264                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
265                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
266                            new String[] {
267                                    Date.class.getName(), Integer.class.getName(),
268                                    
269                            "java.lang.Integer", "java.lang.Integer",
270                                    "com.liferay.portal.kernel.util.OrderByComparator"
271                            });
272            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
273                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
274                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
275                            new String[] { Date.class.getName(), Integer.class.getName() });
276            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
277                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
278                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
279                            new String[] {
280                                    Long.class.getName(), Long.class.getName(),
281                                    Integer.class.getName(),
282                                    
283                            "java.lang.Integer", "java.lang.Integer",
284                                    "com.liferay.portal.kernel.util.OrderByComparator"
285                            });
286            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
287                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
288                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
289                            new String[] {
290                                    Long.class.getName(), Long.class.getName(),
291                                    Integer.class.getName()
292                            },
293                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
294                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
295                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
296            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
297                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
298                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
299                            new String[] {
300                                    Long.class.getName(), Long.class.getName(),
301                                    Integer.class.getName()
302                            });
303            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
304                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
305                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
306                            new String[] {
307                                    Long.class.getName(), Date.class.getName(),
308                                    Integer.class.getName(),
309                                    
310                            "java.lang.Integer", "java.lang.Integer",
311                                    "com.liferay.portal.kernel.util.OrderByComparator"
312                            });
313            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
314                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
315                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
316                            new String[] {
317                                    Long.class.getName(), Date.class.getName(),
318                                    Integer.class.getName()
319                            });
320            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
321                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
322                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
323                            new String[] {
324                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
325                                    
326                            "java.lang.Integer", "java.lang.Integer",
327                                    "com.liferay.portal.kernel.util.OrderByComparator"
328                            });
329            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
330                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
331                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
332                            new String[] {
333                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
334                            });
335            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
336                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
337                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
338                            new String[] {
339                                    Long.class.getName(), Long.class.getName(),
340                                    Integer.class.getName(),
341                                    
342                            "java.lang.Integer", "java.lang.Integer",
343                                    "com.liferay.portal.kernel.util.OrderByComparator"
344                            });
345            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
346                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
347                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
348                            new String[] {
349                                    Long.class.getName(), Long.class.getName(),
350                                    Integer.class.getName()
351                            },
352                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
353                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
354                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
355            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
356                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
357                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
358                            new String[] {
359                                    Long.class.getName(), Long.class.getName(),
360                                    Integer.class.getName()
361                            });
362            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
363                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
364                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
365                            new String[] {
366                                    Long.class.getName(), Date.class.getName(),
367                                    Integer.class.getName(),
368                                    
369                            "java.lang.Integer", "java.lang.Integer",
370                                    "com.liferay.portal.kernel.util.OrderByComparator"
371                            });
372            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
373                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
374                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
375                            new String[] {
376                                    Long.class.getName(), Date.class.getName(),
377                                    Integer.class.getName()
378                            });
379            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
380                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
381                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
382                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
383                            new String[] {
384                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
385                                    Integer.class.getName(),
386                                    
387                            "java.lang.Integer", "java.lang.Integer",
388                                    "com.liferay.portal.kernel.util.OrderByComparator"
389                            });
390            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
391                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
392                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
393                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
394                            new String[] {
395                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
396                                    Integer.class.getName()
397                            });
398            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
399                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
400                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
401            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
402                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
403                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
404            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
405                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
406                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
407    
408            /**
409             * Caches the blogs entry in the entity cache if it is enabled.
410             *
411             * @param blogsEntry the blogs entry
412             */
413            public void cacheResult(BlogsEntry blogsEntry) {
414                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
415                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
416    
417                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
418                            new Object[] {
419                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
420                            }, blogsEntry);
421    
422                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
423                            new Object[] {
424                                    Long.valueOf(blogsEntry.getGroupId()),
425                                    
426                            blogsEntry.getUrlTitle()
427                            }, blogsEntry);
428    
429                    blogsEntry.resetOriginalValues();
430            }
431    
432            /**
433             * Caches the blogs entries in the entity cache if it is enabled.
434             *
435             * @param blogsEntries the blogs entries
436             */
437            public void cacheResult(List<BlogsEntry> blogsEntries) {
438                    for (BlogsEntry blogsEntry : blogsEntries) {
439                            if (EntityCacheUtil.getResult(
440                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
441                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
442                                    cacheResult(blogsEntry);
443                            }
444                            else {
445                                    blogsEntry.resetOriginalValues();
446                            }
447                    }
448            }
449    
450            /**
451             * Clears the cache for all blogs entries.
452             *
453             * <p>
454             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
455             * </p>
456             */
457            @Override
458            public void clearCache() {
459                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
460                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
461                    }
462    
463                    EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
464    
465                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
466                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
467                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
468            }
469    
470            /**
471             * Clears the cache for the blogs entry.
472             *
473             * <p>
474             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
475             * </p>
476             */
477            @Override
478            public void clearCache(BlogsEntry blogsEntry) {
479                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
480                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
481    
482                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
483                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
484    
485                    clearUniqueFindersCache(blogsEntry);
486            }
487    
488            @Override
489            public void clearCache(List<BlogsEntry> blogsEntries) {
490                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
491                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
492    
493                    for (BlogsEntry blogsEntry : blogsEntries) {
494                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
495                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
496    
497                            clearUniqueFindersCache(blogsEntry);
498                    }
499            }
500    
501            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
502                    if (blogsEntry.isNew()) {
503                            Object[] args = new Object[] {
504                                            blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
505                                    };
506    
507                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
508                                    Long.valueOf(1));
509                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
510                                    blogsEntry);
511    
512                            args = new Object[] {
513                                            Long.valueOf(blogsEntry.getGroupId()),
514                                            
515                                            blogsEntry.getUrlTitle()
516                                    };
517    
518                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
519                                    Long.valueOf(1));
520                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
521                                    blogsEntry);
522                    }
523                    else {
524                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
525    
526                            if ((blogsEntryModelImpl.getColumnBitmask() &
527                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
528                                    Object[] args = new Object[] {
529                                                    blogsEntry.getUuid(),
530                                                    Long.valueOf(blogsEntry.getGroupId())
531                                            };
532    
533                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
534                                            Long.valueOf(1));
535                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
536                                            blogsEntry);
537                            }
538    
539                            if ((blogsEntryModelImpl.getColumnBitmask() &
540                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
541                                    Object[] args = new Object[] {
542                                                    Long.valueOf(blogsEntry.getGroupId()),
543                                                    
544                                                    blogsEntry.getUrlTitle()
545                                            };
546    
547                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
548                                            Long.valueOf(1));
549                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
550                                            blogsEntry);
551                            }
552                    }
553            }
554    
555            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
556                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
557    
558                    Object[] args = new Object[] {
559                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
560                            };
561    
562                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
563                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
564    
565                    if ((blogsEntryModelImpl.getColumnBitmask() &
566                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
567                            args = new Object[] {
568                                            blogsEntryModelImpl.getOriginalUuid(),
569                                            Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
570                                    };
571    
572                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
573                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
574                    }
575    
576                    args = new Object[] {
577                                    Long.valueOf(blogsEntry.getGroupId()),
578                                    
579                                    blogsEntry.getUrlTitle()
580                            };
581    
582                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
583                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
584    
585                    if ((blogsEntryModelImpl.getColumnBitmask() &
586                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
587                            args = new Object[] {
588                                            Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
589                                            
590                                            blogsEntryModelImpl.getOriginalUrlTitle()
591                                    };
592    
593                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
594                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
595                    }
596            }
597    
598            /**
599             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
600             *
601             * @param entryId the primary key for the new blogs entry
602             * @return the new blogs entry
603             */
604            public BlogsEntry create(long entryId) {
605                    BlogsEntry blogsEntry = new BlogsEntryImpl();
606    
607                    blogsEntry.setNew(true);
608                    blogsEntry.setPrimaryKey(entryId);
609    
610                    String uuid = PortalUUIDUtil.generate();
611    
612                    blogsEntry.setUuid(uuid);
613    
614                    return blogsEntry;
615            }
616    
617            /**
618             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
619             *
620             * @param entryId the primary key of the blogs entry
621             * @return the blogs entry that was removed
622             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
623             * @throws SystemException if a system exception occurred
624             */
625            public BlogsEntry remove(long entryId)
626                    throws NoSuchEntryException, SystemException {
627                    return remove(Long.valueOf(entryId));
628            }
629    
630            /**
631             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
632             *
633             * @param primaryKey the primary key of the blogs entry
634             * @return the blogs entry that was removed
635             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
636             * @throws SystemException if a system exception occurred
637             */
638            @Override
639            public BlogsEntry remove(Serializable primaryKey)
640                    throws NoSuchEntryException, SystemException {
641                    Session session = null;
642    
643                    try {
644                            session = openSession();
645    
646                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
647                                            primaryKey);
648    
649                            if (blogsEntry == null) {
650                                    if (_log.isWarnEnabled()) {
651                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
652                                    }
653    
654                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
655                                            primaryKey);
656                            }
657    
658                            return remove(blogsEntry);
659                    }
660                    catch (NoSuchEntryException nsee) {
661                            throw nsee;
662                    }
663                    catch (Exception e) {
664                            throw processException(e);
665                    }
666                    finally {
667                            closeSession(session);
668                    }
669            }
670    
671            @Override
672            protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
673                    throws SystemException {
674                    blogsEntry = toUnwrappedModel(blogsEntry);
675    
676                    Session session = null;
677    
678                    try {
679                            session = openSession();
680    
681                            BatchSessionUtil.delete(session, blogsEntry);
682                    }
683                    catch (Exception e) {
684                            throw processException(e);
685                    }
686                    finally {
687                            closeSession(session);
688                    }
689    
690                    clearCache(blogsEntry);
691    
692                    return blogsEntry;
693            }
694    
695            @Override
696            public BlogsEntry updateImpl(
697                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry, boolean merge)
698                    throws SystemException {
699                    blogsEntry = toUnwrappedModel(blogsEntry);
700    
701                    boolean isNew = blogsEntry.isNew();
702    
703                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
704    
705                    if (Validator.isNull(blogsEntry.getUuid())) {
706                            String uuid = PortalUUIDUtil.generate();
707    
708                            blogsEntry.setUuid(uuid);
709                    }
710    
711                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
712    
713                    if (userId > 0) {
714                            long companyId = blogsEntry.getCompanyId();
715    
716                            long groupId = blogsEntry.getGroupId();
717    
718                            long entryId = 0;
719    
720                            if (!isNew) {
721                                    entryId = blogsEntry.getPrimaryKey();
722                            }
723    
724                            try {
725                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
726                                                    userId,
727                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
728                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
729                                                    blogsEntry.getTitle(), null));
730    
731                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
732                                                    groupId, userId,
733                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
734                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
735                                                    blogsEntry.getContent(), null));
736                            }
737                            catch (SanitizerException se) {
738                                    throw new SystemException(se);
739                            }
740                    }
741    
742                    Session session = null;
743    
744                    try {
745                            session = openSession();
746    
747                            BatchSessionUtil.update(session, blogsEntry, merge);
748    
749                            blogsEntry.setNew(false);
750                    }
751                    catch (Exception e) {
752                            throw processException(e);
753                    }
754                    finally {
755                            closeSession(session);
756                    }
757    
758                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
759    
760                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
761                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
762                    }
763    
764                    else {
765                            if ((blogsEntryModelImpl.getColumnBitmask() &
766                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
767                                    Object[] args = new Object[] {
768                                                    blogsEntryModelImpl.getOriginalUuid()
769                                            };
770    
771                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
772                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
773                                            args);
774    
775                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
776    
777                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
778                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
779                                            args);
780                            }
781    
782                            if ((blogsEntryModelImpl.getColumnBitmask() &
783                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
784                                    Object[] args = new Object[] {
785                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
786                                            };
787    
788                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
789                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
790                                            args);
791    
792                                    args = new Object[] {
793                                                    Long.valueOf(blogsEntryModelImpl.getGroupId())
794                                            };
795    
796                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
797                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
798                                            args);
799                            }
800    
801                            if ((blogsEntryModelImpl.getColumnBitmask() &
802                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
803                                    Object[] args = new Object[] {
804                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId())
805                                            };
806    
807                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
808                                            args);
809                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
810                                            args);
811    
812                                    args = new Object[] {
813                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId())
814                                            };
815    
816                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
817                                            args);
818                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
819                                            args);
820                            }
821    
822                            if ((blogsEntryModelImpl.getColumnBitmask() &
823                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
824                                    Object[] args = new Object[] {
825                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
826                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId())
827                                            };
828    
829                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
830                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
831                                            args);
832    
833                                    args = new Object[] {
834                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
835                                                    Long.valueOf(blogsEntryModelImpl.getUserId())
836                                            };
837    
838                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
839                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
840                                            args);
841                            }
842    
843                            if ((blogsEntryModelImpl.getColumnBitmask() &
844                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
845                                    Object[] args = new Object[] {
846                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
847                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
848                                            };
849    
850                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
851                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
852                                            args);
853    
854                                    args = new Object[] {
855                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
856                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
857                                            };
858    
859                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
860                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
861                                            args);
862                            }
863    
864                            if ((blogsEntryModelImpl.getColumnBitmask() &
865                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
866                                    Object[] args = new Object[] {
867                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
868                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
869                                            };
870    
871                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
872                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
873                                            args);
874    
875                                    args = new Object[] {
876                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
877                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
878                                            };
879    
880                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
881                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
882                                            args);
883                            }
884    
885                            if ((blogsEntryModelImpl.getColumnBitmask() &
886                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
887                                    Object[] args = new Object[] {
888                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
889                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
890                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
891                                            };
892    
893                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
894                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
895                                            args);
896    
897                                    args = new Object[] {
898                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
899                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
900                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
901                                            };
902    
903                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
904                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
905                                            args);
906                            }
907    
908                            if ((blogsEntryModelImpl.getColumnBitmask() &
909                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
910                                    Object[] args = new Object[] {
911                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
912                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
913                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
914                                            };
915    
916                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
917                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
918                                            args);
919    
920                                    args = new Object[] {
921                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
922                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
923                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
924                                            };
925    
926                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
927                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
928                                            args);
929                            }
930                    }
931    
932                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
933                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
934    
935                    clearUniqueFindersCache(blogsEntry);
936                    cacheUniqueFindersCache(blogsEntry);
937    
938                    return blogsEntry;
939            }
940    
941            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
942                    if (blogsEntry instanceof BlogsEntryImpl) {
943                            return blogsEntry;
944                    }
945    
946                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
947    
948                    blogsEntryImpl.setNew(blogsEntry.isNew());
949                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
950    
951                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
952                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
953                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
954                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
955                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
956                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
957                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
958                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
959                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
960                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
961                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
962                    blogsEntryImpl.setContent(blogsEntry.getContent());
963                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
964                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
965                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
966                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
967                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
968                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
969                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
970                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
971                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
972                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
973                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
974    
975                    return blogsEntryImpl;
976            }
977    
978            /**
979             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
980             *
981             * @param primaryKey the primary key of the blogs entry
982             * @return the blogs entry
983             * @throws com.liferay.portal.NoSuchModelException if a blogs entry with the primary key could not be found
984             * @throws SystemException if a system exception occurred
985             */
986            @Override
987            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
988                    throws NoSuchModelException, SystemException {
989                    return findByPrimaryKey(((Long)primaryKey).longValue());
990            }
991    
992            /**
993             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
994             *
995             * @param entryId the primary key of the blogs entry
996             * @return the blogs entry
997             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
998             * @throws SystemException if a system exception occurred
999             */
1000            public BlogsEntry findByPrimaryKey(long entryId)
1001                    throws NoSuchEntryException, SystemException {
1002                    BlogsEntry blogsEntry = fetchByPrimaryKey(entryId);
1003    
1004                    if (blogsEntry == null) {
1005                            if (_log.isWarnEnabled()) {
1006                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
1007                            }
1008    
1009                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1010                                    entryId);
1011                    }
1012    
1013                    return blogsEntry;
1014            }
1015    
1016            /**
1017             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
1018             *
1019             * @param primaryKey the primary key of the blogs entry
1020             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
1021             * @throws SystemException if a system exception occurred
1022             */
1023            @Override
1024            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
1025                    throws SystemException {
1026                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1027            }
1028    
1029            /**
1030             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
1031             *
1032             * @param entryId the primary key of the blogs entry
1033             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
1034             * @throws SystemException if a system exception occurred
1035             */
1036            public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
1037                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1038                                    BlogsEntryImpl.class, entryId);
1039    
1040                    if (blogsEntry == _nullBlogsEntry) {
1041                            return null;
1042                    }
1043    
1044                    if (blogsEntry == null) {
1045                            Session session = null;
1046    
1047                            boolean hasException = false;
1048    
1049                            try {
1050                                    session = openSession();
1051    
1052                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
1053                                                    Long.valueOf(entryId));
1054                            }
1055                            catch (Exception e) {
1056                                    hasException = true;
1057    
1058                                    throw processException(e);
1059                            }
1060                            finally {
1061                                    if (blogsEntry != null) {
1062                                            cacheResult(blogsEntry);
1063                                    }
1064                                    else if (!hasException) {
1065                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1066                                                    BlogsEntryImpl.class, entryId, _nullBlogsEntry);
1067                                    }
1068    
1069                                    closeSession(session);
1070                            }
1071                    }
1072    
1073                    return blogsEntry;
1074            }
1075    
1076            /**
1077             * Returns all the blogs entries where uuid = &#63;.
1078             *
1079             * @param uuid the uuid
1080             * @return the matching blogs entries
1081             * @throws SystemException if a system exception occurred
1082             */
1083            public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
1084                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1085            }
1086    
1087            /**
1088             * Returns a range of all the blogs entries where uuid = &#63;.
1089             *
1090             * <p>
1091             * 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.
1092             * </p>
1093             *
1094             * @param uuid the uuid
1095             * @param start the lower bound of the range of blogs entries
1096             * @param end the upper bound of the range of blogs entries (not inclusive)
1097             * @return the range of matching blogs entries
1098             * @throws SystemException if a system exception occurred
1099             */
1100            public List<BlogsEntry> findByUuid(String uuid, int start, int end)
1101                    throws SystemException {
1102                    return findByUuid(uuid, start, end, null);
1103            }
1104    
1105            /**
1106             * Returns an ordered range of all the blogs entries where uuid = &#63;.
1107             *
1108             * <p>
1109             * 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.
1110             * </p>
1111             *
1112             * @param uuid the uuid
1113             * @param start the lower bound of the range of blogs entries
1114             * @param end the upper bound of the range of blogs entries (not inclusive)
1115             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1116             * @return the ordered range of matching blogs entries
1117             * @throws SystemException if a system exception occurred
1118             */
1119            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
1120                    OrderByComparator orderByComparator) throws SystemException {
1121                    FinderPath finderPath = null;
1122                    Object[] finderArgs = null;
1123    
1124                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1125                                    (orderByComparator == null)) {
1126                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1127                            finderArgs = new Object[] { uuid };
1128                    }
1129                    else {
1130                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1131                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1132                    }
1133    
1134                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1135                                    finderArgs, this);
1136    
1137                    if ((list != null) && !list.isEmpty()) {
1138                            for (BlogsEntry blogsEntry : list) {
1139                                    if (!Validator.equals(uuid, blogsEntry.getUuid())) {
1140                                            list = null;
1141    
1142                                            break;
1143                                    }
1144                            }
1145                    }
1146    
1147                    if (list == null) {
1148                            StringBundler query = null;
1149    
1150                            if (orderByComparator != null) {
1151                                    query = new StringBundler(3 +
1152                                                    (orderByComparator.getOrderByFields().length * 3));
1153                            }
1154                            else {
1155                                    query = new StringBundler(3);
1156                            }
1157    
1158                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1159    
1160                            if (uuid == null) {
1161                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1162                            }
1163                            else {
1164                                    if (uuid.equals(StringPool.BLANK)) {
1165                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1166                                    }
1167                                    else {
1168                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1169                                    }
1170                            }
1171    
1172                            if (orderByComparator != null) {
1173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1174                                            orderByComparator);
1175                            }
1176    
1177                            else {
1178                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1179                            }
1180    
1181                            String sql = query.toString();
1182    
1183                            Session session = null;
1184    
1185                            try {
1186                                    session = openSession();
1187    
1188                                    Query q = session.createQuery(sql);
1189    
1190                                    QueryPos qPos = QueryPos.getInstance(q);
1191    
1192                                    if (uuid != null) {
1193                                            qPos.add(uuid);
1194                                    }
1195    
1196                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
1197                                                    end);
1198                            }
1199                            catch (Exception e) {
1200                                    throw processException(e);
1201                            }
1202                            finally {
1203                                    if (list == null) {
1204                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1205                                    }
1206                                    else {
1207                                            cacheResult(list);
1208    
1209                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1210                                    }
1211    
1212                                    closeSession(session);
1213                            }
1214                    }
1215    
1216                    return list;
1217            }
1218    
1219            /**
1220             * Returns the first blogs entry in the ordered set where uuid = &#63;.
1221             *
1222             * @param uuid the uuid
1223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1224             * @return the first matching blogs entry
1225             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1226             * @throws SystemException if a system exception occurred
1227             */
1228            public BlogsEntry findByUuid_First(String uuid,
1229                    OrderByComparator orderByComparator)
1230                    throws NoSuchEntryException, SystemException {
1231                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
1232    
1233                    if (blogsEntry != null) {
1234                            return blogsEntry;
1235                    }
1236    
1237                    StringBundler msg = new StringBundler(4);
1238    
1239                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240    
1241                    msg.append("uuid=");
1242                    msg.append(uuid);
1243    
1244                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1245    
1246                    throw new NoSuchEntryException(msg.toString());
1247            }
1248    
1249            /**
1250             * Returns the first blogs entry in the ordered set where uuid = &#63;.
1251             *
1252             * @param uuid the uuid
1253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1254             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1255             * @throws SystemException if a system exception occurred
1256             */
1257            public BlogsEntry fetchByUuid_First(String uuid,
1258                    OrderByComparator orderByComparator) throws SystemException {
1259                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
1260    
1261                    if (!list.isEmpty()) {
1262                            return list.get(0);
1263                    }
1264    
1265                    return null;
1266            }
1267    
1268            /**
1269             * Returns the last blogs entry in the ordered set where uuid = &#63;.
1270             *
1271             * @param uuid the uuid
1272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1273             * @return the last matching blogs entry
1274             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1275             * @throws SystemException if a system exception occurred
1276             */
1277            public BlogsEntry findByUuid_Last(String uuid,
1278                    OrderByComparator orderByComparator)
1279                    throws NoSuchEntryException, SystemException {
1280                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
1281    
1282                    if (blogsEntry != null) {
1283                            return blogsEntry;
1284                    }
1285    
1286                    StringBundler msg = new StringBundler(4);
1287    
1288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1289    
1290                    msg.append("uuid=");
1291                    msg.append(uuid);
1292    
1293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1294    
1295                    throw new NoSuchEntryException(msg.toString());
1296            }
1297    
1298            /**
1299             * Returns the last blogs entry in the ordered set where uuid = &#63;.
1300             *
1301             * @param uuid the uuid
1302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1303             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1304             * @throws SystemException if a system exception occurred
1305             */
1306            public BlogsEntry fetchByUuid_Last(String uuid,
1307                    OrderByComparator orderByComparator) throws SystemException {
1308                    int count = countByUuid(uuid);
1309    
1310                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
1311                                    orderByComparator);
1312    
1313                    if (!list.isEmpty()) {
1314                            return list.get(0);
1315                    }
1316    
1317                    return null;
1318            }
1319    
1320            /**
1321             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
1322             *
1323             * @param entryId the primary key of the current blogs entry
1324             * @param uuid the uuid
1325             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1326             * @return the previous, current, and next blogs entry
1327             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1328             * @throws SystemException if a system exception occurred
1329             */
1330            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
1331                    OrderByComparator orderByComparator)
1332                    throws NoSuchEntryException, SystemException {
1333                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1334    
1335                    Session session = null;
1336    
1337                    try {
1338                            session = openSession();
1339    
1340                            BlogsEntry[] array = new BlogsEntryImpl[3];
1341    
1342                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
1343                                            orderByComparator, true);
1344    
1345                            array[1] = blogsEntry;
1346    
1347                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
1348                                            orderByComparator, false);
1349    
1350                            return array;
1351                    }
1352                    catch (Exception e) {
1353                            throw processException(e);
1354                    }
1355                    finally {
1356                            closeSession(session);
1357                    }
1358            }
1359    
1360            protected BlogsEntry getByUuid_PrevAndNext(Session session,
1361                    BlogsEntry blogsEntry, String uuid,
1362                    OrderByComparator orderByComparator, boolean previous) {
1363                    StringBundler query = null;
1364    
1365                    if (orderByComparator != null) {
1366                            query = new StringBundler(6 +
1367                                            (orderByComparator.getOrderByFields().length * 6));
1368                    }
1369                    else {
1370                            query = new StringBundler(3);
1371                    }
1372    
1373                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1374    
1375                    if (uuid == null) {
1376                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1377                    }
1378                    else {
1379                            if (uuid.equals(StringPool.BLANK)) {
1380                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1381                            }
1382                            else {
1383                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1384                            }
1385                    }
1386    
1387                    if (orderByComparator != null) {
1388                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1389    
1390                            if (orderByConditionFields.length > 0) {
1391                                    query.append(WHERE_AND);
1392                            }
1393    
1394                            for (int i = 0; i < orderByConditionFields.length; i++) {
1395                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1396                                    query.append(orderByConditionFields[i]);
1397    
1398                                    if ((i + 1) < orderByConditionFields.length) {
1399                                            if (orderByComparator.isAscending() ^ previous) {
1400                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1401                                            }
1402                                            else {
1403                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1404                                            }
1405                                    }
1406                                    else {
1407                                            if (orderByComparator.isAscending() ^ previous) {
1408                                                    query.append(WHERE_GREATER_THAN);
1409                                            }
1410                                            else {
1411                                                    query.append(WHERE_LESSER_THAN);
1412                                            }
1413                                    }
1414                            }
1415    
1416                            query.append(ORDER_BY_CLAUSE);
1417    
1418                            String[] orderByFields = orderByComparator.getOrderByFields();
1419    
1420                            for (int i = 0; i < orderByFields.length; i++) {
1421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1422                                    query.append(orderByFields[i]);
1423    
1424                                    if ((i + 1) < orderByFields.length) {
1425                                            if (orderByComparator.isAscending() ^ previous) {
1426                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1427                                            }
1428                                            else {
1429                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1430                                            }
1431                                    }
1432                                    else {
1433                                            if (orderByComparator.isAscending() ^ previous) {
1434                                                    query.append(ORDER_BY_ASC);
1435                                            }
1436                                            else {
1437                                                    query.append(ORDER_BY_DESC);
1438                                            }
1439                                    }
1440                            }
1441                    }
1442    
1443                    else {
1444                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1445                    }
1446    
1447                    String sql = query.toString();
1448    
1449                    Query q = session.createQuery(sql);
1450    
1451                    q.setFirstResult(0);
1452                    q.setMaxResults(2);
1453    
1454                    QueryPos qPos = QueryPos.getInstance(q);
1455    
1456                    if (uuid != null) {
1457                            qPos.add(uuid);
1458                    }
1459    
1460                    if (orderByComparator != null) {
1461                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1462    
1463                            for (Object value : values) {
1464                                    qPos.add(value);
1465                            }
1466                    }
1467    
1468                    List<BlogsEntry> list = q.list();
1469    
1470                    if (list.size() == 2) {
1471                            return list.get(1);
1472                    }
1473                    else {
1474                            return null;
1475                    }
1476            }
1477    
1478            /**
1479             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
1480             *
1481             * @param uuid the uuid
1482             * @param groupId the group ID
1483             * @return the matching blogs entry
1484             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1485             * @throws SystemException if a system exception occurred
1486             */
1487            public BlogsEntry findByUUID_G(String uuid, long groupId)
1488                    throws NoSuchEntryException, SystemException {
1489                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
1490    
1491                    if (blogsEntry == null) {
1492                            StringBundler msg = new StringBundler(6);
1493    
1494                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1495    
1496                            msg.append("uuid=");
1497                            msg.append(uuid);
1498    
1499                            msg.append(", groupId=");
1500                            msg.append(groupId);
1501    
1502                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1503    
1504                            if (_log.isWarnEnabled()) {
1505                                    _log.warn(msg.toString());
1506                            }
1507    
1508                            throw new NoSuchEntryException(msg.toString());
1509                    }
1510    
1511                    return blogsEntry;
1512            }
1513    
1514            /**
1515             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1516             *
1517             * @param uuid the uuid
1518             * @param groupId the group ID
1519             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1520             * @throws SystemException if a system exception occurred
1521             */
1522            public BlogsEntry fetchByUUID_G(String uuid, long groupId)
1523                    throws SystemException {
1524                    return fetchByUUID_G(uuid, groupId, true);
1525            }
1526    
1527            /**
1528             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1529             *
1530             * @param uuid the uuid
1531             * @param groupId the group ID
1532             * @param retrieveFromCache whether to use the finder cache
1533             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1534             * @throws SystemException if a system exception occurred
1535             */
1536            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
1537                    boolean retrieveFromCache) throws SystemException {
1538                    Object[] finderArgs = new Object[] { uuid, groupId };
1539    
1540                    Object result = null;
1541    
1542                    if (retrieveFromCache) {
1543                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1544                                            finderArgs, this);
1545                    }
1546    
1547                    if (result instanceof BlogsEntry) {
1548                            BlogsEntry blogsEntry = (BlogsEntry)result;
1549    
1550                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1551                                            (groupId != blogsEntry.getGroupId())) {
1552                                    result = null;
1553                            }
1554                    }
1555    
1556                    if (result == null) {
1557                            StringBundler query = new StringBundler(4);
1558    
1559                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1560    
1561                            if (uuid == null) {
1562                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1563                            }
1564                            else {
1565                                    if (uuid.equals(StringPool.BLANK)) {
1566                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1567                                    }
1568                                    else {
1569                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1570                                    }
1571                            }
1572    
1573                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1574    
1575                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1576    
1577                            String sql = query.toString();
1578    
1579                            Session session = null;
1580    
1581                            try {
1582                                    session = openSession();
1583    
1584                                    Query q = session.createQuery(sql);
1585    
1586                                    QueryPos qPos = QueryPos.getInstance(q);
1587    
1588                                    if (uuid != null) {
1589                                            qPos.add(uuid);
1590                                    }
1591    
1592                                    qPos.add(groupId);
1593    
1594                                    List<BlogsEntry> list = q.list();
1595    
1596                                    result = list;
1597    
1598                                    BlogsEntry blogsEntry = null;
1599    
1600                                    if (list.isEmpty()) {
1601                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1602                                                    finderArgs, list);
1603                                    }
1604                                    else {
1605                                            blogsEntry = list.get(0);
1606    
1607                                            cacheResult(blogsEntry);
1608    
1609                                            if ((blogsEntry.getUuid() == null) ||
1610                                                            !blogsEntry.getUuid().equals(uuid) ||
1611                                                            (blogsEntry.getGroupId() != groupId)) {
1612                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1613                                                            finderArgs, blogsEntry);
1614                                            }
1615                                    }
1616    
1617                                    return blogsEntry;
1618                            }
1619                            catch (Exception e) {
1620                                    throw processException(e);
1621                            }
1622                            finally {
1623                                    if (result == null) {
1624                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1625                                                    finderArgs);
1626                                    }
1627    
1628                                    closeSession(session);
1629                            }
1630                    }
1631                    else {
1632                            if (result instanceof List<?>) {
1633                                    return null;
1634                            }
1635                            else {
1636                                    return (BlogsEntry)result;
1637                            }
1638                    }
1639            }
1640    
1641            /**
1642             * Returns all the blogs entries where groupId = &#63;.
1643             *
1644             * @param groupId the group ID
1645             * @return the matching blogs entries
1646             * @throws SystemException if a system exception occurred
1647             */
1648            public List<BlogsEntry> findByGroupId(long groupId)
1649                    throws SystemException {
1650                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1651            }
1652    
1653            /**
1654             * Returns a range of all the blogs entries where groupId = &#63;.
1655             *
1656             * <p>
1657             * 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.
1658             * </p>
1659             *
1660             * @param groupId the group ID
1661             * @param start the lower bound of the range of blogs entries
1662             * @param end the upper bound of the range of blogs entries (not inclusive)
1663             * @return the range of matching blogs entries
1664             * @throws SystemException if a system exception occurred
1665             */
1666            public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
1667                    throws SystemException {
1668                    return findByGroupId(groupId, start, end, null);
1669            }
1670    
1671            /**
1672             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1673             *
1674             * <p>
1675             * 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.
1676             * </p>
1677             *
1678             * @param groupId the group ID
1679             * @param start the lower bound of the range of blogs entries
1680             * @param end the upper bound of the range of blogs entries (not inclusive)
1681             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1682             * @return the ordered range of matching blogs entries
1683             * @throws SystemException if a system exception occurred
1684             */
1685            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1686                    OrderByComparator orderByComparator) throws SystemException {
1687                    FinderPath finderPath = null;
1688                    Object[] finderArgs = null;
1689    
1690                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1691                                    (orderByComparator == null)) {
1692                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1693                            finderArgs = new Object[] { groupId };
1694                    }
1695                    else {
1696                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1697                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1698                    }
1699    
1700                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1701                                    finderArgs, this);
1702    
1703                    if ((list != null) && !list.isEmpty()) {
1704                            for (BlogsEntry blogsEntry : list) {
1705                                    if ((groupId != blogsEntry.getGroupId())) {
1706                                            list = null;
1707    
1708                                            break;
1709                                    }
1710                            }
1711                    }
1712    
1713                    if (list == null) {
1714                            StringBundler query = null;
1715    
1716                            if (orderByComparator != null) {
1717                                    query = new StringBundler(3 +
1718                                                    (orderByComparator.getOrderByFields().length * 3));
1719                            }
1720                            else {
1721                                    query = new StringBundler(3);
1722                            }
1723    
1724                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1725    
1726                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1727    
1728                            if (orderByComparator != null) {
1729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1730                                            orderByComparator);
1731                            }
1732    
1733                            else {
1734                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1735                            }
1736    
1737                            String sql = query.toString();
1738    
1739                            Session session = null;
1740    
1741                            try {
1742                                    session = openSession();
1743    
1744                                    Query q = session.createQuery(sql);
1745    
1746                                    QueryPos qPos = QueryPos.getInstance(q);
1747    
1748                                    qPos.add(groupId);
1749    
1750                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
1751                                                    end);
1752                            }
1753                            catch (Exception e) {
1754                                    throw processException(e);
1755                            }
1756                            finally {
1757                                    if (list == null) {
1758                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1759                                    }
1760                                    else {
1761                                            cacheResult(list);
1762    
1763                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1764                                    }
1765    
1766                                    closeSession(session);
1767                            }
1768                    }
1769    
1770                    return list;
1771            }
1772    
1773            /**
1774             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1775             *
1776             * @param groupId the group ID
1777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1778             * @return the first matching blogs entry
1779             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1780             * @throws SystemException if a system exception occurred
1781             */
1782            public BlogsEntry findByGroupId_First(long groupId,
1783                    OrderByComparator orderByComparator)
1784                    throws NoSuchEntryException, SystemException {
1785                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1786    
1787                    if (blogsEntry != null) {
1788                            return blogsEntry;
1789                    }
1790    
1791                    StringBundler msg = new StringBundler(4);
1792    
1793                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1794    
1795                    msg.append("groupId=");
1796                    msg.append(groupId);
1797    
1798                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1799    
1800                    throw new NoSuchEntryException(msg.toString());
1801            }
1802    
1803            /**
1804             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1805             *
1806             * @param groupId the group ID
1807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1808             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1809             * @throws SystemException if a system exception occurred
1810             */
1811            public BlogsEntry fetchByGroupId_First(long groupId,
1812                    OrderByComparator orderByComparator) throws SystemException {
1813                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1814    
1815                    if (!list.isEmpty()) {
1816                            return list.get(0);
1817                    }
1818    
1819                    return null;
1820            }
1821    
1822            /**
1823             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1824             *
1825             * @param groupId the group ID
1826             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1827             * @return the last matching blogs entry
1828             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1829             * @throws SystemException if a system exception occurred
1830             */
1831            public BlogsEntry findByGroupId_Last(long groupId,
1832                    OrderByComparator orderByComparator)
1833                    throws NoSuchEntryException, SystemException {
1834                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1835    
1836                    if (blogsEntry != null) {
1837                            return blogsEntry;
1838                    }
1839    
1840                    StringBundler msg = new StringBundler(4);
1841    
1842                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1843    
1844                    msg.append("groupId=");
1845                    msg.append(groupId);
1846    
1847                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1848    
1849                    throw new NoSuchEntryException(msg.toString());
1850            }
1851    
1852            /**
1853             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1854             *
1855             * @param groupId the group ID
1856             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1857             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public BlogsEntry fetchByGroupId_Last(long groupId,
1861                    OrderByComparator orderByComparator) throws SystemException {
1862                    int count = countByGroupId(groupId);
1863    
1864                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1865                                    orderByComparator);
1866    
1867                    if (!list.isEmpty()) {
1868                            return list.get(0);
1869                    }
1870    
1871                    return null;
1872            }
1873    
1874            /**
1875             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1876             *
1877             * @param entryId the primary key of the current blogs entry
1878             * @param groupId the group ID
1879             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1880             * @return the previous, current, and next blogs entry
1881             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1882             * @throws SystemException if a system exception occurred
1883             */
1884            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1885                    OrderByComparator orderByComparator)
1886                    throws NoSuchEntryException, SystemException {
1887                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1888    
1889                    Session session = null;
1890    
1891                    try {
1892                            session = openSession();
1893    
1894                            BlogsEntry[] array = new BlogsEntryImpl[3];
1895    
1896                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1897                                            orderByComparator, true);
1898    
1899                            array[1] = blogsEntry;
1900    
1901                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1902                                            orderByComparator, false);
1903    
1904                            return array;
1905                    }
1906                    catch (Exception e) {
1907                            throw processException(e);
1908                    }
1909                    finally {
1910                            closeSession(session);
1911                    }
1912            }
1913    
1914            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1915                    BlogsEntry blogsEntry, long groupId,
1916                    OrderByComparator orderByComparator, boolean previous) {
1917                    StringBundler query = null;
1918    
1919                    if (orderByComparator != null) {
1920                            query = new StringBundler(6 +
1921                                            (orderByComparator.getOrderByFields().length * 6));
1922                    }
1923                    else {
1924                            query = new StringBundler(3);
1925                    }
1926    
1927                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1928    
1929                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1930    
1931                    if (orderByComparator != null) {
1932                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1933    
1934                            if (orderByConditionFields.length > 0) {
1935                                    query.append(WHERE_AND);
1936                            }
1937    
1938                            for (int i = 0; i < orderByConditionFields.length; i++) {
1939                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1940                                    query.append(orderByConditionFields[i]);
1941    
1942                                    if ((i + 1) < orderByConditionFields.length) {
1943                                            if (orderByComparator.isAscending() ^ previous) {
1944                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1945                                            }
1946                                            else {
1947                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1948                                            }
1949                                    }
1950                                    else {
1951                                            if (orderByComparator.isAscending() ^ previous) {
1952                                                    query.append(WHERE_GREATER_THAN);
1953                                            }
1954                                            else {
1955                                                    query.append(WHERE_LESSER_THAN);
1956                                            }
1957                                    }
1958                            }
1959    
1960                            query.append(ORDER_BY_CLAUSE);
1961    
1962                            String[] orderByFields = orderByComparator.getOrderByFields();
1963    
1964                            for (int i = 0; i < orderByFields.length; i++) {
1965                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1966                                    query.append(orderByFields[i]);
1967    
1968                                    if ((i + 1) < orderByFields.length) {
1969                                            if (orderByComparator.isAscending() ^ previous) {
1970                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1971                                            }
1972                                            else {
1973                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1974                                            }
1975                                    }
1976                                    else {
1977                                            if (orderByComparator.isAscending() ^ previous) {
1978                                                    query.append(ORDER_BY_ASC);
1979                                            }
1980                                            else {
1981                                                    query.append(ORDER_BY_DESC);
1982                                            }
1983                                    }
1984                            }
1985                    }
1986    
1987                    else {
1988                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1989                    }
1990    
1991                    String sql = query.toString();
1992    
1993                    Query q = session.createQuery(sql);
1994    
1995                    q.setFirstResult(0);
1996                    q.setMaxResults(2);
1997    
1998                    QueryPos qPos = QueryPos.getInstance(q);
1999    
2000                    qPos.add(groupId);
2001    
2002                    if (orderByComparator != null) {
2003                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2004    
2005                            for (Object value : values) {
2006                                    qPos.add(value);
2007                            }
2008                    }
2009    
2010                    List<BlogsEntry> list = q.list();
2011    
2012                    if (list.size() == 2) {
2013                            return list.get(1);
2014                    }
2015                    else {
2016                            return null;
2017                    }
2018            }
2019    
2020            /**
2021             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
2022             *
2023             * @param groupId the group ID
2024             * @return the matching blogs entries that the user has permission to view
2025             * @throws SystemException if a system exception occurred
2026             */
2027            public List<BlogsEntry> filterFindByGroupId(long groupId)
2028                    throws SystemException {
2029                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2030                            QueryUtil.ALL_POS, null);
2031            }
2032    
2033            /**
2034             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
2035             *
2036             * <p>
2037             * 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.
2038             * </p>
2039             *
2040             * @param groupId the group ID
2041             * @param start the lower bound of the range of blogs entries
2042             * @param end the upper bound of the range of blogs entries (not inclusive)
2043             * @return the range of matching blogs entries that the user has permission to view
2044             * @throws SystemException if a system exception occurred
2045             */
2046            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end)
2047                    throws SystemException {
2048                    return filterFindByGroupId(groupId, start, end, null);
2049            }
2050    
2051            /**
2052             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
2053             *
2054             * <p>
2055             * 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.
2056             * </p>
2057             *
2058             * @param groupId the group ID
2059             * @param start the lower bound of the range of blogs entries
2060             * @param end the upper bound of the range of blogs entries (not inclusive)
2061             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2062             * @return the ordered range of matching blogs entries that the user has permission to view
2063             * @throws SystemException if a system exception occurred
2064             */
2065            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
2066                    int end, OrderByComparator orderByComparator) throws SystemException {
2067                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2068                            return findByGroupId(groupId, start, end, orderByComparator);
2069                    }
2070    
2071                    StringBundler query = null;
2072    
2073                    if (orderByComparator != null) {
2074                            query = new StringBundler(3 +
2075                                            (orderByComparator.getOrderByFields().length * 3));
2076                    }
2077                    else {
2078                            query = new StringBundler(3);
2079                    }
2080    
2081                    if (getDB().isSupportsInlineDistinct()) {
2082                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2083                    }
2084                    else {
2085                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2086                    }
2087    
2088                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2089    
2090                    if (!getDB().isSupportsInlineDistinct()) {
2091                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2092                    }
2093    
2094                    if (orderByComparator != null) {
2095                            if (getDB().isSupportsInlineDistinct()) {
2096                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2097                                            orderByComparator);
2098                            }
2099                            else {
2100                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2101                                            orderByComparator);
2102                            }
2103                    }
2104    
2105                    else {
2106                            if (getDB().isSupportsInlineDistinct()) {
2107                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2108                            }
2109                            else {
2110                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2111                            }
2112                    }
2113    
2114                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2115                                    BlogsEntry.class.getName(),
2116                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2117    
2118                    Session session = null;
2119    
2120                    try {
2121                            session = openSession();
2122    
2123                            SQLQuery q = session.createSQLQuery(sql);
2124    
2125                            if (getDB().isSupportsInlineDistinct()) {
2126                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2127                            }
2128                            else {
2129                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2130                            }
2131    
2132                            QueryPos qPos = QueryPos.getInstance(q);
2133    
2134                            qPos.add(groupId);
2135    
2136                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2137                    }
2138                    catch (Exception e) {
2139                            throw processException(e);
2140                    }
2141                    finally {
2142                            closeSession(session);
2143                    }
2144            }
2145    
2146            /**
2147             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63;.
2148             *
2149             * @param entryId the primary key of the current blogs entry
2150             * @param groupId the group ID
2151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2152             * @return the previous, current, and next blogs entry
2153             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2157                    long groupId, OrderByComparator orderByComparator)
2158                    throws NoSuchEntryException, SystemException {
2159                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2160                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2161                    }
2162    
2163                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2164    
2165                    Session session = null;
2166    
2167                    try {
2168                            session = openSession();
2169    
2170                            BlogsEntry[] array = new BlogsEntryImpl[3];
2171    
2172                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2173                                            groupId, orderByComparator, true);
2174    
2175                            array[1] = blogsEntry;
2176    
2177                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2178                                            groupId, orderByComparator, false);
2179    
2180                            return array;
2181                    }
2182                    catch (Exception e) {
2183                            throw processException(e);
2184                    }
2185                    finally {
2186                            closeSession(session);
2187                    }
2188            }
2189    
2190            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2191                    BlogsEntry blogsEntry, long groupId,
2192                    OrderByComparator orderByComparator, boolean previous) {
2193                    StringBundler query = null;
2194    
2195                    if (orderByComparator != null) {
2196                            query = new StringBundler(6 +
2197                                            (orderByComparator.getOrderByFields().length * 6));
2198                    }
2199                    else {
2200                            query = new StringBundler(3);
2201                    }
2202    
2203                    if (getDB().isSupportsInlineDistinct()) {
2204                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2205                    }
2206                    else {
2207                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2208                    }
2209    
2210                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2211    
2212                    if (!getDB().isSupportsInlineDistinct()) {
2213                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2214                    }
2215    
2216                    if (orderByComparator != null) {
2217                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2218    
2219                            if (orderByConditionFields.length > 0) {
2220                                    query.append(WHERE_AND);
2221                            }
2222    
2223                            for (int i = 0; i < orderByConditionFields.length; i++) {
2224                                    if (getDB().isSupportsInlineDistinct()) {
2225                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2226                                    }
2227                                    else {
2228                                            query.append(_ORDER_BY_ENTITY_TABLE);
2229                                    }
2230    
2231                                    query.append(orderByConditionFields[i]);
2232    
2233                                    if ((i + 1) < orderByConditionFields.length) {
2234                                            if (orderByComparator.isAscending() ^ previous) {
2235                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2236                                            }
2237                                            else {
2238                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2239                                            }
2240                                    }
2241                                    else {
2242                                            if (orderByComparator.isAscending() ^ previous) {
2243                                                    query.append(WHERE_GREATER_THAN);
2244                                            }
2245                                            else {
2246                                                    query.append(WHERE_LESSER_THAN);
2247                                            }
2248                                    }
2249                            }
2250    
2251                            query.append(ORDER_BY_CLAUSE);
2252    
2253                            String[] orderByFields = orderByComparator.getOrderByFields();
2254    
2255                            for (int i = 0; i < orderByFields.length; i++) {
2256                                    if (getDB().isSupportsInlineDistinct()) {
2257                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2258                                    }
2259                                    else {
2260                                            query.append(_ORDER_BY_ENTITY_TABLE);
2261                                    }
2262    
2263                                    query.append(orderByFields[i]);
2264    
2265                                    if ((i + 1) < orderByFields.length) {
2266                                            if (orderByComparator.isAscending() ^ previous) {
2267                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2268                                            }
2269                                            else {
2270                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2271                                            }
2272                                    }
2273                                    else {
2274                                            if (orderByComparator.isAscending() ^ previous) {
2275                                                    query.append(ORDER_BY_ASC);
2276                                            }
2277                                            else {
2278                                                    query.append(ORDER_BY_DESC);
2279                                            }
2280                                    }
2281                            }
2282                    }
2283    
2284                    else {
2285                            if (getDB().isSupportsInlineDistinct()) {
2286                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2287                            }
2288                            else {
2289                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2290                            }
2291                    }
2292    
2293                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2294                                    BlogsEntry.class.getName(),
2295                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2296    
2297                    SQLQuery q = session.createSQLQuery(sql);
2298    
2299                    q.setFirstResult(0);
2300                    q.setMaxResults(2);
2301    
2302                    if (getDB().isSupportsInlineDistinct()) {
2303                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2304                    }
2305                    else {
2306                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2307                    }
2308    
2309                    QueryPos qPos = QueryPos.getInstance(q);
2310    
2311                    qPos.add(groupId);
2312    
2313                    if (orderByComparator != null) {
2314                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2315    
2316                            for (Object value : values) {
2317                                    qPos.add(value);
2318                            }
2319                    }
2320    
2321                    List<BlogsEntry> list = q.list();
2322    
2323                    if (list.size() == 2) {
2324                            return list.get(1);
2325                    }
2326                    else {
2327                            return null;
2328                    }
2329            }
2330    
2331            /**
2332             * Returns all the blogs entries where companyId = &#63;.
2333             *
2334             * @param companyId the company ID
2335             * @return the matching blogs entries
2336             * @throws SystemException if a system exception occurred
2337             */
2338            public List<BlogsEntry> findByCompanyId(long companyId)
2339                    throws SystemException {
2340                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2341                            null);
2342            }
2343    
2344            /**
2345             * Returns a range of all the blogs entries where companyId = &#63;.
2346             *
2347             * <p>
2348             * 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.
2349             * </p>
2350             *
2351             * @param companyId the company ID
2352             * @param start the lower bound of the range of blogs entries
2353             * @param end the upper bound of the range of blogs entries (not inclusive)
2354             * @return the range of matching blogs entries
2355             * @throws SystemException if a system exception occurred
2356             */
2357            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
2358                    throws SystemException {
2359                    return findByCompanyId(companyId, start, end, null);
2360            }
2361    
2362            /**
2363             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2364             *
2365             * <p>
2366             * 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.
2367             * </p>
2368             *
2369             * @param companyId the company ID
2370             * @param start the lower bound of the range of blogs entries
2371             * @param end the upper bound of the range of blogs entries (not inclusive)
2372             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2373             * @return the ordered range of matching blogs entries
2374             * @throws SystemException if a system exception occurred
2375             */
2376            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2377                    OrderByComparator orderByComparator) throws SystemException {
2378                    FinderPath finderPath = null;
2379                    Object[] finderArgs = null;
2380    
2381                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2382                                    (orderByComparator == null)) {
2383                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2384                            finderArgs = new Object[] { companyId };
2385                    }
2386                    else {
2387                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2388                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2389                    }
2390    
2391                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2392                                    finderArgs, this);
2393    
2394                    if ((list != null) && !list.isEmpty()) {
2395                            for (BlogsEntry blogsEntry : list) {
2396                                    if ((companyId != blogsEntry.getCompanyId())) {
2397                                            list = null;
2398    
2399                                            break;
2400                                    }
2401                            }
2402                    }
2403    
2404                    if (list == null) {
2405                            StringBundler query = null;
2406    
2407                            if (orderByComparator != null) {
2408                                    query = new StringBundler(3 +
2409                                                    (orderByComparator.getOrderByFields().length * 3));
2410                            }
2411                            else {
2412                                    query = new StringBundler(3);
2413                            }
2414    
2415                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2416    
2417                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2418    
2419                            if (orderByComparator != null) {
2420                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2421                                            orderByComparator);
2422                            }
2423    
2424                            else {
2425                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2426                            }
2427    
2428                            String sql = query.toString();
2429    
2430                            Session session = null;
2431    
2432                            try {
2433                                    session = openSession();
2434    
2435                                    Query q = session.createQuery(sql);
2436    
2437                                    QueryPos qPos = QueryPos.getInstance(q);
2438    
2439                                    qPos.add(companyId);
2440    
2441                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
2442                                                    end);
2443                            }
2444                            catch (Exception e) {
2445                                    throw processException(e);
2446                            }
2447                            finally {
2448                                    if (list == null) {
2449                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2450                                    }
2451                                    else {
2452                                            cacheResult(list);
2453    
2454                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2455                                    }
2456    
2457                                    closeSession(session);
2458                            }
2459                    }
2460    
2461                    return list;
2462            }
2463    
2464            /**
2465             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2466             *
2467             * @param companyId the company ID
2468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2469             * @return the first matching blogs entry
2470             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2471             * @throws SystemException if a system exception occurred
2472             */
2473            public BlogsEntry findByCompanyId_First(long companyId,
2474                    OrderByComparator orderByComparator)
2475                    throws NoSuchEntryException, SystemException {
2476                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2477                                    orderByComparator);
2478    
2479                    if (blogsEntry != null) {
2480                            return blogsEntry;
2481                    }
2482    
2483                    StringBundler msg = new StringBundler(4);
2484    
2485                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2486    
2487                    msg.append("companyId=");
2488                    msg.append(companyId);
2489    
2490                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2491    
2492                    throw new NoSuchEntryException(msg.toString());
2493            }
2494    
2495            /**
2496             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2497             *
2498             * @param companyId the company ID
2499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2500             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2501             * @throws SystemException if a system exception occurred
2502             */
2503            public BlogsEntry fetchByCompanyId_First(long companyId,
2504                    OrderByComparator orderByComparator) throws SystemException {
2505                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2506                                    orderByComparator);
2507    
2508                    if (!list.isEmpty()) {
2509                            return list.get(0);
2510                    }
2511    
2512                    return null;
2513            }
2514    
2515            /**
2516             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2517             *
2518             * @param companyId the company ID
2519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2520             * @return the last matching blogs entry
2521             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2522             * @throws SystemException if a system exception occurred
2523             */
2524            public BlogsEntry findByCompanyId_Last(long companyId,
2525                    OrderByComparator orderByComparator)
2526                    throws NoSuchEntryException, SystemException {
2527                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2528                                    orderByComparator);
2529    
2530                    if (blogsEntry != null) {
2531                            return blogsEntry;
2532                    }
2533    
2534                    StringBundler msg = new StringBundler(4);
2535    
2536                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2537    
2538                    msg.append("companyId=");
2539                    msg.append(companyId);
2540    
2541                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2542    
2543                    throw new NoSuchEntryException(msg.toString());
2544            }
2545    
2546            /**
2547             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2548             *
2549             * @param companyId the company ID
2550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2551             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2552             * @throws SystemException if a system exception occurred
2553             */
2554            public BlogsEntry fetchByCompanyId_Last(long companyId,
2555                    OrderByComparator orderByComparator) throws SystemException {
2556                    int count = countByCompanyId(companyId);
2557    
2558                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2559                                    orderByComparator);
2560    
2561                    if (!list.isEmpty()) {
2562                            return list.get(0);
2563                    }
2564    
2565                    return null;
2566            }
2567    
2568            /**
2569             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2570             *
2571             * @param entryId the primary key of the current blogs entry
2572             * @param companyId the company ID
2573             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2574             * @return the previous, current, and next blogs entry
2575             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2576             * @throws SystemException if a system exception occurred
2577             */
2578            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2579                    long companyId, OrderByComparator orderByComparator)
2580                    throws NoSuchEntryException, SystemException {
2581                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2582    
2583                    Session session = null;
2584    
2585                    try {
2586                            session = openSession();
2587    
2588                            BlogsEntry[] array = new BlogsEntryImpl[3];
2589    
2590                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2591                                            companyId, orderByComparator, true);
2592    
2593                            array[1] = blogsEntry;
2594    
2595                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2596                                            companyId, orderByComparator, false);
2597    
2598                            return array;
2599                    }
2600                    catch (Exception e) {
2601                            throw processException(e);
2602                    }
2603                    finally {
2604                            closeSession(session);
2605                    }
2606            }
2607    
2608            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2609                    BlogsEntry blogsEntry, long companyId,
2610                    OrderByComparator orderByComparator, boolean previous) {
2611                    StringBundler query = null;
2612    
2613                    if (orderByComparator != null) {
2614                            query = new StringBundler(6 +
2615                                            (orderByComparator.getOrderByFields().length * 6));
2616                    }
2617                    else {
2618                            query = new StringBundler(3);
2619                    }
2620    
2621                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2622    
2623                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2624    
2625                    if (orderByComparator != null) {
2626                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2627    
2628                            if (orderByConditionFields.length > 0) {
2629                                    query.append(WHERE_AND);
2630                            }
2631    
2632                            for (int i = 0; i < orderByConditionFields.length; i++) {
2633                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2634                                    query.append(orderByConditionFields[i]);
2635    
2636                                    if ((i + 1) < orderByConditionFields.length) {
2637                                            if (orderByComparator.isAscending() ^ previous) {
2638                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2639                                            }
2640                                            else {
2641                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2642                                            }
2643                                    }
2644                                    else {
2645                                            if (orderByComparator.isAscending() ^ previous) {
2646                                                    query.append(WHERE_GREATER_THAN);
2647                                            }
2648                                            else {
2649                                                    query.append(WHERE_LESSER_THAN);
2650                                            }
2651                                    }
2652                            }
2653    
2654                            query.append(ORDER_BY_CLAUSE);
2655    
2656                            String[] orderByFields = orderByComparator.getOrderByFields();
2657    
2658                            for (int i = 0; i < orderByFields.length; i++) {
2659                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2660                                    query.append(orderByFields[i]);
2661    
2662                                    if ((i + 1) < orderByFields.length) {
2663                                            if (orderByComparator.isAscending() ^ previous) {
2664                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2665                                            }
2666                                            else {
2667                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2668                                            }
2669                                    }
2670                                    else {
2671                                            if (orderByComparator.isAscending() ^ previous) {
2672                                                    query.append(ORDER_BY_ASC);
2673                                            }
2674                                            else {
2675                                                    query.append(ORDER_BY_DESC);
2676                                            }
2677                                    }
2678                            }
2679                    }
2680    
2681                    else {
2682                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2683                    }
2684    
2685                    String sql = query.toString();
2686    
2687                    Query q = session.createQuery(sql);
2688    
2689                    q.setFirstResult(0);
2690                    q.setMaxResults(2);
2691    
2692                    QueryPos qPos = QueryPos.getInstance(q);
2693    
2694                    qPos.add(companyId);
2695    
2696                    if (orderByComparator != null) {
2697                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2698    
2699                            for (Object value : values) {
2700                                    qPos.add(value);
2701                            }
2702                    }
2703    
2704                    List<BlogsEntry> list = q.list();
2705    
2706                    if (list.size() == 2) {
2707                            return list.get(1);
2708                    }
2709                    else {
2710                            return null;
2711                    }
2712            }
2713    
2714            /**
2715             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
2716             *
2717             * @param companyId the company ID
2718             * @param userId the user ID
2719             * @return the matching blogs entries
2720             * @throws SystemException if a system exception occurred
2721             */
2722            public List<BlogsEntry> findByC_U(long companyId, long userId)
2723                    throws SystemException {
2724                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
2725                            QueryUtil.ALL_POS, null);
2726            }
2727    
2728            /**
2729             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
2730             *
2731             * <p>
2732             * 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.
2733             * </p>
2734             *
2735             * @param companyId the company ID
2736             * @param userId the user ID
2737             * @param start the lower bound of the range of blogs entries
2738             * @param end the upper bound of the range of blogs entries (not inclusive)
2739             * @return the range of matching blogs entries
2740             * @throws SystemException if a system exception occurred
2741             */
2742            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2743                    int end) throws SystemException {
2744                    return findByC_U(companyId, userId, start, end, null);
2745            }
2746    
2747            /**
2748             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
2749             *
2750             * <p>
2751             * 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.
2752             * </p>
2753             *
2754             * @param companyId the company ID
2755             * @param userId the user ID
2756             * @param start the lower bound of the range of blogs entries
2757             * @param end the upper bound of the range of blogs entries (not inclusive)
2758             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2759             * @return the ordered range of matching blogs entries
2760             * @throws SystemException if a system exception occurred
2761             */
2762            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2763                    int end, OrderByComparator orderByComparator) throws SystemException {
2764                    FinderPath finderPath = null;
2765                    Object[] finderArgs = null;
2766    
2767                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2768                                    (orderByComparator == null)) {
2769                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
2770                            finderArgs = new Object[] { companyId, userId };
2771                    }
2772                    else {
2773                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
2774                            finderArgs = new Object[] {
2775                                            companyId, userId,
2776                                            
2777                                            start, end, orderByComparator
2778                                    };
2779                    }
2780    
2781                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2782                                    finderArgs, this);
2783    
2784                    if ((list != null) && !list.isEmpty()) {
2785                            for (BlogsEntry blogsEntry : list) {
2786                                    if ((companyId != blogsEntry.getCompanyId()) ||
2787                                                    (userId != blogsEntry.getUserId())) {
2788                                            list = null;
2789    
2790                                            break;
2791                                    }
2792                            }
2793                    }
2794    
2795                    if (list == null) {
2796                            StringBundler query = null;
2797    
2798                            if (orderByComparator != null) {
2799                                    query = new StringBundler(4 +
2800                                                    (orderByComparator.getOrderByFields().length * 3));
2801                            }
2802                            else {
2803                                    query = new StringBundler(4);
2804                            }
2805    
2806                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2807    
2808                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2809    
2810                            query.append(_FINDER_COLUMN_C_U_USERID_2);
2811    
2812                            if (orderByComparator != null) {
2813                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2814                                            orderByComparator);
2815                            }
2816    
2817                            else {
2818                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2819                            }
2820    
2821                            String sql = query.toString();
2822    
2823                            Session session = null;
2824    
2825                            try {
2826                                    session = openSession();
2827    
2828                                    Query q = session.createQuery(sql);
2829    
2830                                    QueryPos qPos = QueryPos.getInstance(q);
2831    
2832                                    qPos.add(companyId);
2833    
2834                                    qPos.add(userId);
2835    
2836                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
2837                                                    end);
2838                            }
2839                            catch (Exception e) {
2840                                    throw processException(e);
2841                            }
2842                            finally {
2843                                    if (list == null) {
2844                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2845                                    }
2846                                    else {
2847                                            cacheResult(list);
2848    
2849                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2850                                    }
2851    
2852                                    closeSession(session);
2853                            }
2854                    }
2855    
2856                    return list;
2857            }
2858    
2859            /**
2860             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2861             *
2862             * @param companyId the company ID
2863             * @param userId the user ID
2864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2865             * @return the first matching blogs entry
2866             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2867             * @throws SystemException if a system exception occurred
2868             */
2869            public BlogsEntry findByC_U_First(long companyId, long userId,
2870                    OrderByComparator orderByComparator)
2871                    throws NoSuchEntryException, SystemException {
2872                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
2873                                    orderByComparator);
2874    
2875                    if (blogsEntry != null) {
2876                            return blogsEntry;
2877                    }
2878    
2879                    StringBundler msg = new StringBundler(6);
2880    
2881                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2882    
2883                    msg.append("companyId=");
2884                    msg.append(companyId);
2885    
2886                    msg.append(", userId=");
2887                    msg.append(userId);
2888    
2889                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2890    
2891                    throw new NoSuchEntryException(msg.toString());
2892            }
2893    
2894            /**
2895             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2896             *
2897             * @param companyId the company ID
2898             * @param userId the user ID
2899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2900             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2901             * @throws SystemException if a system exception occurred
2902             */
2903            public BlogsEntry fetchByC_U_First(long companyId, long userId,
2904                    OrderByComparator orderByComparator) throws SystemException {
2905                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
2906                                    orderByComparator);
2907    
2908                    if (!list.isEmpty()) {
2909                            return list.get(0);
2910                    }
2911    
2912                    return null;
2913            }
2914    
2915            /**
2916             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2917             *
2918             * @param companyId the company ID
2919             * @param userId the user ID
2920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2921             * @return the last matching blogs entry
2922             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2923             * @throws SystemException if a system exception occurred
2924             */
2925            public BlogsEntry findByC_U_Last(long companyId, long userId,
2926                    OrderByComparator orderByComparator)
2927                    throws NoSuchEntryException, SystemException {
2928                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
2929                                    orderByComparator);
2930    
2931                    if (blogsEntry != null) {
2932                            return blogsEntry;
2933                    }
2934    
2935                    StringBundler msg = new StringBundler(6);
2936    
2937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2938    
2939                    msg.append("companyId=");
2940                    msg.append(companyId);
2941    
2942                    msg.append(", userId=");
2943                    msg.append(userId);
2944    
2945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2946    
2947                    throw new NoSuchEntryException(msg.toString());
2948            }
2949    
2950            /**
2951             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2952             *
2953             * @param companyId the company ID
2954             * @param userId the user ID
2955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2956             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2957             * @throws SystemException if a system exception occurred
2958             */
2959            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
2960                    OrderByComparator orderByComparator) throws SystemException {
2961                    int count = countByC_U(companyId, userId);
2962    
2963                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
2964                                    orderByComparator);
2965    
2966                    if (!list.isEmpty()) {
2967                            return list.get(0);
2968                    }
2969    
2970                    return null;
2971            }
2972    
2973            /**
2974             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2975             *
2976             * @param entryId the primary key of the current blogs entry
2977             * @param companyId the company ID
2978             * @param userId the user ID
2979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2980             * @return the previous, current, and next blogs entry
2981             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2982             * @throws SystemException if a system exception occurred
2983             */
2984            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
2985                    long userId, OrderByComparator orderByComparator)
2986                    throws NoSuchEntryException, SystemException {
2987                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2988    
2989                    Session session = null;
2990    
2991                    try {
2992                            session = openSession();
2993    
2994                            BlogsEntry[] array = new BlogsEntryImpl[3];
2995    
2996                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
2997                                            userId, orderByComparator, true);
2998    
2999                            array[1] = blogsEntry;
3000    
3001                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3002                                            userId, orderByComparator, false);
3003    
3004                            return array;
3005                    }
3006                    catch (Exception e) {
3007                            throw processException(e);
3008                    }
3009                    finally {
3010                            closeSession(session);
3011                    }
3012            }
3013    
3014            protected BlogsEntry getByC_U_PrevAndNext(Session session,
3015                    BlogsEntry blogsEntry, long companyId, long userId,
3016                    OrderByComparator orderByComparator, boolean previous) {
3017                    StringBundler query = null;
3018    
3019                    if (orderByComparator != null) {
3020                            query = new StringBundler(6 +
3021                                            (orderByComparator.getOrderByFields().length * 6));
3022                    }
3023                    else {
3024                            query = new StringBundler(3);
3025                    }
3026    
3027                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3028    
3029                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3030    
3031                    query.append(_FINDER_COLUMN_C_U_USERID_2);
3032    
3033                    if (orderByComparator != null) {
3034                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3035    
3036                            if (orderByConditionFields.length > 0) {
3037                                    query.append(WHERE_AND);
3038                            }
3039    
3040                            for (int i = 0; i < orderByConditionFields.length; i++) {
3041                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3042                                    query.append(orderByConditionFields[i]);
3043    
3044                                    if ((i + 1) < orderByConditionFields.length) {
3045                                            if (orderByComparator.isAscending() ^ previous) {
3046                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3047                                            }
3048                                            else {
3049                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3050                                            }
3051                                    }
3052                                    else {
3053                                            if (orderByComparator.isAscending() ^ previous) {
3054                                                    query.append(WHERE_GREATER_THAN);
3055                                            }
3056                                            else {
3057                                                    query.append(WHERE_LESSER_THAN);
3058                                            }
3059                                    }
3060                            }
3061    
3062                            query.append(ORDER_BY_CLAUSE);
3063    
3064                            String[] orderByFields = orderByComparator.getOrderByFields();
3065    
3066                            for (int i = 0; i < orderByFields.length; i++) {
3067                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3068                                    query.append(orderByFields[i]);
3069    
3070                                    if ((i + 1) < orderByFields.length) {
3071                                            if (orderByComparator.isAscending() ^ previous) {
3072                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3073                                            }
3074                                            else {
3075                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3076                                            }
3077                                    }
3078                                    else {
3079                                            if (orderByComparator.isAscending() ^ previous) {
3080                                                    query.append(ORDER_BY_ASC);
3081                                            }
3082                                            else {
3083                                                    query.append(ORDER_BY_DESC);
3084                                            }
3085                                    }
3086                            }
3087                    }
3088    
3089                    else {
3090                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3091                    }
3092    
3093                    String sql = query.toString();
3094    
3095                    Query q = session.createQuery(sql);
3096    
3097                    q.setFirstResult(0);
3098                    q.setMaxResults(2);
3099    
3100                    QueryPos qPos = QueryPos.getInstance(q);
3101    
3102                    qPos.add(companyId);
3103    
3104                    qPos.add(userId);
3105    
3106                    if (orderByComparator != null) {
3107                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3108    
3109                            for (Object value : values) {
3110                                    qPos.add(value);
3111                            }
3112                    }
3113    
3114                    List<BlogsEntry> list = q.list();
3115    
3116                    if (list.size() == 2) {
3117                            return list.get(1);
3118                    }
3119                    else {
3120                            return null;
3121                    }
3122            }
3123    
3124            /**
3125             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3126             *
3127             * @param companyId the company ID
3128             * @param displayDate the display date
3129             * @return the matching blogs entries
3130             * @throws SystemException if a system exception occurred
3131             */
3132            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate)
3133                    throws SystemException {
3134                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
3135                            QueryUtil.ALL_POS, null);
3136            }
3137    
3138            /**
3139             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3140             *
3141             * <p>
3142             * 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.
3143             * </p>
3144             *
3145             * @param companyId the company ID
3146             * @param displayDate the display date
3147             * @param start the lower bound of the range of blogs entries
3148             * @param end the upper bound of the range of blogs entries (not inclusive)
3149             * @return the range of matching blogs entries
3150             * @throws SystemException if a system exception occurred
3151             */
3152            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3153                    int start, int end) throws SystemException {
3154                    return findByC_LtD(companyId, displayDate, start, end, null);
3155            }
3156    
3157            /**
3158             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3159             *
3160             * <p>
3161             * 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.
3162             * </p>
3163             *
3164             * @param companyId the company ID
3165             * @param displayDate the display date
3166             * @param start the lower bound of the range of blogs entries
3167             * @param end the upper bound of the range of blogs entries (not inclusive)
3168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3169             * @return the ordered range of matching blogs entries
3170             * @throws SystemException if a system exception occurred
3171             */
3172            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3173                    int start, int end, OrderByComparator orderByComparator)
3174                    throws SystemException {
3175                    FinderPath finderPath = null;
3176                    Object[] finderArgs = null;
3177    
3178                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
3179                    finderArgs = new Object[] {
3180                                    companyId, displayDate,
3181                                    
3182                                    start, end, orderByComparator
3183                            };
3184    
3185                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3186                                    finderArgs, this);
3187    
3188                    if ((list != null) && !list.isEmpty()) {
3189                            for (BlogsEntry blogsEntry : list) {
3190                                    if ((companyId != blogsEntry.getCompanyId()) ||
3191                                                    !Validator.equals(displayDate,
3192                                                            blogsEntry.getDisplayDate())) {
3193                                            list = null;
3194    
3195                                            break;
3196                                    }
3197                            }
3198                    }
3199    
3200                    if (list == null) {
3201                            StringBundler query = null;
3202    
3203                            if (orderByComparator != null) {
3204                                    query = new StringBundler(4 +
3205                                                    (orderByComparator.getOrderByFields().length * 3));
3206                            }
3207                            else {
3208                                    query = new StringBundler(4);
3209                            }
3210    
3211                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3212    
3213                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3214    
3215                            if (displayDate == null) {
3216                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3217                            }
3218                            else {
3219                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3220                            }
3221    
3222                            if (orderByComparator != null) {
3223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3224                                            orderByComparator);
3225                            }
3226    
3227                            else {
3228                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3229                            }
3230    
3231                            String sql = query.toString();
3232    
3233                            Session session = null;
3234    
3235                            try {
3236                                    session = openSession();
3237    
3238                                    Query q = session.createQuery(sql);
3239    
3240                                    QueryPos qPos = QueryPos.getInstance(q);
3241    
3242                                    qPos.add(companyId);
3243    
3244                                    if (displayDate != null) {
3245                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3246                                    }
3247    
3248                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
3249                                                    end);
3250                            }
3251                            catch (Exception e) {
3252                                    throw processException(e);
3253                            }
3254                            finally {
3255                                    if (list == null) {
3256                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3257                                    }
3258                                    else {
3259                                            cacheResult(list);
3260    
3261                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3262                                    }
3263    
3264                                    closeSession(session);
3265                            }
3266                    }
3267    
3268                    return list;
3269            }
3270    
3271            /**
3272             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3273             *
3274             * @param companyId the company ID
3275             * @param displayDate the display date
3276             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3277             * @return the first matching blogs entry
3278             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3279             * @throws SystemException if a system exception occurred
3280             */
3281            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
3282                    OrderByComparator orderByComparator)
3283                    throws NoSuchEntryException, SystemException {
3284                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
3285                                    orderByComparator);
3286    
3287                    if (blogsEntry != null) {
3288                            return blogsEntry;
3289                    }
3290    
3291                    StringBundler msg = new StringBundler(6);
3292    
3293                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3294    
3295                    msg.append("companyId=");
3296                    msg.append(companyId);
3297    
3298                    msg.append(", displayDate=");
3299                    msg.append(displayDate);
3300    
3301                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3302    
3303                    throw new NoSuchEntryException(msg.toString());
3304            }
3305    
3306            /**
3307             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3308             *
3309             * @param companyId the company ID
3310             * @param displayDate the display date
3311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3312             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3313             * @throws SystemException if a system exception occurred
3314             */
3315            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
3316                    OrderByComparator orderByComparator) throws SystemException {
3317                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
3318                                    orderByComparator);
3319    
3320                    if (!list.isEmpty()) {
3321                            return list.get(0);
3322                    }
3323    
3324                    return null;
3325            }
3326    
3327            /**
3328             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3329             *
3330             * @param companyId the company ID
3331             * @param displayDate the display date
3332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3333             * @return the last matching blogs entry
3334             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3335             * @throws SystemException if a system exception occurred
3336             */
3337            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
3338                    OrderByComparator orderByComparator)
3339                    throws NoSuchEntryException, SystemException {
3340                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
3341                                    orderByComparator);
3342    
3343                    if (blogsEntry != null) {
3344                            return blogsEntry;
3345                    }
3346    
3347                    StringBundler msg = new StringBundler(6);
3348    
3349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3350    
3351                    msg.append("companyId=");
3352                    msg.append(companyId);
3353    
3354                    msg.append(", displayDate=");
3355                    msg.append(displayDate);
3356    
3357                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3358    
3359                    throw new NoSuchEntryException(msg.toString());
3360            }
3361    
3362            /**
3363             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3364             *
3365             * @param companyId the company ID
3366             * @param displayDate the display date
3367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3368             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3369             * @throws SystemException if a system exception occurred
3370             */
3371            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
3372                    OrderByComparator orderByComparator) throws SystemException {
3373                    int count = countByC_LtD(companyId, displayDate);
3374    
3375                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
3376                                    count, orderByComparator);
3377    
3378                    if (!list.isEmpty()) {
3379                            return list.get(0);
3380                    }
3381    
3382                    return null;
3383            }
3384    
3385            /**
3386             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3387             *
3388             * @param entryId the primary key of the current blogs entry
3389             * @param companyId the company ID
3390             * @param displayDate the display date
3391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3392             * @return the previous, current, and next blogs entry
3393             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3394             * @throws SystemException if a system exception occurred
3395             */
3396            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
3397                    Date displayDate, OrderByComparator orderByComparator)
3398                    throws NoSuchEntryException, SystemException {
3399                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3400    
3401                    Session session = null;
3402    
3403                    try {
3404                            session = openSession();
3405    
3406                            BlogsEntry[] array = new BlogsEntryImpl[3];
3407    
3408                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3409                                            displayDate, orderByComparator, true);
3410    
3411                            array[1] = blogsEntry;
3412    
3413                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3414                                            displayDate, orderByComparator, false);
3415    
3416                            return array;
3417                    }
3418                    catch (Exception e) {
3419                            throw processException(e);
3420                    }
3421                    finally {
3422                            closeSession(session);
3423                    }
3424            }
3425    
3426            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
3427                    BlogsEntry blogsEntry, long companyId, Date displayDate,
3428                    OrderByComparator orderByComparator, boolean previous) {
3429                    StringBundler query = null;
3430    
3431                    if (orderByComparator != null) {
3432                            query = new StringBundler(6 +
3433                                            (orderByComparator.getOrderByFields().length * 6));
3434                    }
3435                    else {
3436                            query = new StringBundler(3);
3437                    }
3438    
3439                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3440    
3441                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3442    
3443                    if (displayDate == null) {
3444                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3445                    }
3446                    else {
3447                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3448                    }
3449    
3450                    if (orderByComparator != null) {
3451                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3452    
3453                            if (orderByConditionFields.length > 0) {
3454                                    query.append(WHERE_AND);
3455                            }
3456    
3457                            for (int i = 0; i < orderByConditionFields.length; i++) {
3458                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3459                                    query.append(orderByConditionFields[i]);
3460    
3461                                    if ((i + 1) < orderByConditionFields.length) {
3462                                            if (orderByComparator.isAscending() ^ previous) {
3463                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3464                                            }
3465                                            else {
3466                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3467                                            }
3468                                    }
3469                                    else {
3470                                            if (orderByComparator.isAscending() ^ previous) {
3471                                                    query.append(WHERE_GREATER_THAN);
3472                                            }
3473                                            else {
3474                                                    query.append(WHERE_LESSER_THAN);
3475                                            }
3476                                    }
3477                            }
3478    
3479                            query.append(ORDER_BY_CLAUSE);
3480    
3481                            String[] orderByFields = orderByComparator.getOrderByFields();
3482    
3483                            for (int i = 0; i < orderByFields.length; i++) {
3484                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3485                                    query.append(orderByFields[i]);
3486    
3487                                    if ((i + 1) < orderByFields.length) {
3488                                            if (orderByComparator.isAscending() ^ previous) {
3489                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3490                                            }
3491                                            else {
3492                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3493                                            }
3494                                    }
3495                                    else {
3496                                            if (orderByComparator.isAscending() ^ previous) {
3497                                                    query.append(ORDER_BY_ASC);
3498                                            }
3499                                            else {
3500                                                    query.append(ORDER_BY_DESC);
3501                                            }
3502                                    }
3503                            }
3504                    }
3505    
3506                    else {
3507                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3508                    }
3509    
3510                    String sql = query.toString();
3511    
3512                    Query q = session.createQuery(sql);
3513    
3514                    q.setFirstResult(0);
3515                    q.setMaxResults(2);
3516    
3517                    QueryPos qPos = QueryPos.getInstance(q);
3518    
3519                    qPos.add(companyId);
3520    
3521                    if (displayDate != null) {
3522                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3523                    }
3524    
3525                    if (orderByComparator != null) {
3526                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3527    
3528                            for (Object value : values) {
3529                                    qPos.add(value);
3530                            }
3531                    }
3532    
3533                    List<BlogsEntry> list = q.list();
3534    
3535                    if (list.size() == 2) {
3536                            return list.get(1);
3537                    }
3538                    else {
3539                            return null;
3540                    }
3541            }
3542    
3543            /**
3544             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
3545             *
3546             * @param companyId the company ID
3547             * @param status the status
3548             * @return the matching blogs entries
3549             * @throws SystemException if a system exception occurred
3550             */
3551            public List<BlogsEntry> findByC_S(long companyId, int status)
3552                    throws SystemException {
3553                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
3554                            QueryUtil.ALL_POS, null);
3555            }
3556    
3557            /**
3558             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
3559             *
3560             * <p>
3561             * 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.
3562             * </p>
3563             *
3564             * @param companyId the company ID
3565             * @param status the status
3566             * @param start the lower bound of the range of blogs entries
3567             * @param end the upper bound of the range of blogs entries (not inclusive)
3568             * @return the range of matching blogs entries
3569             * @throws SystemException if a system exception occurred
3570             */
3571            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
3572                    int end) throws SystemException {
3573                    return findByC_S(companyId, status, start, end, null);
3574            }
3575    
3576            /**
3577             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
3578             *
3579             * <p>
3580             * 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.
3581             * </p>
3582             *
3583             * @param companyId the company ID
3584             * @param status the status
3585             * @param start the lower bound of the range of blogs entries
3586             * @param end the upper bound of the range of blogs entries (not inclusive)
3587             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3588             * @return the ordered range of matching blogs entries
3589             * @throws SystemException if a system exception occurred
3590             */
3591            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
3592                    int end, OrderByComparator orderByComparator) throws SystemException {
3593                    FinderPath finderPath = null;
3594                    Object[] finderArgs = null;
3595    
3596                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3597                                    (orderByComparator == null)) {
3598                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3599                            finderArgs = new Object[] { companyId, status };
3600                    }
3601                    else {
3602                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3603                            finderArgs = new Object[] {
3604                                            companyId, status,
3605                                            
3606                                            start, end, orderByComparator
3607                                    };
3608                    }
3609    
3610                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3611                                    finderArgs, this);
3612    
3613                    if ((list != null) && !list.isEmpty()) {
3614                            for (BlogsEntry blogsEntry : list) {
3615                                    if ((companyId != blogsEntry.getCompanyId()) ||
3616                                                    (status != blogsEntry.getStatus())) {
3617                                            list = null;
3618    
3619                                            break;
3620                                    }
3621                            }
3622                    }
3623    
3624                    if (list == null) {
3625                            StringBundler query = null;
3626    
3627                            if (orderByComparator != null) {
3628                                    query = new StringBundler(4 +
3629                                                    (orderByComparator.getOrderByFields().length * 3));
3630                            }
3631                            else {
3632                                    query = new StringBundler(4);
3633                            }
3634    
3635                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3636    
3637                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3638    
3639                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
3640    
3641                            if (orderByComparator != null) {
3642                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3643                                            orderByComparator);
3644                            }
3645    
3646                            else {
3647                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3648                            }
3649    
3650                            String sql = query.toString();
3651    
3652                            Session session = null;
3653    
3654                            try {
3655                                    session = openSession();
3656    
3657                                    Query q = session.createQuery(sql);
3658    
3659                                    QueryPos qPos = QueryPos.getInstance(q);
3660    
3661                                    qPos.add(companyId);
3662    
3663                                    qPos.add(status);
3664    
3665                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
3666                                                    end);
3667                            }
3668                            catch (Exception e) {
3669                                    throw processException(e);
3670                            }
3671                            finally {
3672                                    if (list == null) {
3673                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3674                                    }
3675                                    else {
3676                                            cacheResult(list);
3677    
3678                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3679                                    }
3680    
3681                                    closeSession(session);
3682                            }
3683                    }
3684    
3685                    return list;
3686            }
3687    
3688            /**
3689             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
3690             *
3691             * @param companyId the company ID
3692             * @param status the status
3693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3694             * @return the first matching blogs entry
3695             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3696             * @throws SystemException if a system exception occurred
3697             */
3698            public BlogsEntry findByC_S_First(long companyId, int status,
3699                    OrderByComparator orderByComparator)
3700                    throws NoSuchEntryException, SystemException {
3701                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
3702                                    orderByComparator);
3703    
3704                    if (blogsEntry != null) {
3705                            return blogsEntry;
3706                    }
3707    
3708                    StringBundler msg = new StringBundler(6);
3709    
3710                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3711    
3712                    msg.append("companyId=");
3713                    msg.append(companyId);
3714    
3715                    msg.append(", status=");
3716                    msg.append(status);
3717    
3718                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3719    
3720                    throw new NoSuchEntryException(msg.toString());
3721            }
3722    
3723            /**
3724             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
3725             *
3726             * @param companyId the company ID
3727             * @param status the status
3728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3729             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3730             * @throws SystemException if a system exception occurred
3731             */
3732            public BlogsEntry fetchByC_S_First(long companyId, int status,
3733                    OrderByComparator orderByComparator) throws SystemException {
3734                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
3735                                    orderByComparator);
3736    
3737                    if (!list.isEmpty()) {
3738                            return list.get(0);
3739                    }
3740    
3741                    return null;
3742            }
3743    
3744            /**
3745             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
3746             *
3747             * @param companyId the company ID
3748             * @param status the status
3749             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3750             * @return the last matching blogs entry
3751             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3752             * @throws SystemException if a system exception occurred
3753             */
3754            public BlogsEntry findByC_S_Last(long companyId, int status,
3755                    OrderByComparator orderByComparator)
3756                    throws NoSuchEntryException, SystemException {
3757                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
3758                                    orderByComparator);
3759    
3760                    if (blogsEntry != null) {
3761                            return blogsEntry;
3762                    }
3763    
3764                    StringBundler msg = new StringBundler(6);
3765    
3766                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3767    
3768                    msg.append("companyId=");
3769                    msg.append(companyId);
3770    
3771                    msg.append(", status=");
3772                    msg.append(status);
3773    
3774                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3775    
3776                    throw new NoSuchEntryException(msg.toString());
3777            }
3778    
3779            /**
3780             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
3781             *
3782             * @param companyId the company ID
3783             * @param status the status
3784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3785             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3786             * @throws SystemException if a system exception occurred
3787             */
3788            public BlogsEntry fetchByC_S_Last(long companyId, int status,
3789                    OrderByComparator orderByComparator) throws SystemException {
3790                    int count = countByC_S(companyId, status);
3791    
3792                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
3793                                    orderByComparator);
3794    
3795                    if (!list.isEmpty()) {
3796                            return list.get(0);
3797                    }
3798    
3799                    return null;
3800            }
3801    
3802            /**
3803             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
3804             *
3805             * @param entryId the primary key of the current blogs entry
3806             * @param companyId the company ID
3807             * @param status the status
3808             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3809             * @return the previous, current, and next blogs entry
3810             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3811             * @throws SystemException if a system exception occurred
3812             */
3813            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
3814                    int status, OrderByComparator orderByComparator)
3815                    throws NoSuchEntryException, SystemException {
3816                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3817    
3818                    Session session = null;
3819    
3820                    try {
3821                            session = openSession();
3822    
3823                            BlogsEntry[] array = new BlogsEntryImpl[3];
3824    
3825                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
3826                                            status, orderByComparator, true);
3827    
3828                            array[1] = blogsEntry;
3829    
3830                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
3831                                            status, orderByComparator, false);
3832    
3833                            return array;
3834                    }
3835                    catch (Exception e) {
3836                            throw processException(e);
3837                    }
3838                    finally {
3839                            closeSession(session);
3840                    }
3841            }
3842    
3843            protected BlogsEntry getByC_S_PrevAndNext(Session session,
3844                    BlogsEntry blogsEntry, long companyId, int status,
3845                    OrderByComparator orderByComparator, boolean previous) {
3846                    StringBundler query = null;
3847    
3848                    if (orderByComparator != null) {
3849                            query = new StringBundler(6 +
3850                                            (orderByComparator.getOrderByFields().length * 6));
3851                    }
3852                    else {
3853                            query = new StringBundler(3);
3854                    }
3855    
3856                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3857    
3858                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3859    
3860                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
3861    
3862                    if (orderByComparator != null) {
3863                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3864    
3865                            if (orderByConditionFields.length > 0) {
3866                                    query.append(WHERE_AND);
3867                            }
3868    
3869                            for (int i = 0; i < orderByConditionFields.length; i++) {
3870                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3871                                    query.append(orderByConditionFields[i]);
3872    
3873                                    if ((i + 1) < orderByConditionFields.length) {
3874                                            if (orderByComparator.isAscending() ^ previous) {
3875                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3876                                            }
3877                                            else {
3878                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3879                                            }
3880                                    }
3881                                    else {
3882                                            if (orderByComparator.isAscending() ^ previous) {
3883                                                    query.append(WHERE_GREATER_THAN);
3884                                            }
3885                                            else {
3886                                                    query.append(WHERE_LESSER_THAN);
3887                                            }
3888                                    }
3889                            }
3890    
3891                            query.append(ORDER_BY_CLAUSE);
3892    
3893                            String[] orderByFields = orderByComparator.getOrderByFields();
3894    
3895                            for (int i = 0; i < orderByFields.length; i++) {
3896                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3897                                    query.append(orderByFields[i]);
3898    
3899                                    if ((i + 1) < orderByFields.length) {
3900                                            if (orderByComparator.isAscending() ^ previous) {
3901                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3902                                            }
3903                                            else {
3904                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3905                                            }
3906                                    }
3907                                    else {
3908                                            if (orderByComparator.isAscending() ^ previous) {
3909                                                    query.append(ORDER_BY_ASC);
3910                                            }
3911                                            else {
3912                                                    query.append(ORDER_BY_DESC);
3913                                            }
3914                                    }
3915                            }
3916                    }
3917    
3918                    else {
3919                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3920                    }
3921    
3922                    String sql = query.toString();
3923    
3924                    Query q = session.createQuery(sql);
3925    
3926                    q.setFirstResult(0);
3927                    q.setMaxResults(2);
3928    
3929                    QueryPos qPos = QueryPos.getInstance(q);
3930    
3931                    qPos.add(companyId);
3932    
3933                    qPos.add(status);
3934    
3935                    if (orderByComparator != null) {
3936                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3937    
3938                            for (Object value : values) {
3939                                    qPos.add(value);
3940                            }
3941                    }
3942    
3943                    List<BlogsEntry> list = q.list();
3944    
3945                    if (list.size() == 2) {
3946                            return list.get(1);
3947                    }
3948                    else {
3949                            return null;
3950                    }
3951            }
3952    
3953            /**
3954             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
3955             *
3956             * @param groupId the group ID
3957             * @param urlTitle the url title
3958             * @return the matching blogs entry
3959             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3960             * @throws SystemException if a system exception occurred
3961             */
3962            public BlogsEntry findByG_UT(long groupId, String urlTitle)
3963                    throws NoSuchEntryException, SystemException {
3964                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
3965    
3966                    if (blogsEntry == null) {
3967                            StringBundler msg = new StringBundler(6);
3968    
3969                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3970    
3971                            msg.append("groupId=");
3972                            msg.append(groupId);
3973    
3974                            msg.append(", urlTitle=");
3975                            msg.append(urlTitle);
3976    
3977                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3978    
3979                            if (_log.isWarnEnabled()) {
3980                                    _log.warn(msg.toString());
3981                            }
3982    
3983                            throw new NoSuchEntryException(msg.toString());
3984                    }
3985    
3986                    return blogsEntry;
3987            }
3988    
3989            /**
3990             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3991             *
3992             * @param groupId the group ID
3993             * @param urlTitle the url title
3994             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3995             * @throws SystemException if a system exception occurred
3996             */
3997            public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
3998                    throws SystemException {
3999                    return fetchByG_UT(groupId, urlTitle, true);
4000            }
4001    
4002            /**
4003             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4004             *
4005             * @param groupId the group ID
4006             * @param urlTitle the url title
4007             * @param retrieveFromCache whether to use the finder cache
4008             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4009             * @throws SystemException if a system exception occurred
4010             */
4011            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
4012                    boolean retrieveFromCache) throws SystemException {
4013                    Object[] finderArgs = new Object[] { groupId, urlTitle };
4014    
4015                    Object result = null;
4016    
4017                    if (retrieveFromCache) {
4018                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
4019                                            finderArgs, this);
4020                    }
4021    
4022                    if (result instanceof BlogsEntry) {
4023                            BlogsEntry blogsEntry = (BlogsEntry)result;
4024    
4025                            if ((groupId != blogsEntry.getGroupId()) ||
4026                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
4027                                    result = null;
4028                            }
4029                    }
4030    
4031                    if (result == null) {
4032                            StringBundler query = new StringBundler(4);
4033    
4034                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4035    
4036                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4037    
4038                            if (urlTitle == null) {
4039                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4040                            }
4041                            else {
4042                                    if (urlTitle.equals(StringPool.BLANK)) {
4043                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4044                                    }
4045                                    else {
4046                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4047                                    }
4048                            }
4049    
4050                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4051    
4052                            String sql = query.toString();
4053    
4054                            Session session = null;
4055    
4056                            try {
4057                                    session = openSession();
4058    
4059                                    Query q = session.createQuery(sql);
4060    
4061                                    QueryPos qPos = QueryPos.getInstance(q);
4062    
4063                                    qPos.add(groupId);
4064    
4065                                    if (urlTitle != null) {
4066                                            qPos.add(urlTitle);
4067                                    }
4068    
4069                                    List<BlogsEntry> list = q.list();
4070    
4071                                    result = list;
4072    
4073                                    BlogsEntry blogsEntry = null;
4074    
4075                                    if (list.isEmpty()) {
4076                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4077                                                    finderArgs, list);
4078                                    }
4079                                    else {
4080                                            blogsEntry = list.get(0);
4081    
4082                                            cacheResult(blogsEntry);
4083    
4084                                            if ((blogsEntry.getGroupId() != groupId) ||
4085                                                            (blogsEntry.getUrlTitle() == null) ||
4086                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
4087                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4088                                                            finderArgs, blogsEntry);
4089                                            }
4090                                    }
4091    
4092                                    return blogsEntry;
4093                            }
4094                            catch (Exception e) {
4095                                    throw processException(e);
4096                            }
4097                            finally {
4098                                    if (result == null) {
4099                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
4100                                                    finderArgs);
4101                                    }
4102    
4103                                    closeSession(session);
4104                            }
4105                    }
4106                    else {
4107                            if (result instanceof List<?>) {
4108                                    return null;
4109                            }
4110                            else {
4111                                    return (BlogsEntry)result;
4112                            }
4113                    }
4114            }
4115    
4116            /**
4117             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
4118             *
4119             * @param groupId the group ID
4120             * @param displayDate the display date
4121             * @return the matching blogs entries
4122             * @throws SystemException if a system exception occurred
4123             */
4124            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate)
4125                    throws SystemException {
4126                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
4127                            QueryUtil.ALL_POS, null);
4128            }
4129    
4130            /**
4131             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
4132             *
4133             * <p>
4134             * 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.
4135             * </p>
4136             *
4137             * @param groupId the group ID
4138             * @param displayDate the display date
4139             * @param start the lower bound of the range of blogs entries
4140             * @param end the upper bound of the range of blogs entries (not inclusive)
4141             * @return the range of matching blogs entries
4142             * @throws SystemException if a system exception occurred
4143             */
4144            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
4145                    int start, int end) throws SystemException {
4146                    return findByG_LtD(groupId, displayDate, start, end, null);
4147            }
4148    
4149            /**
4150             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
4151             *
4152             * <p>
4153             * 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.
4154             * </p>
4155             *
4156             * @param groupId the group ID
4157             * @param displayDate the display date
4158             * @param start the lower bound of the range of blogs entries
4159             * @param end the upper bound of the range of blogs entries (not inclusive)
4160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4161             * @return the ordered range of matching blogs entries
4162             * @throws SystemException if a system exception occurred
4163             */
4164            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
4165                    int start, int end, OrderByComparator orderByComparator)
4166                    throws SystemException {
4167                    FinderPath finderPath = null;
4168                    Object[] finderArgs = null;
4169    
4170                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
4171                    finderArgs = new Object[] {
4172                                    groupId, displayDate,
4173                                    
4174                                    start, end, orderByComparator
4175                            };
4176    
4177                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4178                                    finderArgs, this);
4179    
4180                    if ((list != null) && !list.isEmpty()) {
4181                            for (BlogsEntry blogsEntry : list) {
4182                                    if ((groupId != blogsEntry.getGroupId()) ||
4183                                                    !Validator.equals(displayDate,
4184                                                            blogsEntry.getDisplayDate())) {
4185                                            list = null;
4186    
4187                                            break;
4188                                    }
4189                            }
4190                    }
4191    
4192                    if (list == null) {
4193                            StringBundler query = null;
4194    
4195                            if (orderByComparator != null) {
4196                                    query = new StringBundler(4 +
4197                                                    (orderByComparator.getOrderByFields().length * 3));
4198                            }
4199                            else {
4200                                    query = new StringBundler(4);
4201                            }
4202    
4203                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4204    
4205                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4206    
4207                            if (displayDate == null) {
4208                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4209                            }
4210                            else {
4211                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4212                            }
4213    
4214                            if (orderByComparator != null) {
4215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4216                                            orderByComparator);
4217                            }
4218    
4219                            else {
4220                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4221                            }
4222    
4223                            String sql = query.toString();
4224    
4225                            Session session = null;
4226    
4227                            try {
4228                                    session = openSession();
4229    
4230                                    Query q = session.createQuery(sql);
4231    
4232                                    QueryPos qPos = QueryPos.getInstance(q);
4233    
4234                                    qPos.add(groupId);
4235    
4236                                    if (displayDate != null) {
4237                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
4238                                    }
4239    
4240                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
4241                                                    end);
4242                            }
4243                            catch (Exception e) {
4244                                    throw processException(e);
4245                            }
4246                            finally {
4247                                    if (list == null) {
4248                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4249                                    }
4250                                    else {
4251                                            cacheResult(list);
4252    
4253                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4254                                    }
4255    
4256                                    closeSession(session);
4257                            }
4258                    }
4259    
4260                    return list;
4261            }
4262    
4263            /**
4264             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
4265             *
4266             * @param groupId the group ID
4267             * @param displayDate the display date
4268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4269             * @return the first matching blogs entry
4270             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4271             * @throws SystemException if a system exception occurred
4272             */
4273            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
4274                    OrderByComparator orderByComparator)
4275                    throws NoSuchEntryException, SystemException {
4276                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
4277                                    orderByComparator);
4278    
4279                    if (blogsEntry != null) {
4280                            return blogsEntry;
4281                    }
4282    
4283                    StringBundler msg = new StringBundler(6);
4284    
4285                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4286    
4287                    msg.append("groupId=");
4288                    msg.append(groupId);
4289    
4290                    msg.append(", displayDate=");
4291                    msg.append(displayDate);
4292    
4293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4294    
4295                    throw new NoSuchEntryException(msg.toString());
4296            }
4297    
4298            /**
4299             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
4300             *
4301             * @param groupId the group ID
4302             * @param displayDate the display date
4303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4304             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4305             * @throws SystemException if a system exception occurred
4306             */
4307            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
4308                    OrderByComparator orderByComparator) throws SystemException {
4309                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
4310                                    orderByComparator);
4311    
4312                    if (!list.isEmpty()) {
4313                            return list.get(0);
4314                    }
4315    
4316                    return null;
4317            }
4318    
4319            /**
4320             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
4321             *
4322             * @param groupId the group ID
4323             * @param displayDate the display date
4324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4325             * @return the last matching blogs entry
4326             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4327             * @throws SystemException if a system exception occurred
4328             */
4329            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
4330                    OrderByComparator orderByComparator)
4331                    throws NoSuchEntryException, SystemException {
4332                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
4333                                    orderByComparator);
4334    
4335                    if (blogsEntry != null) {
4336                            return blogsEntry;
4337                    }
4338    
4339                    StringBundler msg = new StringBundler(6);
4340    
4341                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4342    
4343                    msg.append("groupId=");
4344                    msg.append(groupId);
4345    
4346                    msg.append(", displayDate=");
4347                    msg.append(displayDate);
4348    
4349                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4350    
4351                    throw new NoSuchEntryException(msg.toString());
4352            }
4353    
4354            /**
4355             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
4356             *
4357             * @param groupId the group ID
4358             * @param displayDate the display date
4359             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4360             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4361             * @throws SystemException if a system exception occurred
4362             */
4363            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
4364                    OrderByComparator orderByComparator) throws SystemException {
4365                    int count = countByG_LtD(groupId, displayDate);
4366    
4367                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
4368                                    count, orderByComparator);
4369    
4370                    if (!list.isEmpty()) {
4371                            return list.get(0);
4372                    }
4373    
4374                    return null;
4375            }
4376    
4377            /**
4378             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
4379             *
4380             * @param entryId the primary key of the current blogs entry
4381             * @param groupId the group ID
4382             * @param displayDate the display date
4383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4384             * @return the previous, current, and next blogs entry
4385             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4386             * @throws SystemException if a system exception occurred
4387             */
4388            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
4389                    Date displayDate, OrderByComparator orderByComparator)
4390                    throws NoSuchEntryException, SystemException {
4391                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4392    
4393                    Session session = null;
4394    
4395                    try {
4396                            session = openSession();
4397    
4398                            BlogsEntry[] array = new BlogsEntryImpl[3];
4399    
4400                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
4401                                            displayDate, orderByComparator, true);
4402    
4403                            array[1] = blogsEntry;
4404    
4405                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
4406                                            displayDate, orderByComparator, false);
4407    
4408                            return array;
4409                    }
4410                    catch (Exception e) {
4411                            throw processException(e);
4412                    }
4413                    finally {
4414                            closeSession(session);
4415                    }
4416            }
4417    
4418            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
4419                    BlogsEntry blogsEntry, long groupId, Date displayDate,
4420                    OrderByComparator orderByComparator, boolean previous) {
4421                    StringBundler query = null;
4422    
4423                    if (orderByComparator != null) {
4424                            query = new StringBundler(6 +
4425                                            (orderByComparator.getOrderByFields().length * 6));
4426                    }
4427                    else {
4428                            query = new StringBundler(3);
4429                    }
4430    
4431                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4432    
4433                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4434    
4435                    if (displayDate == null) {
4436                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4437                    }
4438                    else {
4439                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4440                    }
4441    
4442                    if (orderByComparator != null) {
4443                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4444    
4445                            if (orderByConditionFields.length > 0) {
4446                                    query.append(WHERE_AND);
4447                            }
4448    
4449                            for (int i = 0; i < orderByConditionFields.length; i++) {
4450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4451                                    query.append(orderByConditionFields[i]);
4452    
4453                                    if ((i + 1) < orderByConditionFields.length) {
4454                                            if (orderByComparator.isAscending() ^ previous) {
4455                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4456                                            }
4457                                            else {
4458                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4459                                            }
4460                                    }
4461                                    else {
4462                                            if (orderByComparator.isAscending() ^ previous) {
4463                                                    query.append(WHERE_GREATER_THAN);
4464                                            }
4465                                            else {
4466                                                    query.append(WHERE_LESSER_THAN);
4467                                            }
4468                                    }
4469                            }
4470    
4471                            query.append(ORDER_BY_CLAUSE);
4472    
4473                            String[] orderByFields = orderByComparator.getOrderByFields();
4474    
4475                            for (int i = 0; i < orderByFields.length; i++) {
4476                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4477                                    query.append(orderByFields[i]);
4478    
4479                                    if ((i + 1) < orderByFields.length) {
4480                                            if (orderByComparator.isAscending() ^ previous) {
4481                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4482                                            }
4483                                            else {
4484                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4485                                            }
4486                                    }
4487                                    else {
4488                                            if (orderByComparator.isAscending() ^ previous) {
4489                                                    query.append(ORDER_BY_ASC);
4490                                            }
4491                                            else {
4492                                                    query.append(ORDER_BY_DESC);
4493                                            }
4494                                    }
4495                            }
4496                    }
4497    
4498                    else {
4499                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4500                    }
4501    
4502                    String sql = query.toString();
4503    
4504                    Query q = session.createQuery(sql);
4505    
4506                    q.setFirstResult(0);
4507                    q.setMaxResults(2);
4508    
4509                    QueryPos qPos = QueryPos.getInstance(q);
4510    
4511                    qPos.add(groupId);
4512    
4513                    if (displayDate != null) {
4514                            qPos.add(CalendarUtil.getTimestamp(displayDate));
4515                    }
4516    
4517                    if (orderByComparator != null) {
4518                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4519    
4520                            for (Object value : values) {
4521                                    qPos.add(value);
4522                            }
4523                    }
4524    
4525                    List<BlogsEntry> list = q.list();
4526    
4527                    if (list.size() == 2) {
4528                            return list.get(1);
4529                    }
4530                    else {
4531                            return null;
4532                    }
4533            }
4534    
4535            /**
4536             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4537             *
4538             * @param groupId the group ID
4539             * @param displayDate the display date
4540             * @return the matching blogs entries that the user has permission to view
4541             * @throws SystemException if a system exception occurred
4542             */
4543            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate)
4544                    throws SystemException {
4545                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
4546                            QueryUtil.ALL_POS, null);
4547            }
4548    
4549            /**
4550             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4551             *
4552             * <p>
4553             * 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.
4554             * </p>
4555             *
4556             * @param groupId the group ID
4557             * @param displayDate the display date
4558             * @param start the lower bound of the range of blogs entries
4559             * @param end the upper bound of the range of blogs entries (not inclusive)
4560             * @return the range of matching blogs entries that the user has permission to view
4561             * @throws SystemException if a system exception occurred
4562             */
4563            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
4564                    int start, int end) throws SystemException {
4565                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
4566            }
4567    
4568            /**
4569             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
4570             *
4571             * <p>
4572             * 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.
4573             * </p>
4574             *
4575             * @param groupId the group ID
4576             * @param displayDate the display date
4577             * @param start the lower bound of the range of blogs entries
4578             * @param end the upper bound of the range of blogs entries (not inclusive)
4579             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4580             * @return the ordered range of matching blogs entries that the user has permission to view
4581             * @throws SystemException if a system exception occurred
4582             */
4583            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
4584                    int start, int end, OrderByComparator orderByComparator)
4585                    throws SystemException {
4586                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4587                            return findByG_LtD(groupId, displayDate, start, end,
4588                                    orderByComparator);
4589                    }
4590    
4591                    StringBundler query = null;
4592    
4593                    if (orderByComparator != null) {
4594                            query = new StringBundler(4 +
4595                                            (orderByComparator.getOrderByFields().length * 3));
4596                    }
4597                    else {
4598                            query = new StringBundler(4);
4599                    }
4600    
4601                    if (getDB().isSupportsInlineDistinct()) {
4602                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4603                    }
4604                    else {
4605                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4606                    }
4607    
4608                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4609    
4610                    if (displayDate == null) {
4611                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4612                    }
4613                    else {
4614                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4615                    }
4616    
4617                    if (!getDB().isSupportsInlineDistinct()) {
4618                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4619                    }
4620    
4621                    if (orderByComparator != null) {
4622                            if (getDB().isSupportsInlineDistinct()) {
4623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4624                                            orderByComparator);
4625                            }
4626                            else {
4627                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4628                                            orderByComparator);
4629                            }
4630                    }
4631    
4632                    else {
4633                            if (getDB().isSupportsInlineDistinct()) {
4634                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4635                            }
4636                            else {
4637                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4638                            }
4639                    }
4640    
4641                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4642                                    BlogsEntry.class.getName(),
4643                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4644    
4645                    Session session = null;
4646    
4647                    try {
4648                            session = openSession();
4649    
4650                            SQLQuery q = session.createSQLQuery(sql);
4651    
4652                            if (getDB().isSupportsInlineDistinct()) {
4653                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4654                            }
4655                            else {
4656                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4657                            }
4658    
4659                            QueryPos qPos = QueryPos.getInstance(q);
4660    
4661                            qPos.add(groupId);
4662    
4663                            if (displayDate != null) {
4664                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
4665                            }
4666    
4667                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4668                    }
4669                    catch (Exception e) {
4670                            throw processException(e);
4671                    }
4672                    finally {
4673                            closeSession(session);
4674                    }
4675            }
4676    
4677            /**
4678             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4679             *
4680             * @param entryId the primary key of the current blogs entry
4681             * @param groupId the group ID
4682             * @param displayDate the display date
4683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4684             * @return the previous, current, and next blogs entry
4685             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4686             * @throws SystemException if a system exception occurred
4687             */
4688            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
4689                    long groupId, Date displayDate, OrderByComparator orderByComparator)
4690                    throws NoSuchEntryException, SystemException {
4691                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4692                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
4693                                    orderByComparator);
4694                    }
4695    
4696                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4697    
4698                    Session session = null;
4699    
4700                    try {
4701                            session = openSession();
4702    
4703                            BlogsEntry[] array = new BlogsEntryImpl[3];
4704    
4705                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
4706                                            groupId, displayDate, orderByComparator, true);
4707    
4708                            array[1] = blogsEntry;
4709    
4710                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
4711                                            groupId, displayDate, orderByComparator, false);
4712    
4713                            return array;
4714                    }
4715                    catch (Exception e) {
4716                            throw processException(e);
4717                    }
4718                    finally {
4719                            closeSession(session);
4720                    }
4721            }
4722    
4723            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
4724                    BlogsEntry blogsEntry, long groupId, Date displayDate,
4725                    OrderByComparator orderByComparator, boolean previous) {
4726                    StringBundler query = null;
4727    
4728                    if (orderByComparator != null) {
4729                            query = new StringBundler(6 +
4730                                            (orderByComparator.getOrderByFields().length * 6));
4731                    }
4732                    else {
4733                            query = new StringBundler(3);
4734                    }
4735    
4736                    if (getDB().isSupportsInlineDistinct()) {
4737                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4738                    }
4739                    else {
4740                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4741                    }
4742    
4743                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4744    
4745                    if (displayDate == null) {
4746                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4747                    }
4748                    else {
4749                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4750                    }
4751    
4752                    if (!getDB().isSupportsInlineDistinct()) {
4753                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4754                    }
4755    
4756                    if (orderByComparator != null) {
4757                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4758    
4759                            if (orderByConditionFields.length > 0) {
4760                                    query.append(WHERE_AND);
4761                            }
4762    
4763                            for (int i = 0; i < orderByConditionFields.length; i++) {
4764                                    if (getDB().isSupportsInlineDistinct()) {
4765                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4766                                    }
4767                                    else {
4768                                            query.append(_ORDER_BY_ENTITY_TABLE);
4769                                    }
4770    
4771                                    query.append(orderByConditionFields[i]);
4772    
4773                                    if ((i + 1) < orderByConditionFields.length) {
4774                                            if (orderByComparator.isAscending() ^ previous) {
4775                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4776                                            }
4777                                            else {
4778                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4779                                            }
4780                                    }
4781                                    else {
4782                                            if (orderByComparator.isAscending() ^ previous) {
4783                                                    query.append(WHERE_GREATER_THAN);
4784                                            }
4785                                            else {
4786                                                    query.append(WHERE_LESSER_THAN);
4787                                            }
4788                                    }
4789                            }
4790    
4791                            query.append(ORDER_BY_CLAUSE);
4792    
4793                            String[] orderByFields = orderByComparator.getOrderByFields();
4794    
4795                            for (int i = 0; i < orderByFields.length; i++) {
4796                                    if (getDB().isSupportsInlineDistinct()) {
4797                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4798                                    }
4799                                    else {
4800                                            query.append(_ORDER_BY_ENTITY_TABLE);
4801                                    }
4802    
4803                                    query.append(orderByFields[i]);
4804    
4805                                    if ((i + 1) < orderByFields.length) {
4806                                            if (orderByComparator.isAscending() ^ previous) {
4807                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4808                                            }
4809                                            else {
4810                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4811                                            }
4812                                    }
4813                                    else {
4814                                            if (orderByComparator.isAscending() ^ previous) {
4815                                                    query.append(ORDER_BY_ASC);
4816                                            }
4817                                            else {
4818                                                    query.append(ORDER_BY_DESC);
4819                                            }
4820                                    }
4821                            }
4822                    }
4823    
4824                    else {
4825                            if (getDB().isSupportsInlineDistinct()) {
4826                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4827                            }
4828                            else {
4829                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4830                            }
4831                    }
4832    
4833                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4834                                    BlogsEntry.class.getName(),
4835                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4836    
4837                    SQLQuery q = session.createSQLQuery(sql);
4838    
4839                    q.setFirstResult(0);
4840                    q.setMaxResults(2);
4841    
4842                    if (getDB().isSupportsInlineDistinct()) {
4843                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4844                    }
4845                    else {
4846                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4847                    }
4848    
4849                    QueryPos qPos = QueryPos.getInstance(q);
4850    
4851                    qPos.add(groupId);
4852    
4853                    if (displayDate != null) {
4854                            qPos.add(CalendarUtil.getTimestamp(displayDate));
4855                    }
4856    
4857                    if (orderByComparator != null) {
4858                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4859    
4860                            for (Object value : values) {
4861                                    qPos.add(value);
4862                            }
4863                    }
4864    
4865                    List<BlogsEntry> list = q.list();
4866    
4867                    if (list.size() == 2) {
4868                            return list.get(1);
4869                    }
4870                    else {
4871                            return null;
4872                    }
4873            }
4874    
4875            /**
4876             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4877             *
4878             * @param groupId the group ID
4879             * @param status the status
4880             * @return the matching blogs entries
4881             * @throws SystemException if a system exception occurred
4882             */
4883            public List<BlogsEntry> findByG_S(long groupId, int status)
4884                    throws SystemException {
4885                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4886                            null);
4887            }
4888    
4889            /**
4890             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4891             *
4892             * <p>
4893             * 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.
4894             * </p>
4895             *
4896             * @param groupId the group ID
4897             * @param status the status
4898             * @param start the lower bound of the range of blogs entries
4899             * @param end the upper bound of the range of blogs entries (not inclusive)
4900             * @return the range of matching blogs entries
4901             * @throws SystemException if a system exception occurred
4902             */
4903            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4904                    int end) throws SystemException {
4905                    return findByG_S(groupId, status, start, end, null);
4906            }
4907    
4908            /**
4909             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4910             *
4911             * <p>
4912             * 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.
4913             * </p>
4914             *
4915             * @param groupId the group ID
4916             * @param status the status
4917             * @param start the lower bound of the range of blogs entries
4918             * @param end the upper bound of the range of blogs entries (not inclusive)
4919             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4920             * @return the ordered range of matching blogs entries
4921             * @throws SystemException if a system exception occurred
4922             */
4923            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4924                    int end, OrderByComparator orderByComparator) throws SystemException {
4925                    FinderPath finderPath = null;
4926                    Object[] finderArgs = null;
4927    
4928                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4929                                    (orderByComparator == null)) {
4930                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4931                            finderArgs = new Object[] { groupId, status };
4932                    }
4933                    else {
4934                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4935                            finderArgs = new Object[] {
4936                                            groupId, status,
4937                                            
4938                                            start, end, orderByComparator
4939                                    };
4940                    }
4941    
4942                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4943                                    finderArgs, this);
4944    
4945                    if ((list != null) && !list.isEmpty()) {
4946                            for (BlogsEntry blogsEntry : list) {
4947                                    if ((groupId != blogsEntry.getGroupId()) ||
4948                                                    (status != blogsEntry.getStatus())) {
4949                                            list = null;
4950    
4951                                            break;
4952                                    }
4953                            }
4954                    }
4955    
4956                    if (list == null) {
4957                            StringBundler query = null;
4958    
4959                            if (orderByComparator != null) {
4960                                    query = new StringBundler(4 +
4961                                                    (orderByComparator.getOrderByFields().length * 3));
4962                            }
4963                            else {
4964                                    query = new StringBundler(4);
4965                            }
4966    
4967                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4968    
4969                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4970    
4971                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4972    
4973                            if (orderByComparator != null) {
4974                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4975                                            orderByComparator);
4976                            }
4977    
4978                            else {
4979                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4980                            }
4981    
4982                            String sql = query.toString();
4983    
4984                            Session session = null;
4985    
4986                            try {
4987                                    session = openSession();
4988    
4989                                    Query q = session.createQuery(sql);
4990    
4991                                    QueryPos qPos = QueryPos.getInstance(q);
4992    
4993                                    qPos.add(groupId);
4994    
4995                                    qPos.add(status);
4996    
4997                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
4998                                                    end);
4999                            }
5000                            catch (Exception e) {
5001                                    throw processException(e);
5002                            }
5003                            finally {
5004                                    if (list == null) {
5005                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5006                                    }
5007                                    else {
5008                                            cacheResult(list);
5009    
5010                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5011                                    }
5012    
5013                                    closeSession(session);
5014                            }
5015                    }
5016    
5017                    return list;
5018            }
5019    
5020            /**
5021             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
5022             *
5023             * @param groupId the group ID
5024             * @param status the status
5025             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5026             * @return the first matching blogs entry
5027             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5028             * @throws SystemException if a system exception occurred
5029             */
5030            public BlogsEntry findByG_S_First(long groupId, int status,
5031                    OrderByComparator orderByComparator)
5032                    throws NoSuchEntryException, SystemException {
5033                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
5034                                    orderByComparator);
5035    
5036                    if (blogsEntry != null) {
5037                            return blogsEntry;
5038                    }
5039    
5040                    StringBundler msg = new StringBundler(6);
5041    
5042                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5043    
5044                    msg.append("groupId=");
5045                    msg.append(groupId);
5046    
5047                    msg.append(", status=");
5048                    msg.append(status);
5049    
5050                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5051    
5052                    throw new NoSuchEntryException(msg.toString());
5053            }
5054    
5055            /**
5056             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
5057             *
5058             * @param groupId the group ID
5059             * @param status the status
5060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5061             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5062             * @throws SystemException if a system exception occurred
5063             */
5064            public BlogsEntry fetchByG_S_First(long groupId, int status,
5065                    OrderByComparator orderByComparator) throws SystemException {
5066                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
5067                                    orderByComparator);
5068    
5069                    if (!list.isEmpty()) {
5070                            return list.get(0);
5071                    }
5072    
5073                    return null;
5074            }
5075    
5076            /**
5077             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
5078             *
5079             * @param groupId the group ID
5080             * @param status the status
5081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5082             * @return the last matching blogs entry
5083             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5084             * @throws SystemException if a system exception occurred
5085             */
5086            public BlogsEntry findByG_S_Last(long groupId, int status,
5087                    OrderByComparator orderByComparator)
5088                    throws NoSuchEntryException, SystemException {
5089                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
5090                                    orderByComparator);
5091    
5092                    if (blogsEntry != null) {
5093                            return blogsEntry;
5094                    }
5095    
5096                    StringBundler msg = new StringBundler(6);
5097    
5098                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5099    
5100                    msg.append("groupId=");
5101                    msg.append(groupId);
5102    
5103                    msg.append(", status=");
5104                    msg.append(status);
5105    
5106                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5107    
5108                    throw new NoSuchEntryException(msg.toString());
5109            }
5110    
5111            /**
5112             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
5113             *
5114             * @param groupId the group ID
5115             * @param status the status
5116             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5117             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5118             * @throws SystemException if a system exception occurred
5119             */
5120            public BlogsEntry fetchByG_S_Last(long groupId, int status,
5121                    OrderByComparator orderByComparator) throws SystemException {
5122                    int count = countByG_S(groupId, status);
5123    
5124                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
5125                                    orderByComparator);
5126    
5127                    if (!list.isEmpty()) {
5128                            return list.get(0);
5129                    }
5130    
5131                    return null;
5132            }
5133    
5134            /**
5135             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
5136             *
5137             * @param entryId the primary key of the current blogs entry
5138             * @param groupId the group ID
5139             * @param status the status
5140             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5141             * @return the previous, current, and next blogs entry
5142             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5143             * @throws SystemException if a system exception occurred
5144             */
5145            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
5146                    int status, OrderByComparator orderByComparator)
5147                    throws NoSuchEntryException, SystemException {
5148                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5149    
5150                    Session session = null;
5151    
5152                    try {
5153                            session = openSession();
5154    
5155                            BlogsEntry[] array = new BlogsEntryImpl[3];
5156    
5157                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
5158                                            status, orderByComparator, true);
5159    
5160                            array[1] = blogsEntry;
5161    
5162                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
5163                                            status, orderByComparator, false);
5164    
5165                            return array;
5166                    }
5167                    catch (Exception e) {
5168                            throw processException(e);
5169                    }
5170                    finally {
5171                            closeSession(session);
5172                    }
5173            }
5174    
5175            protected BlogsEntry getByG_S_PrevAndNext(Session session,
5176                    BlogsEntry blogsEntry, long groupId, int status,
5177                    OrderByComparator orderByComparator, boolean previous) {
5178                    StringBundler query = null;
5179    
5180                    if (orderByComparator != null) {
5181                            query = new StringBundler(6 +
5182                                            (orderByComparator.getOrderByFields().length * 6));
5183                    }
5184                    else {
5185                            query = new StringBundler(3);
5186                    }
5187    
5188                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5189    
5190                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5191    
5192                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
5193    
5194                    if (orderByComparator != null) {
5195                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5196    
5197                            if (orderByConditionFields.length > 0) {
5198                                    query.append(WHERE_AND);
5199                            }
5200    
5201                            for (int i = 0; i < orderByConditionFields.length; i++) {
5202                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5203                                    query.append(orderByConditionFields[i]);
5204    
5205                                    if ((i + 1) < orderByConditionFields.length) {
5206                                            if (orderByComparator.isAscending() ^ previous) {
5207                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5208                                            }
5209                                            else {
5210                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5211                                            }
5212                                    }
5213                                    else {
5214                                            if (orderByComparator.isAscending() ^ previous) {
5215                                                    query.append(WHERE_GREATER_THAN);
5216                                            }
5217                                            else {
5218                                                    query.append(WHERE_LESSER_THAN);
5219                                            }
5220                                    }
5221                            }
5222    
5223                            query.append(ORDER_BY_CLAUSE);
5224    
5225                            String[] orderByFields = orderByComparator.getOrderByFields();
5226    
5227                            for (int i = 0; i < orderByFields.length; i++) {
5228                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5229                                    query.append(orderByFields[i]);
5230    
5231                                    if ((i + 1) < orderByFields.length) {
5232                                            if (orderByComparator.isAscending() ^ previous) {
5233                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5234                                            }
5235                                            else {
5236                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5237                                            }
5238                                    }
5239                                    else {
5240                                            if (orderByComparator.isAscending() ^ previous) {
5241                                                    query.append(ORDER_BY_ASC);
5242                                            }
5243                                            else {
5244                                                    query.append(ORDER_BY_DESC);
5245                                            }
5246                                    }
5247                            }
5248                    }
5249    
5250                    else {
5251                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5252                    }
5253    
5254                    String sql = query.toString();
5255    
5256                    Query q = session.createQuery(sql);
5257    
5258                    q.setFirstResult(0);
5259                    q.setMaxResults(2);
5260    
5261                    QueryPos qPos = QueryPos.getInstance(q);
5262    
5263                    qPos.add(groupId);
5264    
5265                    qPos.add(status);
5266    
5267                    if (orderByComparator != null) {
5268                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5269    
5270                            for (Object value : values) {
5271                                    qPos.add(value);
5272                            }
5273                    }
5274    
5275                    List<BlogsEntry> list = q.list();
5276    
5277                    if (list.size() == 2) {
5278                            return list.get(1);
5279                    }
5280                    else {
5281                            return null;
5282                    }
5283            }
5284    
5285            /**
5286             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
5287             *
5288             * @param groupId the group ID
5289             * @param status the status
5290             * @return the matching blogs entries that the user has permission to view
5291             * @throws SystemException if a system exception occurred
5292             */
5293            public List<BlogsEntry> filterFindByG_S(long groupId, int status)
5294                    throws SystemException {
5295                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
5296                            QueryUtil.ALL_POS, null);
5297            }
5298    
5299            /**
5300             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
5301             *
5302             * <p>
5303             * 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.
5304             * </p>
5305             *
5306             * @param groupId the group ID
5307             * @param status the status
5308             * @param start the lower bound of the range of blogs entries
5309             * @param end the upper bound of the range of blogs entries (not inclusive)
5310             * @return the range of matching blogs entries that the user has permission to view
5311             * @throws SystemException if a system exception occurred
5312             */
5313            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
5314                    int start, int end) throws SystemException {
5315                    return filterFindByG_S(groupId, status, start, end, null);
5316            }
5317    
5318            /**
5319             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
5320             *
5321             * <p>
5322             * 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.
5323             * </p>
5324             *
5325             * @param groupId the group ID
5326             * @param status the status
5327             * @param start the lower bound of the range of blogs entries
5328             * @param end the upper bound of the range of blogs entries (not inclusive)
5329             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5330             * @return the ordered range of matching blogs entries that the user has permission to view
5331             * @throws SystemException if a system exception occurred
5332             */
5333            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
5334                    int start, int end, OrderByComparator orderByComparator)
5335                    throws SystemException {
5336                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5337                            return findByG_S(groupId, status, start, end, orderByComparator);
5338                    }
5339    
5340                    StringBundler query = null;
5341    
5342                    if (orderByComparator != null) {
5343                            query = new StringBundler(4 +
5344                                            (orderByComparator.getOrderByFields().length * 3));
5345                    }
5346                    else {
5347                            query = new StringBundler(4);
5348                    }
5349    
5350                    if (getDB().isSupportsInlineDistinct()) {
5351                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5352                    }
5353                    else {
5354                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5355                    }
5356    
5357                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5358    
5359                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
5360    
5361                    if (!getDB().isSupportsInlineDistinct()) {
5362                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5363                    }
5364    
5365                    if (orderByComparator != null) {
5366                            if (getDB().isSupportsInlineDistinct()) {
5367                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5368                                            orderByComparator);
5369                            }
5370                            else {
5371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5372                                            orderByComparator);
5373                            }
5374                    }
5375    
5376                    else {
5377                            if (getDB().isSupportsInlineDistinct()) {
5378                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5379                            }
5380                            else {
5381                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5382                            }
5383                    }
5384    
5385                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5386                                    BlogsEntry.class.getName(),
5387                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5388    
5389                    Session session = null;
5390    
5391                    try {
5392                            session = openSession();
5393    
5394                            SQLQuery q = session.createSQLQuery(sql);
5395    
5396                            if (getDB().isSupportsInlineDistinct()) {
5397                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5398                            }
5399                            else {
5400                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5401                            }
5402    
5403                            QueryPos qPos = QueryPos.getInstance(q);
5404    
5405                            qPos.add(groupId);
5406    
5407                            qPos.add(status);
5408    
5409                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5410                    }
5411                    catch (Exception e) {
5412                            throw processException(e);
5413                    }
5414                    finally {
5415                            closeSession(session);
5416                    }
5417            }
5418    
5419            /**
5420             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
5421             *
5422             * @param entryId the primary key of the current blogs entry
5423             * @param groupId the group ID
5424             * @param status the status
5425             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5426             * @return the previous, current, and next blogs entry
5427             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5428             * @throws SystemException if a system exception occurred
5429             */
5430            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
5431                    int status, OrderByComparator orderByComparator)
5432                    throws NoSuchEntryException, SystemException {
5433                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5434                            return findByG_S_PrevAndNext(entryId, groupId, status,
5435                                    orderByComparator);
5436                    }
5437    
5438                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5439    
5440                    Session session = null;
5441    
5442                    try {
5443                            session = openSession();
5444    
5445                            BlogsEntry[] array = new BlogsEntryImpl[3];
5446    
5447                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
5448                                            status, orderByComparator, true);
5449    
5450                            array[1] = blogsEntry;
5451    
5452                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
5453                                            status, orderByComparator, false);
5454    
5455                            return array;
5456                    }
5457                    catch (Exception e) {
5458                            throw processException(e);
5459                    }
5460                    finally {
5461                            closeSession(session);
5462                    }
5463            }
5464    
5465            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
5466                    BlogsEntry blogsEntry, long groupId, int status,
5467                    OrderByComparator orderByComparator, boolean previous) {
5468                    StringBundler query = null;
5469    
5470                    if (orderByComparator != null) {
5471                            query = new StringBundler(6 +
5472                                            (orderByComparator.getOrderByFields().length * 6));
5473                    }
5474                    else {
5475                            query = new StringBundler(3);
5476                    }
5477    
5478                    if (getDB().isSupportsInlineDistinct()) {
5479                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5480                    }
5481                    else {
5482                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5483                    }
5484    
5485                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5486    
5487                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
5488    
5489                    if (!getDB().isSupportsInlineDistinct()) {
5490                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5491                    }
5492    
5493                    if (orderByComparator != null) {
5494                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5495    
5496                            if (orderByConditionFields.length > 0) {
5497                                    query.append(WHERE_AND);
5498                            }
5499    
5500                            for (int i = 0; i < orderByConditionFields.length; i++) {
5501                                    if (getDB().isSupportsInlineDistinct()) {
5502                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5503                                    }
5504                                    else {
5505                                            query.append(_ORDER_BY_ENTITY_TABLE);
5506                                    }
5507    
5508                                    query.append(orderByConditionFields[i]);
5509    
5510                                    if ((i + 1) < orderByConditionFields.length) {
5511                                            if (orderByComparator.isAscending() ^ previous) {
5512                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5513                                            }
5514                                            else {
5515                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5516                                            }
5517                                    }
5518                                    else {
5519                                            if (orderByComparator.isAscending() ^ previous) {
5520                                                    query.append(WHERE_GREATER_THAN);
5521                                            }
5522                                            else {
5523                                                    query.append(WHERE_LESSER_THAN);
5524                                            }
5525                                    }
5526                            }
5527    
5528                            query.append(ORDER_BY_CLAUSE);
5529    
5530                            String[] orderByFields = orderByComparator.getOrderByFields();
5531    
5532                            for (int i = 0; i < orderByFields.length; i++) {
5533                                    if (getDB().isSupportsInlineDistinct()) {
5534                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5535                                    }
5536                                    else {
5537                                            query.append(_ORDER_BY_ENTITY_TABLE);
5538                                    }
5539    
5540                                    query.append(orderByFields[i]);
5541    
5542                                    if ((i + 1) < orderByFields.length) {
5543                                            if (orderByComparator.isAscending() ^ previous) {
5544                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5545                                            }
5546                                            else {
5547                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5548                                            }
5549                                    }
5550                                    else {
5551                                            if (orderByComparator.isAscending() ^ previous) {
5552                                                    query.append(ORDER_BY_ASC);
5553                                            }
5554                                            else {
5555                                                    query.append(ORDER_BY_DESC);
5556                                            }
5557                                    }
5558                            }
5559                    }
5560    
5561                    else {
5562                            if (getDB().isSupportsInlineDistinct()) {
5563                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5564                            }
5565                            else {
5566                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5567                            }
5568                    }
5569    
5570                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5571                                    BlogsEntry.class.getName(),
5572                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5573    
5574                    SQLQuery q = session.createSQLQuery(sql);
5575    
5576                    q.setFirstResult(0);
5577                    q.setMaxResults(2);
5578    
5579                    if (getDB().isSupportsInlineDistinct()) {
5580                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5581                    }
5582                    else {
5583                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5584                    }
5585    
5586                    QueryPos qPos = QueryPos.getInstance(q);
5587    
5588                    qPos.add(groupId);
5589    
5590                    qPos.add(status);
5591    
5592                    if (orderByComparator != null) {
5593                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5594    
5595                            for (Object value : values) {
5596                                    qPos.add(value);
5597                            }
5598                    }
5599    
5600                    List<BlogsEntry> list = q.list();
5601    
5602                    if (list.size() == 2) {
5603                            return list.get(1);
5604                    }
5605                    else {
5606                            return null;
5607                    }
5608            }
5609    
5610            /**
5611             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
5612             *
5613             * @param displayDate the display date
5614             * @param status the status
5615             * @return the matching blogs entries
5616             * @throws SystemException if a system exception occurred
5617             */
5618            public List<BlogsEntry> findByLtD_S(Date displayDate, int status)
5619                    throws SystemException {
5620                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
5621                            QueryUtil.ALL_POS, null);
5622            }
5623    
5624            /**
5625             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
5626             *
5627             * <p>
5628             * 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.
5629             * </p>
5630             *
5631             * @param displayDate the display date
5632             * @param status the status
5633             * @param start the lower bound of the range of blogs entries
5634             * @param end the upper bound of the range of blogs entries (not inclusive)
5635             * @return the range of matching blogs entries
5636             * @throws SystemException if a system exception occurred
5637             */
5638            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
5639                    int start, int end) throws SystemException {
5640                    return findByLtD_S(displayDate, status, start, end, null);
5641            }
5642    
5643            /**
5644             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
5645             *
5646             * <p>
5647             * 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.
5648             * </p>
5649             *
5650             * @param displayDate the display date
5651             * @param status the status
5652             * @param start the lower bound of the range of blogs entries
5653             * @param end the upper bound of the range of blogs entries (not inclusive)
5654             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5655             * @return the ordered range of matching blogs entries
5656             * @throws SystemException if a system exception occurred
5657             */
5658            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
5659                    int start, int end, OrderByComparator orderByComparator)
5660                    throws SystemException {
5661                    FinderPath finderPath = null;
5662                    Object[] finderArgs = null;
5663    
5664                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
5665                    finderArgs = new Object[] {
5666                                    displayDate, status,
5667                                    
5668                                    start, end, orderByComparator
5669                            };
5670    
5671                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5672                                    finderArgs, this);
5673    
5674                    if ((list != null) && !list.isEmpty()) {
5675                            for (BlogsEntry blogsEntry : list) {
5676                                    if (!Validator.equals(displayDate, blogsEntry.getDisplayDate()) ||
5677                                                    (status != blogsEntry.getStatus())) {
5678                                            list = null;
5679    
5680                                            break;
5681                                    }
5682                            }
5683                    }
5684    
5685                    if (list == null) {
5686                            StringBundler query = null;
5687    
5688                            if (orderByComparator != null) {
5689                                    query = new StringBundler(4 +
5690                                                    (orderByComparator.getOrderByFields().length * 3));
5691                            }
5692                            else {
5693                                    query = new StringBundler(4);
5694                            }
5695    
5696                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5697    
5698                            if (displayDate == null) {
5699                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
5700                            }
5701                            else {
5702                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
5703                            }
5704    
5705                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
5706    
5707                            if (orderByComparator != null) {
5708                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5709                                            orderByComparator);
5710                            }
5711    
5712                            else {
5713                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5714                            }
5715    
5716                            String sql = query.toString();
5717    
5718                            Session session = null;
5719    
5720                            try {
5721                                    session = openSession();
5722    
5723                                    Query q = session.createQuery(sql);
5724    
5725                                    QueryPos qPos = QueryPos.getInstance(q);
5726    
5727                                    if (displayDate != null) {
5728                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5729                                    }
5730    
5731                                    qPos.add(status);
5732    
5733                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
5734                                                    end);
5735                            }
5736                            catch (Exception e) {
5737                                    throw processException(e);
5738                            }
5739                            finally {
5740                                    if (list == null) {
5741                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5742                                    }
5743                                    else {
5744                                            cacheResult(list);
5745    
5746                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5747                                    }
5748    
5749                                    closeSession(session);
5750                            }
5751                    }
5752    
5753                    return list;
5754            }
5755    
5756            /**
5757             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
5758             *
5759             * @param displayDate the display date
5760             * @param status the status
5761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5762             * @return the first matching blogs entry
5763             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5764             * @throws SystemException if a system exception occurred
5765             */
5766            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
5767                    OrderByComparator orderByComparator)
5768                    throws NoSuchEntryException, SystemException {
5769                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
5770                                    orderByComparator);
5771    
5772                    if (blogsEntry != null) {
5773                            return blogsEntry;
5774                    }
5775    
5776                    StringBundler msg = new StringBundler(6);
5777    
5778                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5779    
5780                    msg.append("displayDate=");
5781                    msg.append(displayDate);
5782    
5783                    msg.append(", status=");
5784                    msg.append(status);
5785    
5786                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5787    
5788                    throw new NoSuchEntryException(msg.toString());
5789            }
5790    
5791            /**
5792             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
5793             *
5794             * @param displayDate the display date
5795             * @param status the status
5796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5797             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5798             * @throws SystemException if a system exception occurred
5799             */
5800            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
5801                    OrderByComparator orderByComparator) throws SystemException {
5802                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
5803                                    orderByComparator);
5804    
5805                    if (!list.isEmpty()) {
5806                            return list.get(0);
5807                    }
5808    
5809                    return null;
5810            }
5811    
5812            /**
5813             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
5814             *
5815             * @param displayDate the display date
5816             * @param status the status
5817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5818             * @return the last matching blogs entry
5819             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5820             * @throws SystemException if a system exception occurred
5821             */
5822            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
5823                    OrderByComparator orderByComparator)
5824                    throws NoSuchEntryException, SystemException {
5825                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
5826                                    orderByComparator);
5827    
5828                    if (blogsEntry != null) {
5829                            return blogsEntry;
5830                    }
5831    
5832                    StringBundler msg = new StringBundler(6);
5833    
5834                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5835    
5836                    msg.append("displayDate=");
5837                    msg.append(displayDate);
5838    
5839                    msg.append(", status=");
5840                    msg.append(status);
5841    
5842                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5843    
5844                    throw new NoSuchEntryException(msg.toString());
5845            }
5846    
5847            /**
5848             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
5849             *
5850             * @param displayDate the display date
5851             * @param status the status
5852             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5853             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5854             * @throws SystemException if a system exception occurred
5855             */
5856            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
5857                    OrderByComparator orderByComparator) throws SystemException {
5858                    int count = countByLtD_S(displayDate, status);
5859    
5860                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
5861                                    count, orderByComparator);
5862    
5863                    if (!list.isEmpty()) {
5864                            return list.get(0);
5865                    }
5866    
5867                    return null;
5868            }
5869    
5870            /**
5871             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
5872             *
5873             * @param entryId the primary key of the current blogs entry
5874             * @param displayDate the display date
5875             * @param status the status
5876             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5877             * @return the previous, current, and next blogs entry
5878             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5879             * @throws SystemException if a system exception occurred
5880             */
5881            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
5882                    int status, OrderByComparator orderByComparator)
5883                    throws NoSuchEntryException, SystemException {
5884                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5885    
5886                    Session session = null;
5887    
5888                    try {
5889                            session = openSession();
5890    
5891                            BlogsEntry[] array = new BlogsEntryImpl[3];
5892    
5893                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
5894                                            status, orderByComparator, true);
5895    
5896                            array[1] = blogsEntry;
5897    
5898                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
5899                                            status, orderByComparator, false);
5900    
5901                            return array;
5902                    }
5903                    catch (Exception e) {
5904                            throw processException(e);
5905                    }
5906                    finally {
5907                            closeSession(session);
5908                    }
5909            }
5910    
5911            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
5912                    BlogsEntry blogsEntry, Date displayDate, int status,
5913                    OrderByComparator orderByComparator, boolean previous) {
5914                    StringBundler query = null;
5915    
5916                    if (orderByComparator != null) {
5917                            query = new StringBundler(6 +
5918                                            (orderByComparator.getOrderByFields().length * 6));
5919                    }
5920                    else {
5921                            query = new StringBundler(3);
5922                    }
5923    
5924                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5925    
5926                    if (displayDate == null) {
5927                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
5928                    }
5929                    else {
5930                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
5931                    }
5932    
5933                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
5934    
5935                    if (orderByComparator != null) {
5936                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5937    
5938                            if (orderByConditionFields.length > 0) {
5939                                    query.append(WHERE_AND);
5940                            }
5941    
5942                            for (int i = 0; i < orderByConditionFields.length; i++) {
5943                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5944                                    query.append(orderByConditionFields[i]);
5945    
5946                                    if ((i + 1) < orderByConditionFields.length) {
5947                                            if (orderByComparator.isAscending() ^ previous) {
5948                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5949                                            }
5950                                            else {
5951                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5952                                            }
5953                                    }
5954                                    else {
5955                                            if (orderByComparator.isAscending() ^ previous) {
5956                                                    query.append(WHERE_GREATER_THAN);
5957                                            }
5958                                            else {
5959                                                    query.append(WHERE_LESSER_THAN);
5960                                            }
5961                                    }
5962                            }
5963    
5964                            query.append(ORDER_BY_CLAUSE);
5965    
5966                            String[] orderByFields = orderByComparator.getOrderByFields();
5967    
5968                            for (int i = 0; i < orderByFields.length; i++) {
5969                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5970                                    query.append(orderByFields[i]);
5971    
5972                                    if ((i + 1) < orderByFields.length) {
5973                                            if (orderByComparator.isAscending() ^ previous) {
5974                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5975                                            }
5976                                            else {
5977                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5978                                            }
5979                                    }
5980                                    else {
5981                                            if (orderByComparator.isAscending() ^ previous) {
5982                                                    query.append(ORDER_BY_ASC);
5983                                            }
5984                                            else {
5985                                                    query.append(ORDER_BY_DESC);
5986                                            }
5987                                    }
5988                            }
5989                    }
5990    
5991                    else {
5992                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5993                    }
5994    
5995                    String sql = query.toString();
5996    
5997                    Query q = session.createQuery(sql);
5998    
5999                    q.setFirstResult(0);
6000                    q.setMaxResults(2);
6001    
6002                    QueryPos qPos = QueryPos.getInstance(q);
6003    
6004                    if (displayDate != null) {
6005                            qPos.add(CalendarUtil.getTimestamp(displayDate));
6006                    }
6007    
6008                    qPos.add(status);
6009    
6010                    if (orderByComparator != null) {
6011                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6012    
6013                            for (Object value : values) {
6014                                    qPos.add(value);
6015                            }
6016                    }
6017    
6018                    List<BlogsEntry> list = q.list();
6019    
6020                    if (list.size() == 2) {
6021                            return list.get(1);
6022                    }
6023                    else {
6024                            return null;
6025                    }
6026            }
6027    
6028            /**
6029             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
6030             *
6031             * @param companyId the company ID
6032             * @param userId the user ID
6033             * @param status the status
6034             * @return the matching blogs entries
6035             * @throws SystemException if a system exception occurred
6036             */
6037            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
6038                    throws SystemException {
6039                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
6040                            QueryUtil.ALL_POS, null);
6041            }
6042    
6043            /**
6044             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
6045             *
6046             * <p>
6047             * 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.
6048             * </p>
6049             *
6050             * @param companyId the company ID
6051             * @param userId the user ID
6052             * @param status the status
6053             * @param start the lower bound of the range of blogs entries
6054             * @param end the upper bound of the range of blogs entries (not inclusive)
6055             * @return the range of matching blogs entries
6056             * @throws SystemException if a system exception occurred
6057             */
6058            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
6059                    int status, int start, int end) throws SystemException {
6060                    return findByC_U_S(companyId, userId, status, start, end, null);
6061            }
6062    
6063            /**
6064             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
6065             *
6066             * <p>
6067             * 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.
6068             * </p>
6069             *
6070             * @param companyId the company ID
6071             * @param userId the user ID
6072             * @param status the status
6073             * @param start the lower bound of the range of blogs entries
6074             * @param end the upper bound of the range of blogs entries (not inclusive)
6075             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6076             * @return the ordered range of matching blogs entries
6077             * @throws SystemException if a system exception occurred
6078             */
6079            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
6080                    int status, int start, int end, OrderByComparator orderByComparator)
6081                    throws SystemException {
6082                    FinderPath finderPath = null;
6083                    Object[] finderArgs = null;
6084    
6085                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6086                                    (orderByComparator == null)) {
6087                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
6088                            finderArgs = new Object[] { companyId, userId, status };
6089                    }
6090                    else {
6091                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
6092                            finderArgs = new Object[] {
6093                                            companyId, userId, status,
6094                                            
6095                                            start, end, orderByComparator
6096                                    };
6097                    }
6098    
6099                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6100                                    finderArgs, this);
6101    
6102                    if ((list != null) && !list.isEmpty()) {
6103                            for (BlogsEntry blogsEntry : list) {
6104                                    if ((companyId != blogsEntry.getCompanyId()) ||
6105                                                    (userId != blogsEntry.getUserId()) ||
6106                                                    (status != blogsEntry.getStatus())) {
6107                                            list = null;
6108    
6109                                            break;
6110                                    }
6111                            }
6112                    }
6113    
6114                    if (list == null) {
6115                            StringBundler query = null;
6116    
6117                            if (orderByComparator != null) {
6118                                    query = new StringBundler(5 +
6119                                                    (orderByComparator.getOrderByFields().length * 3));
6120                            }
6121                            else {
6122                                    query = new StringBundler(5);
6123                            }
6124    
6125                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6126    
6127                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
6128    
6129                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
6130    
6131                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
6132    
6133                            if (orderByComparator != null) {
6134                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6135                                            orderByComparator);
6136                            }
6137    
6138                            else {
6139                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6140                            }
6141    
6142                            String sql = query.toString();
6143    
6144                            Session session = null;
6145    
6146                            try {
6147                                    session = openSession();
6148    
6149                                    Query q = session.createQuery(sql);
6150    
6151                                    QueryPos qPos = QueryPos.getInstance(q);
6152    
6153                                    qPos.add(companyId);
6154    
6155                                    qPos.add(userId);
6156    
6157                                    qPos.add(status);
6158    
6159                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
6160                                                    end);
6161                            }
6162                            catch (Exception e) {
6163                                    throw processException(e);
6164                            }
6165                            finally {
6166                                    if (list == null) {
6167                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6168                                    }
6169                                    else {
6170                                            cacheResult(list);
6171    
6172                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6173                                    }
6174    
6175                                    closeSession(session);
6176                            }
6177                    }
6178    
6179                    return list;
6180            }
6181    
6182            /**
6183             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
6184             *
6185             * @param companyId the company ID
6186             * @param userId the user ID
6187             * @param status the status
6188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6189             * @return the first matching blogs entry
6190             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6191             * @throws SystemException if a system exception occurred
6192             */
6193            public BlogsEntry findByC_U_S_First(long companyId, long userId,
6194                    int status, OrderByComparator orderByComparator)
6195                    throws NoSuchEntryException, SystemException {
6196                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
6197                                    orderByComparator);
6198    
6199                    if (blogsEntry != null) {
6200                            return blogsEntry;
6201                    }
6202    
6203                    StringBundler msg = new StringBundler(8);
6204    
6205                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6206    
6207                    msg.append("companyId=");
6208                    msg.append(companyId);
6209    
6210                    msg.append(", userId=");
6211                    msg.append(userId);
6212    
6213                    msg.append(", status=");
6214                    msg.append(status);
6215    
6216                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6217    
6218                    throw new NoSuchEntryException(msg.toString());
6219            }
6220    
6221            /**
6222             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
6223             *
6224             * @param companyId the company ID
6225             * @param userId the user ID
6226             * @param status the status
6227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6228             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6229             * @throws SystemException if a system exception occurred
6230             */
6231            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
6232                    int status, OrderByComparator orderByComparator)
6233                    throws SystemException {
6234                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
6235                                    orderByComparator);
6236    
6237                    if (!list.isEmpty()) {
6238                            return list.get(0);
6239                    }
6240    
6241                    return null;
6242            }
6243    
6244            /**
6245             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
6246             *
6247             * @param companyId the company ID
6248             * @param userId the user ID
6249             * @param status the status
6250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6251             * @return the last matching blogs entry
6252             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6253             * @throws SystemException if a system exception occurred
6254             */
6255            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
6256                    OrderByComparator orderByComparator)
6257                    throws NoSuchEntryException, SystemException {
6258                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
6259                                    orderByComparator);
6260    
6261                    if (blogsEntry != null) {
6262                            return blogsEntry;
6263                    }
6264    
6265                    StringBundler msg = new StringBundler(8);
6266    
6267                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6268    
6269                    msg.append("companyId=");
6270                    msg.append(companyId);
6271    
6272                    msg.append(", userId=");
6273                    msg.append(userId);
6274    
6275                    msg.append(", status=");
6276                    msg.append(status);
6277    
6278                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6279    
6280                    throw new NoSuchEntryException(msg.toString());
6281            }
6282    
6283            /**
6284             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
6285             *
6286             * @param companyId the company ID
6287             * @param userId the user ID
6288             * @param status the status
6289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6290             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6291             * @throws SystemException if a system exception occurred
6292             */
6293            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
6294                    int status, OrderByComparator orderByComparator)
6295                    throws SystemException {
6296                    int count = countByC_U_S(companyId, userId, status);
6297    
6298                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
6299                                    count - 1, count, orderByComparator);
6300    
6301                    if (!list.isEmpty()) {
6302                            return list.get(0);
6303                    }
6304    
6305                    return null;
6306            }
6307    
6308            /**
6309             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
6310             *
6311             * @param entryId the primary key of the current blogs entry
6312             * @param companyId the company ID
6313             * @param userId the user ID
6314             * @param status the status
6315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6316             * @return the previous, current, and next blogs entry
6317             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6318             * @throws SystemException if a system exception occurred
6319             */
6320            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
6321                    long userId, int status, OrderByComparator orderByComparator)
6322                    throws NoSuchEntryException, SystemException {
6323                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6324    
6325                    Session session = null;
6326    
6327                    try {
6328                            session = openSession();
6329    
6330                            BlogsEntry[] array = new BlogsEntryImpl[3];
6331    
6332                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
6333                                            userId, status, orderByComparator, true);
6334    
6335                            array[1] = blogsEntry;
6336    
6337                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
6338                                            userId, status, orderByComparator, false);
6339    
6340                            return array;
6341                    }
6342                    catch (Exception e) {
6343                            throw processException(e);
6344                    }
6345                    finally {
6346                            closeSession(session);
6347                    }
6348            }
6349    
6350            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
6351                    BlogsEntry blogsEntry, long companyId, long userId, int status,
6352                    OrderByComparator orderByComparator, boolean previous) {
6353                    StringBundler query = null;
6354    
6355                    if (orderByComparator != null) {
6356                            query = new StringBundler(6 +
6357                                            (orderByComparator.getOrderByFields().length * 6));
6358                    }
6359                    else {
6360                            query = new StringBundler(3);
6361                    }
6362    
6363                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6364    
6365                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
6366    
6367                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
6368    
6369                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
6370    
6371                    if (orderByComparator != null) {
6372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6373    
6374                            if (orderByConditionFields.length > 0) {
6375                                    query.append(WHERE_AND);
6376                            }
6377    
6378                            for (int i = 0; i < orderByConditionFields.length; i++) {
6379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6380                                    query.append(orderByConditionFields[i]);
6381    
6382                                    if ((i + 1) < orderByConditionFields.length) {
6383                                            if (orderByComparator.isAscending() ^ previous) {
6384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6385                                            }
6386                                            else {
6387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6388                                            }
6389                                    }
6390                                    else {
6391                                            if (orderByComparator.isAscending() ^ previous) {
6392                                                    query.append(WHERE_GREATER_THAN);
6393                                            }
6394                                            else {
6395                                                    query.append(WHERE_LESSER_THAN);
6396                                            }
6397                                    }
6398                            }
6399    
6400                            query.append(ORDER_BY_CLAUSE);
6401    
6402                            String[] orderByFields = orderByComparator.getOrderByFields();
6403    
6404                            for (int i = 0; i < orderByFields.length; i++) {
6405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6406                                    query.append(orderByFields[i]);
6407    
6408                                    if ((i + 1) < orderByFields.length) {
6409                                            if (orderByComparator.isAscending() ^ previous) {
6410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6411                                            }
6412                                            else {
6413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6414                                            }
6415                                    }
6416                                    else {
6417                                            if (orderByComparator.isAscending() ^ previous) {
6418                                                    query.append(ORDER_BY_ASC);
6419                                            }
6420                                            else {
6421                                                    query.append(ORDER_BY_DESC);
6422                                            }
6423                                    }
6424                            }
6425                    }
6426    
6427                    else {
6428                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6429                    }
6430    
6431                    String sql = query.toString();
6432    
6433                    Query q = session.createQuery(sql);
6434    
6435                    q.setFirstResult(0);
6436                    q.setMaxResults(2);
6437    
6438                    QueryPos qPos = QueryPos.getInstance(q);
6439    
6440                    qPos.add(companyId);
6441    
6442                    qPos.add(userId);
6443    
6444                    qPos.add(status);
6445    
6446                    if (orderByComparator != null) {
6447                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6448    
6449                            for (Object value : values) {
6450                                    qPos.add(value);
6451                            }
6452                    }
6453    
6454                    List<BlogsEntry> list = q.list();
6455    
6456                    if (list.size() == 2) {
6457                            return list.get(1);
6458                    }
6459                    else {
6460                            return null;
6461                    }
6462            }
6463    
6464            /**
6465             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6466             *
6467             * @param companyId the company ID
6468             * @param displayDate the display date
6469             * @param status the status
6470             * @return the matching blogs entries
6471             * @throws SystemException if a system exception occurred
6472             */
6473            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
6474                    int status) throws SystemException {
6475                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
6476                            QueryUtil.ALL_POS, null);
6477            }
6478    
6479            /**
6480             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6481             *
6482             * <p>
6483             * 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.
6484             * </p>
6485             *
6486             * @param companyId the company ID
6487             * @param displayDate the display date
6488             * @param status the status
6489             * @param start the lower bound of the range of blogs entries
6490             * @param end the upper bound of the range of blogs entries (not inclusive)
6491             * @return the range of matching blogs entries
6492             * @throws SystemException if a system exception occurred
6493             */
6494            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
6495                    int status, int start, int end) throws SystemException {
6496                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
6497            }
6498    
6499            /**
6500             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6501             *
6502             * <p>
6503             * 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.
6504             * </p>
6505             *
6506             * @param companyId the company ID
6507             * @param displayDate the display date
6508             * @param status the status
6509             * @param start the lower bound of the range of blogs entries
6510             * @param end the upper bound of the range of blogs entries (not inclusive)
6511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6512             * @return the ordered range of matching blogs entries
6513             * @throws SystemException if a system exception occurred
6514             */
6515            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
6516                    int status, int start, int end, OrderByComparator orderByComparator)
6517                    throws SystemException {
6518                    FinderPath finderPath = null;
6519                    Object[] finderArgs = null;
6520    
6521                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
6522                    finderArgs = new Object[] {
6523                                    companyId, displayDate, status,
6524                                    
6525                                    start, end, orderByComparator
6526                            };
6527    
6528                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6529                                    finderArgs, this);
6530    
6531                    if ((list != null) && !list.isEmpty()) {
6532                            for (BlogsEntry blogsEntry : list) {
6533                                    if ((companyId != blogsEntry.getCompanyId()) ||
6534                                                    !Validator.equals(displayDate,
6535                                                            blogsEntry.getDisplayDate()) ||
6536                                                    (status != blogsEntry.getStatus())) {
6537                                            list = null;
6538    
6539                                            break;
6540                                    }
6541                            }
6542                    }
6543    
6544                    if (list == null) {
6545                            StringBundler query = null;
6546    
6547                            if (orderByComparator != null) {
6548                                    query = new StringBundler(5 +
6549                                                    (orderByComparator.getOrderByFields().length * 3));
6550                            }
6551                            else {
6552                                    query = new StringBundler(5);
6553                            }
6554    
6555                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6556    
6557                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
6558    
6559                            if (displayDate == null) {
6560                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
6561                            }
6562                            else {
6563                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
6564                            }
6565    
6566                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
6567    
6568                            if (orderByComparator != null) {
6569                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6570                                            orderByComparator);
6571                            }
6572    
6573                            else {
6574                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6575                            }
6576    
6577                            String sql = query.toString();
6578    
6579                            Session session = null;
6580    
6581                            try {
6582                                    session = openSession();
6583    
6584                                    Query q = session.createQuery(sql);
6585    
6586                                    QueryPos qPos = QueryPos.getInstance(q);
6587    
6588                                    qPos.add(companyId);
6589    
6590                                    if (displayDate != null) {
6591                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
6592                                    }
6593    
6594                                    qPos.add(status);
6595    
6596                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
6597                                                    end);
6598                            }
6599                            catch (Exception e) {
6600                                    throw processException(e);
6601                            }
6602                            finally {
6603                                    if (list == null) {
6604                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6605                                    }
6606                                    else {
6607                                            cacheResult(list);
6608    
6609                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6610                                    }
6611    
6612                                    closeSession(session);
6613                            }
6614                    }
6615    
6616                    return list;
6617            }
6618    
6619            /**
6620             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6621             *
6622             * @param companyId the company ID
6623             * @param displayDate the display date
6624             * @param status the status
6625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6626             * @return the first matching blogs entry
6627             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6628             * @throws SystemException if a system exception occurred
6629             */
6630            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
6631                    int status, OrderByComparator orderByComparator)
6632                    throws NoSuchEntryException, SystemException {
6633                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
6634                                    status, orderByComparator);
6635    
6636                    if (blogsEntry != null) {
6637                            return blogsEntry;
6638                    }
6639    
6640                    StringBundler msg = new StringBundler(8);
6641    
6642                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6643    
6644                    msg.append("companyId=");
6645                    msg.append(companyId);
6646    
6647                    msg.append(", displayDate=");
6648                    msg.append(displayDate);
6649    
6650                    msg.append(", status=");
6651                    msg.append(status);
6652    
6653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6654    
6655                    throw new NoSuchEntryException(msg.toString());
6656            }
6657    
6658            /**
6659             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6660             *
6661             * @param companyId the company ID
6662             * @param displayDate the display date
6663             * @param status the status
6664             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6665             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6666             * @throws SystemException if a system exception occurred
6667             */
6668            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
6669                    int status, OrderByComparator orderByComparator)
6670                    throws SystemException {
6671                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
6672                                    0, 1, orderByComparator);
6673    
6674                    if (!list.isEmpty()) {
6675                            return list.get(0);
6676                    }
6677    
6678                    return null;
6679            }
6680    
6681            /**
6682             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6683             *
6684             * @param companyId the company ID
6685             * @param displayDate the display date
6686             * @param status the status
6687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6688             * @return the last matching blogs entry
6689             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6690             * @throws SystemException if a system exception occurred
6691             */
6692            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
6693                    int status, OrderByComparator orderByComparator)
6694                    throws NoSuchEntryException, SystemException {
6695                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
6696                                    status, orderByComparator);
6697    
6698                    if (blogsEntry != null) {
6699                            return blogsEntry;
6700                    }
6701    
6702                    StringBundler msg = new StringBundler(8);
6703    
6704                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6705    
6706                    msg.append("companyId=");
6707                    msg.append(companyId);
6708    
6709                    msg.append(", displayDate=");
6710                    msg.append(displayDate);
6711    
6712                    msg.append(", status=");
6713                    msg.append(status);
6714    
6715                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6716    
6717                    throw new NoSuchEntryException(msg.toString());
6718            }
6719    
6720            /**
6721             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6722             *
6723             * @param companyId the company ID
6724             * @param displayDate the display date
6725             * @param status the status
6726             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6727             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6728             * @throws SystemException if a system exception occurred
6729             */
6730            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
6731                    int status, OrderByComparator orderByComparator)
6732                    throws SystemException {
6733                    int count = countByC_LtD_S(companyId, displayDate, status);
6734    
6735                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
6736                                    count - 1, count, orderByComparator);
6737    
6738                    if (!list.isEmpty()) {
6739                            return list.get(0);
6740                    }
6741    
6742                    return null;
6743            }
6744    
6745            /**
6746             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
6747             *
6748             * @param entryId the primary key of the current blogs entry
6749             * @param companyId the company ID
6750             * @param displayDate the display date
6751             * @param status the status
6752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6753             * @return the previous, current, and next blogs entry
6754             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6755             * @throws SystemException if a system exception occurred
6756             */
6757            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
6758                    Date displayDate, int status, OrderByComparator orderByComparator)
6759                    throws NoSuchEntryException, SystemException {
6760                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6761    
6762                    Session session = null;
6763    
6764                    try {
6765                            session = openSession();
6766    
6767                            BlogsEntry[] array = new BlogsEntryImpl[3];
6768    
6769                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
6770                                            displayDate, status, orderByComparator, true);
6771    
6772                            array[1] = blogsEntry;
6773    
6774                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
6775                                            displayDate, status, orderByComparator, false);
6776    
6777                            return array;
6778                    }
6779                    catch (Exception e) {
6780                            throw processException(e);
6781                    }
6782                    finally {
6783                            closeSession(session);
6784                    }
6785            }
6786    
6787            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
6788                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
6789                    OrderByComparator orderByComparator, boolean previous) {
6790                    StringBundler query = null;
6791    
6792                    if (orderByComparator != null) {
6793                            query = new StringBundler(6 +
6794                                            (orderByComparator.getOrderByFields().length * 6));
6795                    }
6796                    else {
6797                            query = new StringBundler(3);
6798                    }
6799    
6800                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6801    
6802                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
6803    
6804                    if (displayDate == null) {
6805                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
6806                    }
6807                    else {
6808                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
6809                    }
6810    
6811                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
6812    
6813                    if (orderByComparator != null) {
6814                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6815    
6816                            if (orderByConditionFields.length > 0) {
6817                                    query.append(WHERE_AND);
6818                            }
6819    
6820                            for (int i = 0; i < orderByConditionFields.length; i++) {
6821                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6822                                    query.append(orderByConditionFields[i]);
6823    
6824                                    if ((i + 1) < orderByConditionFields.length) {
6825                                            if (orderByComparator.isAscending() ^ previous) {
6826                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6827                                            }
6828                                            else {
6829                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6830                                            }
6831                                    }
6832                                    else {
6833                                            if (orderByComparator.isAscending() ^ previous) {
6834                                                    query.append(WHERE_GREATER_THAN);
6835                                            }
6836                                            else {
6837                                                    query.append(WHERE_LESSER_THAN);
6838                                            }
6839                                    }
6840                            }
6841    
6842                            query.append(ORDER_BY_CLAUSE);
6843    
6844                            String[] orderByFields = orderByComparator.getOrderByFields();
6845    
6846                            for (int i = 0; i < orderByFields.length; i++) {
6847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6848                                    query.append(orderByFields[i]);
6849    
6850                                    if ((i + 1) < orderByFields.length) {
6851                                            if (orderByComparator.isAscending() ^ previous) {
6852                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6853                                            }
6854                                            else {
6855                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6856                                            }
6857                                    }
6858                                    else {
6859                                            if (orderByComparator.isAscending() ^ previous) {
6860                                                    query.append(ORDER_BY_ASC);
6861                                            }
6862                                            else {
6863                                                    query.append(ORDER_BY_DESC);
6864                                            }
6865                                    }
6866                            }
6867                    }
6868    
6869                    else {
6870                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6871                    }
6872    
6873                    String sql = query.toString();
6874    
6875                    Query q = session.createQuery(sql);
6876    
6877                    q.setFirstResult(0);
6878                    q.setMaxResults(2);
6879    
6880                    QueryPos qPos = QueryPos.getInstance(q);
6881    
6882                    qPos.add(companyId);
6883    
6884                    if (displayDate != null) {
6885                            qPos.add(CalendarUtil.getTimestamp(displayDate));
6886                    }
6887    
6888                    qPos.add(status);
6889    
6890                    if (orderByComparator != null) {
6891                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6892    
6893                            for (Object value : values) {
6894                                    qPos.add(value);
6895                            }
6896                    }
6897    
6898                    List<BlogsEntry> list = q.list();
6899    
6900                    if (list.size() == 2) {
6901                            return list.get(1);
6902                    }
6903                    else {
6904                            return null;
6905                    }
6906            }
6907    
6908            /**
6909             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
6910             *
6911             * @param groupId the group ID
6912             * @param userId the user ID
6913             * @param displayDate the display date
6914             * @return the matching blogs entries
6915             * @throws SystemException if a system exception occurred
6916             */
6917            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
6918                    Date displayDate) throws SystemException {
6919                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
6920                            QueryUtil.ALL_POS, null);
6921            }
6922    
6923            /**
6924             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
6925             *
6926             * <p>
6927             * 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.
6928             * </p>
6929             *
6930             * @param groupId the group ID
6931             * @param userId the user ID
6932             * @param displayDate the display date
6933             * @param start the lower bound of the range of blogs entries
6934             * @param end the upper bound of the range of blogs entries (not inclusive)
6935             * @return the range of matching blogs entries
6936             * @throws SystemException if a system exception occurred
6937             */
6938            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
6939                    Date displayDate, int start, int end) throws SystemException {
6940                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
6941            }
6942    
6943            /**
6944             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
6945             *
6946             * <p>
6947             * 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.
6948             * </p>
6949             *
6950             * @param groupId the group ID
6951             * @param userId the user ID
6952             * @param displayDate the display date
6953             * @param start the lower bound of the range of blogs entries
6954             * @param end the upper bound of the range of blogs entries (not inclusive)
6955             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6956             * @return the ordered range of matching blogs entries
6957             * @throws SystemException if a system exception occurred
6958             */
6959            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
6960                    Date displayDate, int start, int end,
6961                    OrderByComparator orderByComparator) throws SystemException {
6962                    FinderPath finderPath = null;
6963                    Object[] finderArgs = null;
6964    
6965                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
6966                    finderArgs = new Object[] {
6967                                    groupId, userId, displayDate,
6968                                    
6969                                    start, end, orderByComparator
6970                            };
6971    
6972                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6973                                    finderArgs, this);
6974    
6975                    if ((list != null) && !list.isEmpty()) {
6976                            for (BlogsEntry blogsEntry : list) {
6977                                    if ((groupId != blogsEntry.getGroupId()) ||
6978                                                    (userId != blogsEntry.getUserId()) ||
6979                                                    !Validator.equals(displayDate,
6980                                                            blogsEntry.getDisplayDate())) {
6981                                            list = null;
6982    
6983                                            break;
6984                                    }
6985                            }
6986                    }
6987    
6988                    if (list == null) {
6989                            StringBundler query = null;
6990    
6991                            if (orderByComparator != null) {
6992                                    query = new StringBundler(5 +
6993                                                    (orderByComparator.getOrderByFields().length * 3));
6994                            }
6995                            else {
6996                                    query = new StringBundler(5);
6997                            }
6998    
6999                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7000    
7001                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
7002    
7003                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
7004    
7005                            if (displayDate == null) {
7006                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
7007                            }
7008                            else {
7009                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
7010                            }
7011    
7012                            if (orderByComparator != null) {
7013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7014                                            orderByComparator);
7015                            }
7016    
7017                            else {
7018                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7019                            }
7020    
7021                            String sql = query.toString();
7022    
7023                            Session session = null;
7024    
7025                            try {
7026                                    session = openSession();
7027    
7028                                    Query q = session.createQuery(sql);
7029    
7030                                    QueryPos qPos = QueryPos.getInstance(q);
7031    
7032                                    qPos.add(groupId);
7033    
7034                                    qPos.add(userId);
7035    
7036                                    if (displayDate != null) {
7037                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7038                                    }
7039    
7040                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
7041                                                    end);
7042                            }
7043                            catch (Exception e) {
7044                                    throw processException(e);
7045                            }
7046                            finally {
7047                                    if (list == null) {
7048                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7049                                    }
7050                                    else {
7051                                            cacheResult(list);
7052    
7053                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7054                                    }
7055    
7056                                    closeSession(session);
7057                            }
7058                    }
7059    
7060                    return list;
7061            }
7062    
7063            /**
7064             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7065             *
7066             * @param groupId the group ID
7067             * @param userId the user ID
7068             * @param displayDate the display date
7069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7070             * @return the first matching blogs entry
7071             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7072             * @throws SystemException if a system exception occurred
7073             */
7074            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
7075                    Date displayDate, OrderByComparator orderByComparator)
7076                    throws NoSuchEntryException, SystemException {
7077                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
7078                                    displayDate, orderByComparator);
7079    
7080                    if (blogsEntry != null) {
7081                            return blogsEntry;
7082                    }
7083    
7084                    StringBundler msg = new StringBundler(8);
7085    
7086                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7087    
7088                    msg.append("groupId=");
7089                    msg.append(groupId);
7090    
7091                    msg.append(", userId=");
7092                    msg.append(userId);
7093    
7094                    msg.append(", displayDate=");
7095                    msg.append(displayDate);
7096    
7097                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7098    
7099                    throw new NoSuchEntryException(msg.toString());
7100            }
7101    
7102            /**
7103             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7104             *
7105             * @param groupId the group ID
7106             * @param userId the user ID
7107             * @param displayDate the display date
7108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7109             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7110             * @throws SystemException if a system exception occurred
7111             */
7112            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
7113                    Date displayDate, OrderByComparator orderByComparator)
7114                    throws SystemException {
7115                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
7116                                    1, orderByComparator);
7117    
7118                    if (!list.isEmpty()) {
7119                            return list.get(0);
7120                    }
7121    
7122                    return null;
7123            }
7124    
7125            /**
7126             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7127             *
7128             * @param groupId the group ID
7129             * @param userId the user ID
7130             * @param displayDate the display date
7131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7132             * @return the last matching blogs entry
7133             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7134             * @throws SystemException if a system exception occurred
7135             */
7136            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
7137                    Date displayDate, OrderByComparator orderByComparator)
7138                    throws NoSuchEntryException, SystemException {
7139                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
7140                                    displayDate, orderByComparator);
7141    
7142                    if (blogsEntry != null) {
7143                            return blogsEntry;
7144                    }
7145    
7146                    StringBundler msg = new StringBundler(8);
7147    
7148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7149    
7150                    msg.append("groupId=");
7151                    msg.append(groupId);
7152    
7153                    msg.append(", userId=");
7154                    msg.append(userId);
7155    
7156                    msg.append(", displayDate=");
7157                    msg.append(displayDate);
7158    
7159                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7160    
7161                    throw new NoSuchEntryException(msg.toString());
7162            }
7163    
7164            /**
7165             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7166             *
7167             * @param groupId the group ID
7168             * @param userId the user ID
7169             * @param displayDate the display date
7170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7171             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7172             * @throws SystemException if a system exception occurred
7173             */
7174            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
7175                    Date displayDate, OrderByComparator orderByComparator)
7176                    throws SystemException {
7177                    int count = countByG_U_LtD(groupId, userId, displayDate);
7178    
7179                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
7180                                    count - 1, count, orderByComparator);
7181    
7182                    if (!list.isEmpty()) {
7183                            return list.get(0);
7184                    }
7185    
7186                    return null;
7187            }
7188    
7189            /**
7190             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7191             *
7192             * @param entryId the primary key of the current blogs entry
7193             * @param groupId the group ID
7194             * @param userId the user ID
7195             * @param displayDate the display date
7196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7197             * @return the previous, current, and next blogs entry
7198             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7199             * @throws SystemException if a system exception occurred
7200             */
7201            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
7202                    long userId, Date displayDate, OrderByComparator orderByComparator)
7203                    throws NoSuchEntryException, SystemException {
7204                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7205    
7206                    Session session = null;
7207    
7208                    try {
7209                            session = openSession();
7210    
7211                            BlogsEntry[] array = new BlogsEntryImpl[3];
7212    
7213                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
7214                                            userId, displayDate, orderByComparator, true);
7215    
7216                            array[1] = blogsEntry;
7217    
7218                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
7219                                            userId, displayDate, orderByComparator, false);
7220    
7221                            return array;
7222                    }
7223                    catch (Exception e) {
7224                            throw processException(e);
7225                    }
7226                    finally {
7227                            closeSession(session);
7228                    }
7229            }
7230    
7231            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
7232                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
7233                    OrderByComparator orderByComparator, boolean previous) {
7234                    StringBundler query = null;
7235    
7236                    if (orderByComparator != null) {
7237                            query = new StringBundler(6 +
7238                                            (orderByComparator.getOrderByFields().length * 6));
7239                    }
7240                    else {
7241                            query = new StringBundler(3);
7242                    }
7243    
7244                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7245    
7246                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
7247    
7248                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
7249    
7250                    if (displayDate == null) {
7251                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
7252                    }
7253                    else {
7254                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
7255                    }
7256    
7257                    if (orderByComparator != null) {
7258                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7259    
7260                            if (orderByConditionFields.length > 0) {
7261                                    query.append(WHERE_AND);
7262                            }
7263    
7264                            for (int i = 0; i < orderByConditionFields.length; i++) {
7265                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7266                                    query.append(orderByConditionFields[i]);
7267    
7268                                    if ((i + 1) < orderByConditionFields.length) {
7269                                            if (orderByComparator.isAscending() ^ previous) {
7270                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7271                                            }
7272                                            else {
7273                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7274                                            }
7275                                    }
7276                                    else {
7277                                            if (orderByComparator.isAscending() ^ previous) {
7278                                                    query.append(WHERE_GREATER_THAN);
7279                                            }
7280                                            else {
7281                                                    query.append(WHERE_LESSER_THAN);
7282                                            }
7283                                    }
7284                            }
7285    
7286                            query.append(ORDER_BY_CLAUSE);
7287    
7288                            String[] orderByFields = orderByComparator.getOrderByFields();
7289    
7290                            for (int i = 0; i < orderByFields.length; i++) {
7291                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7292                                    query.append(orderByFields[i]);
7293    
7294                                    if ((i + 1) < orderByFields.length) {
7295                                            if (orderByComparator.isAscending() ^ previous) {
7296                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7297                                            }
7298                                            else {
7299                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7300                                            }
7301                                    }
7302                                    else {
7303                                            if (orderByComparator.isAscending() ^ previous) {
7304                                                    query.append(ORDER_BY_ASC);
7305                                            }
7306                                            else {
7307                                                    query.append(ORDER_BY_DESC);
7308                                            }
7309                                    }
7310                            }
7311                    }
7312    
7313                    else {
7314                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7315                    }
7316    
7317                    String sql = query.toString();
7318    
7319                    Query q = session.createQuery(sql);
7320    
7321                    q.setFirstResult(0);
7322                    q.setMaxResults(2);
7323    
7324                    QueryPos qPos = QueryPos.getInstance(q);
7325    
7326                    qPos.add(groupId);
7327    
7328                    qPos.add(userId);
7329    
7330                    if (displayDate != null) {
7331                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7332                    }
7333    
7334                    if (orderByComparator != null) {
7335                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7336    
7337                            for (Object value : values) {
7338                                    qPos.add(value);
7339                            }
7340                    }
7341    
7342                    List<BlogsEntry> list = q.list();
7343    
7344                    if (list.size() == 2) {
7345                            return list.get(1);
7346                    }
7347                    else {
7348                            return null;
7349                    }
7350            }
7351    
7352            /**
7353             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7354             *
7355             * @param groupId the group ID
7356             * @param userId the user ID
7357             * @param displayDate the display date
7358             * @return the matching blogs entries that the user has permission to view
7359             * @throws SystemException if a system exception occurred
7360             */
7361            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
7362                    Date displayDate) throws SystemException {
7363                    return filterFindByG_U_LtD(groupId, userId, displayDate,
7364                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7365            }
7366    
7367            /**
7368             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7369             *
7370             * <p>
7371             * 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.
7372             * </p>
7373             *
7374             * @param groupId the group ID
7375             * @param userId the user ID
7376             * @param displayDate the display date
7377             * @param start the lower bound of the range of blogs entries
7378             * @param end the upper bound of the range of blogs entries (not inclusive)
7379             * @return the range of matching blogs entries that the user has permission to view
7380             * @throws SystemException if a system exception occurred
7381             */
7382            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
7383                    Date displayDate, int start, int end) throws SystemException {
7384                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
7385                            null);
7386            }
7387    
7388            /**
7389             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7390             *
7391             * <p>
7392             * 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.
7393             * </p>
7394             *
7395             * @param groupId the group ID
7396             * @param userId the user ID
7397             * @param displayDate the display date
7398             * @param start the lower bound of the range of blogs entries
7399             * @param end the upper bound of the range of blogs entries (not inclusive)
7400             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7401             * @return the ordered range of matching blogs entries that the user has permission to view
7402             * @throws SystemException if a system exception occurred
7403             */
7404            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
7405                    Date displayDate, int start, int end,
7406                    OrderByComparator orderByComparator) throws SystemException {
7407                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7408                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
7409                                    orderByComparator);
7410                    }
7411    
7412                    StringBundler query = null;
7413    
7414                    if (orderByComparator != null) {
7415                            query = new StringBundler(5 +
7416                                            (orderByComparator.getOrderByFields().length * 3));
7417                    }
7418                    else {
7419                            query = new StringBundler(5);
7420                    }
7421    
7422                    if (getDB().isSupportsInlineDistinct()) {
7423                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7424                    }
7425                    else {
7426                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7427                    }
7428    
7429                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
7430    
7431                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
7432    
7433                    if (displayDate == null) {
7434                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
7435                    }
7436                    else {
7437                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
7438                    }
7439    
7440                    if (!getDB().isSupportsInlineDistinct()) {
7441                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7442                    }
7443    
7444                    if (orderByComparator != null) {
7445                            if (getDB().isSupportsInlineDistinct()) {
7446                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7447                                            orderByComparator);
7448                            }
7449                            else {
7450                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7451                                            orderByComparator);
7452                            }
7453                    }
7454    
7455                    else {
7456                            if (getDB().isSupportsInlineDistinct()) {
7457                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7458                            }
7459                            else {
7460                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7461                            }
7462                    }
7463    
7464                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7465                                    BlogsEntry.class.getName(),
7466                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7467    
7468                    Session session = null;
7469    
7470                    try {
7471                            session = openSession();
7472    
7473                            SQLQuery q = session.createSQLQuery(sql);
7474    
7475                            if (getDB().isSupportsInlineDistinct()) {
7476                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7477                            }
7478                            else {
7479                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7480                            }
7481    
7482                            QueryPos qPos = QueryPos.getInstance(q);
7483    
7484                            qPos.add(groupId);
7485    
7486                            qPos.add(userId);
7487    
7488                            if (displayDate != null) {
7489                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
7490                            }
7491    
7492                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
7493                    }
7494                    catch (Exception e) {
7495                            throw processException(e);
7496                    }
7497                    finally {
7498                            closeSession(session);
7499                    }
7500            }
7501    
7502            /**
7503             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
7504             *
7505             * @param entryId the primary key of the current blogs entry
7506             * @param groupId the group ID
7507             * @param userId the user ID
7508             * @param displayDate the display date
7509             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7510             * @return the previous, current, and next blogs entry
7511             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7512             * @throws SystemException if a system exception occurred
7513             */
7514            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
7515                    long groupId, long userId, Date displayDate,
7516                    OrderByComparator orderByComparator)
7517                    throws NoSuchEntryException, SystemException {
7518                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7519                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
7520                                    displayDate, orderByComparator);
7521                    }
7522    
7523                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7524    
7525                    Session session = null;
7526    
7527                    try {
7528                            session = openSession();
7529    
7530                            BlogsEntry[] array = new BlogsEntryImpl[3];
7531    
7532                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
7533                                            groupId, userId, displayDate, orderByComparator, true);
7534    
7535                            array[1] = blogsEntry;
7536    
7537                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
7538                                            groupId, userId, displayDate, orderByComparator, false);
7539    
7540                            return array;
7541                    }
7542                    catch (Exception e) {
7543                            throw processException(e);
7544                    }
7545                    finally {
7546                            closeSession(session);
7547                    }
7548            }
7549    
7550            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
7551                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
7552                    OrderByComparator orderByComparator, boolean previous) {
7553                    StringBundler query = null;
7554    
7555                    if (orderByComparator != null) {
7556                            query = new StringBundler(6 +
7557                                            (orderByComparator.getOrderByFields().length * 6));
7558                    }
7559                    else {
7560                            query = new StringBundler(3);
7561                    }
7562    
7563                    if (getDB().isSupportsInlineDistinct()) {
7564                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7565                    }
7566                    else {
7567                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7568                    }
7569    
7570                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
7571    
7572                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
7573    
7574                    if (displayDate == null) {
7575                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
7576                    }
7577                    else {
7578                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
7579                    }
7580    
7581                    if (!getDB().isSupportsInlineDistinct()) {
7582                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7583                    }
7584    
7585                    if (orderByComparator != null) {
7586                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7587    
7588                            if (orderByConditionFields.length > 0) {
7589                                    query.append(WHERE_AND);
7590                            }
7591    
7592                            for (int i = 0; i < orderByConditionFields.length; i++) {
7593                                    if (getDB().isSupportsInlineDistinct()) {
7594                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7595                                    }
7596                                    else {
7597                                            query.append(_ORDER_BY_ENTITY_TABLE);
7598                                    }
7599    
7600                                    query.append(orderByConditionFields[i]);
7601    
7602                                    if ((i + 1) < orderByConditionFields.length) {
7603                                            if (orderByComparator.isAscending() ^ previous) {
7604                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7605                                            }
7606                                            else {
7607                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7608                                            }
7609                                    }
7610                                    else {
7611                                            if (orderByComparator.isAscending() ^ previous) {
7612                                                    query.append(WHERE_GREATER_THAN);
7613                                            }
7614                                            else {
7615                                                    query.append(WHERE_LESSER_THAN);
7616                                            }
7617                                    }
7618                            }
7619    
7620                            query.append(ORDER_BY_CLAUSE);
7621    
7622                            String[] orderByFields = orderByComparator.getOrderByFields();
7623    
7624                            for (int i = 0; i < orderByFields.length; i++) {
7625                                    if (getDB().isSupportsInlineDistinct()) {
7626                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7627                                    }
7628                                    else {
7629                                            query.append(_ORDER_BY_ENTITY_TABLE);
7630                                    }
7631    
7632                                    query.append(orderByFields[i]);
7633    
7634                                    if ((i + 1) < orderByFields.length) {
7635                                            if (orderByComparator.isAscending() ^ previous) {
7636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7637                                            }
7638                                            else {
7639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7640                                            }
7641                                    }
7642                                    else {
7643                                            if (orderByComparator.isAscending() ^ previous) {
7644                                                    query.append(ORDER_BY_ASC);
7645                                            }
7646                                            else {
7647                                                    query.append(ORDER_BY_DESC);
7648                                            }
7649                                    }
7650                            }
7651                    }
7652    
7653                    else {
7654                            if (getDB().isSupportsInlineDistinct()) {
7655                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7656                            }
7657                            else {
7658                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7659                            }
7660                    }
7661    
7662                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7663                                    BlogsEntry.class.getName(),
7664                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7665    
7666                    SQLQuery q = session.createSQLQuery(sql);
7667    
7668                    q.setFirstResult(0);
7669                    q.setMaxResults(2);
7670    
7671                    if (getDB().isSupportsInlineDistinct()) {
7672                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7673                    }
7674                    else {
7675                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7676                    }
7677    
7678                    QueryPos qPos = QueryPos.getInstance(q);
7679    
7680                    qPos.add(groupId);
7681    
7682                    qPos.add(userId);
7683    
7684                    if (displayDate != null) {
7685                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7686                    }
7687    
7688                    if (orderByComparator != null) {
7689                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7690    
7691                            for (Object value : values) {
7692                                    qPos.add(value);
7693                            }
7694                    }
7695    
7696                    List<BlogsEntry> list = q.list();
7697    
7698                    if (list.size() == 2) {
7699                            return list.get(1);
7700                    }
7701                    else {
7702                            return null;
7703                    }
7704            }
7705    
7706            /**
7707             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
7708             *
7709             * @param groupId the group ID
7710             * @param userId the user ID
7711             * @param status the status
7712             * @return the matching blogs entries
7713             * @throws SystemException if a system exception occurred
7714             */
7715            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
7716                    throws SystemException {
7717                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
7718                            QueryUtil.ALL_POS, null);
7719            }
7720    
7721            /**
7722             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
7723             *
7724             * <p>
7725             * 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.
7726             * </p>
7727             *
7728             * @param groupId the group ID
7729             * @param userId the user ID
7730             * @param status the status
7731             * @param start the lower bound of the range of blogs entries
7732             * @param end the upper bound of the range of blogs entries (not inclusive)
7733             * @return the range of matching blogs entries
7734             * @throws SystemException if a system exception occurred
7735             */
7736            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
7737                    int start, int end) throws SystemException {
7738                    return findByG_U_S(groupId, userId, status, start, end, null);
7739            }
7740    
7741            /**
7742             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
7743             *
7744             * <p>
7745             * 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.
7746             * </p>
7747             *
7748             * @param groupId the group ID
7749             * @param userId the user ID
7750             * @param status the status
7751             * @param start the lower bound of the range of blogs entries
7752             * @param end the upper bound of the range of blogs entries (not inclusive)
7753             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7754             * @return the ordered range of matching blogs entries
7755             * @throws SystemException if a system exception occurred
7756             */
7757            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
7758                    int start, int end, OrderByComparator orderByComparator)
7759                    throws SystemException {
7760                    FinderPath finderPath = null;
7761                    Object[] finderArgs = null;
7762    
7763                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7764                                    (orderByComparator == null)) {
7765                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
7766                            finderArgs = new Object[] { groupId, userId, status };
7767                    }
7768                    else {
7769                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
7770                            finderArgs = new Object[] {
7771                                            groupId, userId, status,
7772                                            
7773                                            start, end, orderByComparator
7774                                    };
7775                    }
7776    
7777                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7778                                    finderArgs, this);
7779    
7780                    if ((list != null) && !list.isEmpty()) {
7781                            for (BlogsEntry blogsEntry : list) {
7782                                    if ((groupId != blogsEntry.getGroupId()) ||
7783                                                    (userId != blogsEntry.getUserId()) ||
7784                                                    (status != blogsEntry.getStatus())) {
7785                                            list = null;
7786    
7787                                            break;
7788                                    }
7789                            }
7790                    }
7791    
7792                    if (list == null) {
7793                            StringBundler query = null;
7794    
7795                            if (orderByComparator != null) {
7796                                    query = new StringBundler(5 +
7797                                                    (orderByComparator.getOrderByFields().length * 3));
7798                            }
7799                            else {
7800                                    query = new StringBundler(5);
7801                            }
7802    
7803                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7804    
7805                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
7806    
7807                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
7808    
7809                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
7810    
7811                            if (orderByComparator != null) {
7812                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7813                                            orderByComparator);
7814                            }
7815    
7816                            else {
7817                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7818                            }
7819    
7820                            String sql = query.toString();
7821    
7822                            Session session = null;
7823    
7824                            try {
7825                                    session = openSession();
7826    
7827                                    Query q = session.createQuery(sql);
7828    
7829                                    QueryPos qPos = QueryPos.getInstance(q);
7830    
7831                                    qPos.add(groupId);
7832    
7833                                    qPos.add(userId);
7834    
7835                                    qPos.add(status);
7836    
7837                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
7838                                                    end);
7839                            }
7840                            catch (Exception e) {
7841                                    throw processException(e);
7842                            }
7843                            finally {
7844                                    if (list == null) {
7845                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7846                                    }
7847                                    else {
7848                                            cacheResult(list);
7849    
7850                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7851                                    }
7852    
7853                                    closeSession(session);
7854                            }
7855                    }
7856    
7857                    return list;
7858            }
7859    
7860            /**
7861             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
7862             *
7863             * @param groupId the group ID
7864             * @param userId the user ID
7865             * @param status the status
7866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7867             * @return the first matching blogs entry
7868             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7869             * @throws SystemException if a system exception occurred
7870             */
7871            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
7872                    OrderByComparator orderByComparator)
7873                    throws NoSuchEntryException, SystemException {
7874                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
7875                                    orderByComparator);
7876    
7877                    if (blogsEntry != null) {
7878                            return blogsEntry;
7879                    }
7880    
7881                    StringBundler msg = new StringBundler(8);
7882    
7883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7884    
7885                    msg.append("groupId=");
7886                    msg.append(groupId);
7887    
7888                    msg.append(", userId=");
7889                    msg.append(userId);
7890    
7891                    msg.append(", status=");
7892                    msg.append(status);
7893    
7894                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7895    
7896                    throw new NoSuchEntryException(msg.toString());
7897            }
7898    
7899            /**
7900             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
7901             *
7902             * @param groupId the group ID
7903             * @param userId the user ID
7904             * @param status the status
7905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7906             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7907             * @throws SystemException if a system exception occurred
7908             */
7909            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
7910                    OrderByComparator orderByComparator) throws SystemException {
7911                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
7912                                    orderByComparator);
7913    
7914                    if (!list.isEmpty()) {
7915                            return list.get(0);
7916                    }
7917    
7918                    return null;
7919            }
7920    
7921            /**
7922             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
7923             *
7924             * @param groupId the group ID
7925             * @param userId the user ID
7926             * @param status the status
7927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7928             * @return the last matching blogs entry
7929             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7930             * @throws SystemException if a system exception occurred
7931             */
7932            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
7933                    OrderByComparator orderByComparator)
7934                    throws NoSuchEntryException, SystemException {
7935                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
7936                                    orderByComparator);
7937    
7938                    if (blogsEntry != null) {
7939                            return blogsEntry;
7940                    }
7941    
7942                    StringBundler msg = new StringBundler(8);
7943    
7944                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7945    
7946                    msg.append("groupId=");
7947                    msg.append(groupId);
7948    
7949                    msg.append(", userId=");
7950                    msg.append(userId);
7951    
7952                    msg.append(", status=");
7953                    msg.append(status);
7954    
7955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7956    
7957                    throw new NoSuchEntryException(msg.toString());
7958            }
7959    
7960            /**
7961             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
7962             *
7963             * @param groupId the group ID
7964             * @param userId the user ID
7965             * @param status the status
7966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7967             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7968             * @throws SystemException if a system exception occurred
7969             */
7970            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
7971                    OrderByComparator orderByComparator) throws SystemException {
7972                    int count = countByG_U_S(groupId, userId, status);
7973    
7974                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
7975                                    count, orderByComparator);
7976    
7977                    if (!list.isEmpty()) {
7978                            return list.get(0);
7979                    }
7980    
7981                    return null;
7982            }
7983    
7984            /**
7985             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
7986             *
7987             * @param entryId the primary key of the current blogs entry
7988             * @param groupId the group ID
7989             * @param userId the user ID
7990             * @param status the status
7991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7992             * @return the previous, current, and next blogs entry
7993             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7994             * @throws SystemException if a system exception occurred
7995             */
7996            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
7997                    long userId, int status, OrderByComparator orderByComparator)
7998                    throws NoSuchEntryException, SystemException {
7999                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8000    
8001                    Session session = null;
8002    
8003                    try {
8004                            session = openSession();
8005    
8006                            BlogsEntry[] array = new BlogsEntryImpl[3];
8007    
8008                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
8009                                            userId, status, orderByComparator, true);
8010    
8011                            array[1] = blogsEntry;
8012    
8013                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
8014                                            userId, status, orderByComparator, false);
8015    
8016                            return array;
8017                    }
8018                    catch (Exception e) {
8019                            throw processException(e);
8020                    }
8021                    finally {
8022                            closeSession(session);
8023                    }
8024            }
8025    
8026            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
8027                    BlogsEntry blogsEntry, long groupId, long userId, int status,
8028                    OrderByComparator orderByComparator, boolean previous) {
8029                    StringBundler query = null;
8030    
8031                    if (orderByComparator != null) {
8032                            query = new StringBundler(6 +
8033                                            (orderByComparator.getOrderByFields().length * 6));
8034                    }
8035                    else {
8036                            query = new StringBundler(3);
8037                    }
8038    
8039                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8040    
8041                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
8042    
8043                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
8044    
8045                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
8046    
8047                    if (orderByComparator != null) {
8048                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8049    
8050                            if (orderByConditionFields.length > 0) {
8051                                    query.append(WHERE_AND);
8052                            }
8053    
8054                            for (int i = 0; i < orderByConditionFields.length; i++) {
8055                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8056                                    query.append(orderByConditionFields[i]);
8057    
8058                                    if ((i + 1) < orderByConditionFields.length) {
8059                                            if (orderByComparator.isAscending() ^ previous) {
8060                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8061                                            }
8062                                            else {
8063                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8064                                            }
8065                                    }
8066                                    else {
8067                                            if (orderByComparator.isAscending() ^ previous) {
8068                                                    query.append(WHERE_GREATER_THAN);
8069                                            }
8070                                            else {
8071                                                    query.append(WHERE_LESSER_THAN);
8072                                            }
8073                                    }
8074                            }
8075    
8076                            query.append(ORDER_BY_CLAUSE);
8077    
8078                            String[] orderByFields = orderByComparator.getOrderByFields();
8079    
8080                            for (int i = 0; i < orderByFields.length; i++) {
8081                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8082                                    query.append(orderByFields[i]);
8083    
8084                                    if ((i + 1) < orderByFields.length) {
8085                                            if (orderByComparator.isAscending() ^ previous) {
8086                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8087                                            }
8088                                            else {
8089                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8090                                            }
8091                                    }
8092                                    else {
8093                                            if (orderByComparator.isAscending() ^ previous) {
8094                                                    query.append(ORDER_BY_ASC);
8095                                            }
8096                                            else {
8097                                                    query.append(ORDER_BY_DESC);
8098                                            }
8099                                    }
8100                            }
8101                    }
8102    
8103                    else {
8104                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8105                    }
8106    
8107                    String sql = query.toString();
8108    
8109                    Query q = session.createQuery(sql);
8110    
8111                    q.setFirstResult(0);
8112                    q.setMaxResults(2);
8113    
8114                    QueryPos qPos = QueryPos.getInstance(q);
8115    
8116                    qPos.add(groupId);
8117    
8118                    qPos.add(userId);
8119    
8120                    qPos.add(status);
8121    
8122                    if (orderByComparator != null) {
8123                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8124    
8125                            for (Object value : values) {
8126                                    qPos.add(value);
8127                            }
8128                    }
8129    
8130                    List<BlogsEntry> list = q.list();
8131    
8132                    if (list.size() == 2) {
8133                            return list.get(1);
8134                    }
8135                    else {
8136                            return null;
8137                    }
8138            }
8139    
8140            /**
8141             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
8142             *
8143             * @param groupId the group ID
8144             * @param userId the user ID
8145             * @param status the status
8146             * @return the matching blogs entries that the user has permission to view
8147             * @throws SystemException if a system exception occurred
8148             */
8149            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
8150                    int status) throws SystemException {
8151                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
8152                            QueryUtil.ALL_POS, null);
8153            }
8154    
8155            /**
8156             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
8157             *
8158             * <p>
8159             * 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.
8160             * </p>
8161             *
8162             * @param groupId the group ID
8163             * @param userId the user ID
8164             * @param status the status
8165             * @param start the lower bound of the range of blogs entries
8166             * @param end the upper bound of the range of blogs entries (not inclusive)
8167             * @return the range of matching blogs entries that the user has permission to view
8168             * @throws SystemException if a system exception occurred
8169             */
8170            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
8171                    int status, int start, int end) throws SystemException {
8172                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
8173            }
8174    
8175            /**
8176             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;.
8177             *
8178             * <p>
8179             * 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.
8180             * </p>
8181             *
8182             * @param groupId the group ID
8183             * @param userId the user ID
8184             * @param status the status
8185             * @param start the lower bound of the range of blogs entries
8186             * @param end the upper bound of the range of blogs entries (not inclusive)
8187             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8188             * @return the ordered range of matching blogs entries that the user has permission to view
8189             * @throws SystemException if a system exception occurred
8190             */
8191            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
8192                    int status, int start, int end, OrderByComparator orderByComparator)
8193                    throws SystemException {
8194                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8195                            return findByG_U_S(groupId, userId, status, start, end,
8196                                    orderByComparator);
8197                    }
8198    
8199                    StringBundler query = null;
8200    
8201                    if (orderByComparator != null) {
8202                            query = new StringBundler(5 +
8203                                            (orderByComparator.getOrderByFields().length * 3));
8204                    }
8205                    else {
8206                            query = new StringBundler(5);
8207                    }
8208    
8209                    if (getDB().isSupportsInlineDistinct()) {
8210                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
8211                    }
8212                    else {
8213                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
8214                    }
8215    
8216                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
8217    
8218                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
8219    
8220                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
8221    
8222                    if (!getDB().isSupportsInlineDistinct()) {
8223                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
8224                    }
8225    
8226                    if (orderByComparator != null) {
8227                            if (getDB().isSupportsInlineDistinct()) {
8228                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8229                                            orderByComparator);
8230                            }
8231                            else {
8232                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8233                                            orderByComparator);
8234                            }
8235                    }
8236    
8237                    else {
8238                            if (getDB().isSupportsInlineDistinct()) {
8239                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8240                            }
8241                            else {
8242                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
8243                            }
8244                    }
8245    
8246                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8247                                    BlogsEntry.class.getName(),
8248                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8249    
8250                    Session session = null;
8251    
8252                    try {
8253                            session = openSession();
8254    
8255                            SQLQuery q = session.createSQLQuery(sql);
8256    
8257                            if (getDB().isSupportsInlineDistinct()) {
8258                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
8259                            }
8260                            else {
8261                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
8262                            }
8263    
8264                            QueryPos qPos = QueryPos.getInstance(q);
8265    
8266                            qPos.add(groupId);
8267    
8268                            qPos.add(userId);
8269    
8270                            qPos.add(status);
8271    
8272                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
8273                    }
8274                    catch (Exception e) {
8275                            throw processException(e);
8276                    }
8277                    finally {
8278                            closeSession(session);
8279                    }
8280            }
8281    
8282            /**
8283             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
8284             *
8285             * @param entryId the primary key of the current blogs entry
8286             * @param groupId the group ID
8287             * @param userId the user ID
8288             * @param status the status
8289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8290             * @return the previous, current, and next blogs entry
8291             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8292             * @throws SystemException if a system exception occurred
8293             */
8294            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
8295                    long groupId, long userId, int status,
8296                    OrderByComparator orderByComparator)
8297                    throws NoSuchEntryException, SystemException {
8298                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8299                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
8300                                    orderByComparator);
8301                    }
8302    
8303                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8304    
8305                    Session session = null;
8306    
8307                    try {
8308                            session = openSession();
8309    
8310                            BlogsEntry[] array = new BlogsEntryImpl[3];
8311    
8312                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
8313                                            groupId, userId, status, orderByComparator, true);
8314    
8315                            array[1] = blogsEntry;
8316    
8317                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
8318                                            groupId, userId, status, orderByComparator, false);
8319    
8320                            return array;
8321                    }
8322                    catch (Exception e) {
8323                            throw processException(e);
8324                    }
8325                    finally {
8326                            closeSession(session);
8327                    }
8328            }
8329    
8330            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
8331                    BlogsEntry blogsEntry, long groupId, long userId, int status,
8332                    OrderByComparator orderByComparator, boolean previous) {
8333                    StringBundler query = null;
8334    
8335                    if (orderByComparator != null) {
8336                            query = new StringBundler(6 +
8337                                            (orderByComparator.getOrderByFields().length * 6));
8338                    }
8339                    else {
8340                            query = new StringBundler(3);
8341                    }
8342    
8343                    if (getDB().isSupportsInlineDistinct()) {
8344                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
8345                    }
8346                    else {
8347                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
8348                    }
8349    
8350                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
8351    
8352                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
8353    
8354                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
8355    
8356                    if (!getDB().isSupportsInlineDistinct()) {
8357                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
8358                    }
8359    
8360                    if (orderByComparator != null) {
8361                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8362    
8363                            if (orderByConditionFields.length > 0) {
8364                                    query.append(WHERE_AND);
8365                            }
8366    
8367                            for (int i = 0; i < orderByConditionFields.length; i++) {
8368                                    if (getDB().isSupportsInlineDistinct()) {
8369                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8370                                    }
8371                                    else {
8372                                            query.append(_ORDER_BY_ENTITY_TABLE);
8373                                    }
8374    
8375                                    query.append(orderByConditionFields[i]);
8376    
8377                                    if ((i + 1) < orderByConditionFields.length) {
8378                                            if (orderByComparator.isAscending() ^ previous) {
8379                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8380                                            }
8381                                            else {
8382                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8383                                            }
8384                                    }
8385                                    else {
8386                                            if (orderByComparator.isAscending() ^ previous) {
8387                                                    query.append(WHERE_GREATER_THAN);
8388                                            }
8389                                            else {
8390                                                    query.append(WHERE_LESSER_THAN);
8391                                            }
8392                                    }
8393                            }
8394    
8395                            query.append(ORDER_BY_CLAUSE);
8396    
8397                            String[] orderByFields = orderByComparator.getOrderByFields();
8398    
8399                            for (int i = 0; i < orderByFields.length; i++) {
8400                                    if (getDB().isSupportsInlineDistinct()) {
8401                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8402                                    }
8403                                    else {
8404                                            query.append(_ORDER_BY_ENTITY_TABLE);
8405                                    }
8406    
8407                                    query.append(orderByFields[i]);
8408    
8409                                    if ((i + 1) < orderByFields.length) {
8410                                            if (orderByComparator.isAscending() ^ previous) {
8411                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8412                                            }
8413                                            else {
8414                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8415                                            }
8416                                    }
8417                                    else {
8418                                            if (orderByComparator.isAscending() ^ previous) {
8419                                                    query.append(ORDER_BY_ASC);
8420                                            }
8421                                            else {
8422                                                    query.append(ORDER_BY_DESC);
8423                                            }
8424                                    }
8425                            }
8426                    }
8427    
8428                    else {
8429                            if (getDB().isSupportsInlineDistinct()) {
8430                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8431                            }
8432                            else {
8433                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
8434                            }
8435                    }
8436    
8437                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8438                                    BlogsEntry.class.getName(),
8439                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8440    
8441                    SQLQuery q = session.createSQLQuery(sql);
8442    
8443                    q.setFirstResult(0);
8444                    q.setMaxResults(2);
8445    
8446                    if (getDB().isSupportsInlineDistinct()) {
8447                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
8448                    }
8449                    else {
8450                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
8451                    }
8452    
8453                    QueryPos qPos = QueryPos.getInstance(q);
8454    
8455                    qPos.add(groupId);
8456    
8457                    qPos.add(userId);
8458    
8459                    qPos.add(status);
8460    
8461                    if (orderByComparator != null) {
8462                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8463    
8464                            for (Object value : values) {
8465                                    qPos.add(value);
8466                            }
8467                    }
8468    
8469                    List<BlogsEntry> list = q.list();
8470    
8471                    if (list.size() == 2) {
8472                            return list.get(1);
8473                    }
8474                    else {
8475                            return null;
8476                    }
8477            }
8478    
8479            /**
8480             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8481             *
8482             * @param groupId the group ID
8483             * @param displayDate the display date
8484             * @param status the status
8485             * @return the matching blogs entries
8486             * @throws SystemException if a system exception occurred
8487             */
8488            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
8489                    int status) throws SystemException {
8490                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
8491                            QueryUtil.ALL_POS, null);
8492            }
8493    
8494            /**
8495             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8496             *
8497             * <p>
8498             * 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.
8499             * </p>
8500             *
8501             * @param groupId the group ID
8502             * @param displayDate the display date
8503             * @param status the status
8504             * @param start the lower bound of the range of blogs entries
8505             * @param end the upper bound of the range of blogs entries (not inclusive)
8506             * @return the range of matching blogs entries
8507             * @throws SystemException if a system exception occurred
8508             */
8509            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
8510                    int status, int start, int end) throws SystemException {
8511                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
8512            }
8513    
8514            /**
8515             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8516             *
8517             * <p>
8518             * 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.
8519             * </p>
8520             *
8521             * @param groupId the group ID
8522             * @param displayDate the display date
8523             * @param status the status
8524             * @param start the lower bound of the range of blogs entries
8525             * @param end the upper bound of the range of blogs entries (not inclusive)
8526             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8527             * @return the ordered range of matching blogs entries
8528             * @throws SystemException if a system exception occurred
8529             */
8530            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
8531                    int status, int start, int end, OrderByComparator orderByComparator)
8532                    throws SystemException {
8533                    FinderPath finderPath = null;
8534                    Object[] finderArgs = null;
8535    
8536                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
8537                    finderArgs = new Object[] {
8538                                    groupId, displayDate, status,
8539                                    
8540                                    start, end, orderByComparator
8541                            };
8542    
8543                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8544                                    finderArgs, this);
8545    
8546                    if ((list != null) && !list.isEmpty()) {
8547                            for (BlogsEntry blogsEntry : list) {
8548                                    if ((groupId != blogsEntry.getGroupId()) ||
8549                                                    !Validator.equals(displayDate,
8550                                                            blogsEntry.getDisplayDate()) ||
8551                                                    (status != blogsEntry.getStatus())) {
8552                                            list = null;
8553    
8554                                            break;
8555                                    }
8556                            }
8557                    }
8558    
8559                    if (list == null) {
8560                            StringBundler query = null;
8561    
8562                            if (orderByComparator != null) {
8563                                    query = new StringBundler(5 +
8564                                                    (orderByComparator.getOrderByFields().length * 3));
8565                            }
8566                            else {
8567                                    query = new StringBundler(5);
8568                            }
8569    
8570                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8571    
8572                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
8573    
8574                            if (displayDate == null) {
8575                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
8576                            }
8577                            else {
8578                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
8579                            }
8580    
8581                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
8582    
8583                            if (orderByComparator != null) {
8584                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8585                                            orderByComparator);
8586                            }
8587    
8588                            else {
8589                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8590                            }
8591    
8592                            String sql = query.toString();
8593    
8594                            Session session = null;
8595    
8596                            try {
8597                                    session = openSession();
8598    
8599                                    Query q = session.createQuery(sql);
8600    
8601                                    QueryPos qPos = QueryPos.getInstance(q);
8602    
8603                                    qPos.add(groupId);
8604    
8605                                    if (displayDate != null) {
8606                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8607                                    }
8608    
8609                                    qPos.add(status);
8610    
8611                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
8612                                                    end);
8613                            }
8614                            catch (Exception e) {
8615                                    throw processException(e);
8616                            }
8617                            finally {
8618                                    if (list == null) {
8619                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8620                                    }
8621                                    else {
8622                                            cacheResult(list);
8623    
8624                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8625                                    }
8626    
8627                                    closeSession(session);
8628                            }
8629                    }
8630    
8631                    return list;
8632            }
8633    
8634            /**
8635             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8636             *
8637             * @param groupId the group ID
8638             * @param displayDate the display date
8639             * @param status the status
8640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8641             * @return the first matching blogs entry
8642             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8643             * @throws SystemException if a system exception occurred
8644             */
8645            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
8646                    int status, OrderByComparator orderByComparator)
8647                    throws NoSuchEntryException, SystemException {
8648                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
8649                                    status, orderByComparator);
8650    
8651                    if (blogsEntry != null) {
8652                            return blogsEntry;
8653                    }
8654    
8655                    StringBundler msg = new StringBundler(8);
8656    
8657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8658    
8659                    msg.append("groupId=");
8660                    msg.append(groupId);
8661    
8662                    msg.append(", displayDate=");
8663                    msg.append(displayDate);
8664    
8665                    msg.append(", status=");
8666                    msg.append(status);
8667    
8668                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8669    
8670                    throw new NoSuchEntryException(msg.toString());
8671            }
8672    
8673            /**
8674             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8675             *
8676             * @param groupId the group ID
8677             * @param displayDate the display date
8678             * @param status the status
8679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8680             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8681             * @throws SystemException if a system exception occurred
8682             */
8683            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
8684                    int status, OrderByComparator orderByComparator)
8685                    throws SystemException {
8686                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
8687                                    1, orderByComparator);
8688    
8689                    if (!list.isEmpty()) {
8690                            return list.get(0);
8691                    }
8692    
8693                    return null;
8694            }
8695    
8696            /**
8697             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8698             *
8699             * @param groupId the group ID
8700             * @param displayDate the display date
8701             * @param status the status
8702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8703             * @return the last matching blogs entry
8704             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8705             * @throws SystemException if a system exception occurred
8706             */
8707            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
8708                    int status, OrderByComparator orderByComparator)
8709                    throws NoSuchEntryException, SystemException {
8710                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
8711                                    status, orderByComparator);
8712    
8713                    if (blogsEntry != null) {
8714                            return blogsEntry;
8715                    }
8716    
8717                    StringBundler msg = new StringBundler(8);
8718    
8719                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8720    
8721                    msg.append("groupId=");
8722                    msg.append(groupId);
8723    
8724                    msg.append(", displayDate=");
8725                    msg.append(displayDate);
8726    
8727                    msg.append(", status=");
8728                    msg.append(status);
8729    
8730                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8731    
8732                    throw new NoSuchEntryException(msg.toString());
8733            }
8734    
8735            /**
8736             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8737             *
8738             * @param groupId the group ID
8739             * @param displayDate the display date
8740             * @param status the status
8741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8742             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8743             * @throws SystemException if a system exception occurred
8744             */
8745            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
8746                    int status, OrderByComparator orderByComparator)
8747                    throws SystemException {
8748                    int count = countByG_LtD_S(groupId, displayDate, status);
8749    
8750                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
8751                                    count - 1, count, orderByComparator);
8752    
8753                    if (!list.isEmpty()) {
8754                            return list.get(0);
8755                    }
8756    
8757                    return null;
8758            }
8759    
8760            /**
8761             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8762             *
8763             * @param entryId the primary key of the current blogs entry
8764             * @param groupId the group ID
8765             * @param displayDate the display date
8766             * @param status the status
8767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8768             * @return the previous, current, and next blogs entry
8769             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8770             * @throws SystemException if a system exception occurred
8771             */
8772            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
8773                    Date displayDate, int status, OrderByComparator orderByComparator)
8774                    throws NoSuchEntryException, SystemException {
8775                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8776    
8777                    Session session = null;
8778    
8779                    try {
8780                            session = openSession();
8781    
8782                            BlogsEntry[] array = new BlogsEntryImpl[3];
8783    
8784                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
8785                                            displayDate, status, orderByComparator, true);
8786    
8787                            array[1] = blogsEntry;
8788    
8789                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
8790                                            displayDate, status, orderByComparator, false);
8791    
8792                            return array;
8793                    }
8794                    catch (Exception e) {
8795                            throw processException(e);
8796                    }
8797                    finally {
8798                            closeSession(session);
8799                    }
8800            }
8801    
8802            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
8803                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
8804                    OrderByComparator orderByComparator, boolean previous) {
8805                    StringBundler query = null;
8806    
8807                    if (orderByComparator != null) {
8808                            query = new StringBundler(6 +
8809                                            (orderByComparator.getOrderByFields().length * 6));
8810                    }
8811                    else {
8812                            query = new StringBundler(3);
8813                    }
8814    
8815                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8816    
8817                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
8818    
8819                    if (displayDate == null) {
8820                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
8821                    }
8822                    else {
8823                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
8824                    }
8825    
8826                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
8827    
8828                    if (orderByComparator != null) {
8829                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8830    
8831                            if (orderByConditionFields.length > 0) {
8832                                    query.append(WHERE_AND);
8833                            }
8834    
8835                            for (int i = 0; i < orderByConditionFields.length; i++) {
8836                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8837                                    query.append(orderByConditionFields[i]);
8838    
8839                                    if ((i + 1) < orderByConditionFields.length) {
8840                                            if (orderByComparator.isAscending() ^ previous) {
8841                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8842                                            }
8843                                            else {
8844                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8845                                            }
8846                                    }
8847                                    else {
8848                                            if (orderByComparator.isAscending() ^ previous) {
8849                                                    query.append(WHERE_GREATER_THAN);
8850                                            }
8851                                            else {
8852                                                    query.append(WHERE_LESSER_THAN);
8853                                            }
8854                                    }
8855                            }
8856    
8857                            query.append(ORDER_BY_CLAUSE);
8858    
8859                            String[] orderByFields = orderByComparator.getOrderByFields();
8860    
8861                            for (int i = 0; i < orderByFields.length; i++) {
8862                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8863                                    query.append(orderByFields[i]);
8864    
8865                                    if ((i + 1) < orderByFields.length) {
8866                                            if (orderByComparator.isAscending() ^ previous) {
8867                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8868                                            }
8869                                            else {
8870                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8871                                            }
8872                                    }
8873                                    else {
8874                                            if (orderByComparator.isAscending() ^ previous) {
8875                                                    query.append(ORDER_BY_ASC);
8876                                            }
8877                                            else {
8878                                                    query.append(ORDER_BY_DESC);
8879                                            }
8880                                    }
8881                            }
8882                    }
8883    
8884                    else {
8885                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8886                    }
8887    
8888                    String sql = query.toString();
8889    
8890                    Query q = session.createQuery(sql);
8891    
8892                    q.setFirstResult(0);
8893                    q.setMaxResults(2);
8894    
8895                    QueryPos qPos = QueryPos.getInstance(q);
8896    
8897                    qPos.add(groupId);
8898    
8899                    if (displayDate != null) {
8900                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8901                    }
8902    
8903                    qPos.add(status);
8904    
8905                    if (orderByComparator != null) {
8906                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8907    
8908                            for (Object value : values) {
8909                                    qPos.add(value);
8910                            }
8911                    }
8912    
8913                    List<BlogsEntry> list = q.list();
8914    
8915                    if (list.size() == 2) {
8916                            return list.get(1);
8917                    }
8918                    else {
8919                            return null;
8920                    }
8921            }
8922    
8923            /**
8924             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8925             *
8926             * @param groupId the group ID
8927             * @param displayDate the display date
8928             * @param status the status
8929             * @return the matching blogs entries that the user has permission to view
8930             * @throws SystemException if a system exception occurred
8931             */
8932            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
8933                    int status) throws SystemException {
8934                    return filterFindByG_LtD_S(groupId, displayDate, status,
8935                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8936            }
8937    
8938            /**
8939             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8940             *
8941             * <p>
8942             * 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.
8943             * </p>
8944             *
8945             * @param groupId the group ID
8946             * @param displayDate the display date
8947             * @param status the status
8948             * @param start the lower bound of the range of blogs entries
8949             * @param end the upper bound of the range of blogs entries (not inclusive)
8950             * @return the range of matching blogs entries that the user has permission to view
8951             * @throws SystemException if a system exception occurred
8952             */
8953            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
8954                    int status, int start, int end) throws SystemException {
8955                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
8956                            null);
8957            }
8958    
8959            /**
8960             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
8961             *
8962             * <p>
8963             * 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.
8964             * </p>
8965             *
8966             * @param groupId the group ID
8967             * @param displayDate the display date
8968             * @param status the status
8969             * @param start the lower bound of the range of blogs entries
8970             * @param end the upper bound of the range of blogs entries (not inclusive)
8971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8972             * @return the ordered range of matching blogs entries that the user has permission to view
8973             * @throws SystemException if a system exception occurred
8974             */
8975            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
8976                    int status, int start, int end, OrderByComparator orderByComparator)
8977                    throws SystemException {
8978                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8979                            return findByG_LtD_S(groupId, displayDate, status, start, end,
8980                                    orderByComparator);
8981                    }
8982    
8983                    StringBundler query = null;
8984    
8985                    if (orderByComparator != null) {
8986                            query = new StringBundler(5 +
8987                                            (orderByComparator.getOrderByFields().length * 3));
8988                    }
8989                    else {
8990                            query = new StringBundler(5);
8991                    }
8992    
8993                    if (getDB().isSupportsInlineDistinct()) {
8994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
8995                    }
8996                    else {
8997                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
8998                    }
8999    
9000                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
9001    
9002                    if (displayDate == null) {
9003                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
9004                    }
9005                    else {
9006                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
9007                    }
9008    
9009                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
9010    
9011                    if (!getDB().isSupportsInlineDistinct()) {
9012                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9013                    }
9014    
9015                    if (orderByComparator != null) {
9016                            if (getDB().isSupportsInlineDistinct()) {
9017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9018                                            orderByComparator);
9019                            }
9020                            else {
9021                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9022                                            orderByComparator);
9023                            }
9024                    }
9025    
9026                    else {
9027                            if (getDB().isSupportsInlineDistinct()) {
9028                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9029                            }
9030                            else {
9031                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9032                            }
9033                    }
9034    
9035                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9036                                    BlogsEntry.class.getName(),
9037                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9038    
9039                    Session session = null;
9040    
9041                    try {
9042                            session = openSession();
9043    
9044                            SQLQuery q = session.createSQLQuery(sql);
9045    
9046                            if (getDB().isSupportsInlineDistinct()) {
9047                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9048                            }
9049                            else {
9050                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9051                            }
9052    
9053                            QueryPos qPos = QueryPos.getInstance(q);
9054    
9055                            qPos.add(groupId);
9056    
9057                            if (displayDate != null) {
9058                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
9059                            }
9060    
9061                            qPos.add(status);
9062    
9063                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9064                    }
9065                    catch (Exception e) {
9066                            throw processException(e);
9067                    }
9068                    finally {
9069                            closeSession(session);
9070                    }
9071            }
9072    
9073            /**
9074             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
9075             *
9076             * @param entryId the primary key of the current blogs entry
9077             * @param groupId the group ID
9078             * @param displayDate the display date
9079             * @param status the status
9080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9081             * @return the previous, current, and next blogs entry
9082             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9083             * @throws SystemException if a system exception occurred
9084             */
9085            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
9086                    long groupId, Date displayDate, int status,
9087                    OrderByComparator orderByComparator)
9088                    throws NoSuchEntryException, SystemException {
9089                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9090                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
9091                                    status, orderByComparator);
9092                    }
9093    
9094                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9095    
9096                    Session session = null;
9097    
9098                    try {
9099                            session = openSession();
9100    
9101                            BlogsEntry[] array = new BlogsEntryImpl[3];
9102    
9103                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
9104                                            groupId, displayDate, status, orderByComparator, true);
9105    
9106                            array[1] = blogsEntry;
9107    
9108                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
9109                                            groupId, displayDate, status, orderByComparator, false);
9110    
9111                            return array;
9112                    }
9113                    catch (Exception e) {
9114                            throw processException(e);
9115                    }
9116                    finally {
9117                            closeSession(session);
9118                    }
9119            }
9120    
9121            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
9122                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
9123                    OrderByComparator orderByComparator, boolean previous) {
9124                    StringBundler query = null;
9125    
9126                    if (orderByComparator != null) {
9127                            query = new StringBundler(6 +
9128                                            (orderByComparator.getOrderByFields().length * 6));
9129                    }
9130                    else {
9131                            query = new StringBundler(3);
9132                    }
9133    
9134                    if (getDB().isSupportsInlineDistinct()) {
9135                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9136                    }
9137                    else {
9138                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9139                    }
9140    
9141                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
9142    
9143                    if (displayDate == null) {
9144                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
9145                    }
9146                    else {
9147                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
9148                    }
9149    
9150                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
9151    
9152                    if (!getDB().isSupportsInlineDistinct()) {
9153                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9154                    }
9155    
9156                    if (orderByComparator != null) {
9157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9158    
9159                            if (orderByConditionFields.length > 0) {
9160                                    query.append(WHERE_AND);
9161                            }
9162    
9163                            for (int i = 0; i < orderByConditionFields.length; i++) {
9164                                    if (getDB().isSupportsInlineDistinct()) {
9165                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9166                                    }
9167                                    else {
9168                                            query.append(_ORDER_BY_ENTITY_TABLE);
9169                                    }
9170    
9171                                    query.append(orderByConditionFields[i]);
9172    
9173                                    if ((i + 1) < orderByConditionFields.length) {
9174                                            if (orderByComparator.isAscending() ^ previous) {
9175                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9176                                            }
9177                                            else {
9178                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9179                                            }
9180                                    }
9181                                    else {
9182                                            if (orderByComparator.isAscending() ^ previous) {
9183                                                    query.append(WHERE_GREATER_THAN);
9184                                            }
9185                                            else {
9186                                                    query.append(WHERE_LESSER_THAN);
9187                                            }
9188                                    }
9189                            }
9190    
9191                            query.append(ORDER_BY_CLAUSE);
9192    
9193                            String[] orderByFields = orderByComparator.getOrderByFields();
9194    
9195                            for (int i = 0; i < orderByFields.length; i++) {
9196                                    if (getDB().isSupportsInlineDistinct()) {
9197                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9198                                    }
9199                                    else {
9200                                            query.append(_ORDER_BY_ENTITY_TABLE);
9201                                    }
9202    
9203                                    query.append(orderByFields[i]);
9204    
9205                                    if ((i + 1) < orderByFields.length) {
9206                                            if (orderByComparator.isAscending() ^ previous) {
9207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9208                                            }
9209                                            else {
9210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9211                                            }
9212                                    }
9213                                    else {
9214                                            if (orderByComparator.isAscending() ^ previous) {
9215                                                    query.append(ORDER_BY_ASC);
9216                                            }
9217                                            else {
9218                                                    query.append(ORDER_BY_DESC);
9219                                            }
9220                                    }
9221                            }
9222                    }
9223    
9224                    else {
9225                            if (getDB().isSupportsInlineDistinct()) {
9226                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9227                            }
9228                            else {
9229                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9230                            }
9231                    }
9232    
9233                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9234                                    BlogsEntry.class.getName(),
9235                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9236    
9237                    SQLQuery q = session.createSQLQuery(sql);
9238    
9239                    q.setFirstResult(0);
9240                    q.setMaxResults(2);
9241    
9242                    if (getDB().isSupportsInlineDistinct()) {
9243                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9244                    }
9245                    else {
9246                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9247                    }
9248    
9249                    QueryPos qPos = QueryPos.getInstance(q);
9250    
9251                    qPos.add(groupId);
9252    
9253                    if (displayDate != null) {
9254                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9255                    }
9256    
9257                    qPos.add(status);
9258    
9259                    if (orderByComparator != null) {
9260                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9261    
9262                            for (Object value : values) {
9263                                    qPos.add(value);
9264                            }
9265                    }
9266    
9267                    List<BlogsEntry> list = q.list();
9268    
9269                    if (list.size() == 2) {
9270                            return list.get(1);
9271                    }
9272                    else {
9273                            return null;
9274                    }
9275            }
9276    
9277            /**
9278             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9279             *
9280             * @param groupId the group ID
9281             * @param userId the user ID
9282             * @param displayDate the display date
9283             * @param status the status
9284             * @return the matching blogs entries
9285             * @throws SystemException if a system exception occurred
9286             */
9287            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
9288                    Date displayDate, int status) throws SystemException {
9289                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
9290                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9291            }
9292    
9293            /**
9294             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9295             *
9296             * <p>
9297             * 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.
9298             * </p>
9299             *
9300             * @param groupId the group ID
9301             * @param userId the user ID
9302             * @param displayDate the display date
9303             * @param status the status
9304             * @param start the lower bound of the range of blogs entries
9305             * @param end the upper bound of the range of blogs entries (not inclusive)
9306             * @return the range of matching blogs entries
9307             * @throws SystemException if a system exception occurred
9308             */
9309            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
9310                    Date displayDate, int status, int start, int end)
9311                    throws SystemException {
9312                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
9313                            end, null);
9314            }
9315    
9316            /**
9317             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9318             *
9319             * <p>
9320             * 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.
9321             * </p>
9322             *
9323             * @param groupId the group ID
9324             * @param userId the user ID
9325             * @param displayDate the display date
9326             * @param status the status
9327             * @param start the lower bound of the range of blogs entries
9328             * @param end the upper bound of the range of blogs entries (not inclusive)
9329             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9330             * @return the ordered range of matching blogs entries
9331             * @throws SystemException if a system exception occurred
9332             */
9333            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
9334                    Date displayDate, int status, int start, int end,
9335                    OrderByComparator orderByComparator) throws SystemException {
9336                    FinderPath finderPath = null;
9337                    Object[] finderArgs = null;
9338    
9339                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
9340                    finderArgs = new Object[] {
9341                                    groupId, userId, displayDate, status,
9342                                    
9343                                    start, end, orderByComparator
9344                            };
9345    
9346                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9347                                    finderArgs, this);
9348    
9349                    if ((list != null) && !list.isEmpty()) {
9350                            for (BlogsEntry blogsEntry : list) {
9351                                    if ((groupId != blogsEntry.getGroupId()) ||
9352                                                    (userId != blogsEntry.getUserId()) ||
9353                                                    !Validator.equals(displayDate,
9354                                                            blogsEntry.getDisplayDate()) ||
9355                                                    (status != blogsEntry.getStatus())) {
9356                                            list = null;
9357    
9358                                            break;
9359                                    }
9360                            }
9361                    }
9362    
9363                    if (list == null) {
9364                            StringBundler query = null;
9365    
9366                            if (orderByComparator != null) {
9367                                    query = new StringBundler(6 +
9368                                                    (orderByComparator.getOrderByFields().length * 3));
9369                            }
9370                            else {
9371                                    query = new StringBundler(6);
9372                            }
9373    
9374                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9375    
9376                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
9377    
9378                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
9379    
9380                            if (displayDate == null) {
9381                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
9382                            }
9383                            else {
9384                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
9385                            }
9386    
9387                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
9388    
9389                            if (orderByComparator != null) {
9390                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9391                                            orderByComparator);
9392                            }
9393    
9394                            else {
9395                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9396                            }
9397    
9398                            String sql = query.toString();
9399    
9400                            Session session = null;
9401    
9402                            try {
9403                                    session = openSession();
9404    
9405                                    Query q = session.createQuery(sql);
9406    
9407                                    QueryPos qPos = QueryPos.getInstance(q);
9408    
9409                                    qPos.add(groupId);
9410    
9411                                    qPos.add(userId);
9412    
9413                                    if (displayDate != null) {
9414                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9415                                    }
9416    
9417                                    qPos.add(status);
9418    
9419                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
9420                                                    end);
9421                            }
9422                            catch (Exception e) {
9423                                    throw processException(e);
9424                            }
9425                            finally {
9426                                    if (list == null) {
9427                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9428                                    }
9429                                    else {
9430                                            cacheResult(list);
9431    
9432                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9433                                    }
9434    
9435                                    closeSession(session);
9436                            }
9437                    }
9438    
9439                    return list;
9440            }
9441    
9442            /**
9443             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9444             *
9445             * @param groupId the group ID
9446             * @param userId the user ID
9447             * @param displayDate the display date
9448             * @param status the status
9449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9450             * @return the first matching blogs entry
9451             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9452             * @throws SystemException if a system exception occurred
9453             */
9454            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
9455                    Date displayDate, int status, OrderByComparator orderByComparator)
9456                    throws NoSuchEntryException, SystemException {
9457                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
9458                                    displayDate, status, orderByComparator);
9459    
9460                    if (blogsEntry != null) {
9461                            return blogsEntry;
9462                    }
9463    
9464                    StringBundler msg = new StringBundler(10);
9465    
9466                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9467    
9468                    msg.append("groupId=");
9469                    msg.append(groupId);
9470    
9471                    msg.append(", userId=");
9472                    msg.append(userId);
9473    
9474                    msg.append(", displayDate=");
9475                    msg.append(displayDate);
9476    
9477                    msg.append(", status=");
9478                    msg.append(status);
9479    
9480                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9481    
9482                    throw new NoSuchEntryException(msg.toString());
9483            }
9484    
9485            /**
9486             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9487             *
9488             * @param groupId the group ID
9489             * @param userId the user ID
9490             * @param displayDate the display date
9491             * @param status the status
9492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9493             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9494             * @throws SystemException if a system exception occurred
9495             */
9496            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
9497                    Date displayDate, int status, OrderByComparator orderByComparator)
9498                    throws SystemException {
9499                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
9500                                    status, 0, 1, orderByComparator);
9501    
9502                    if (!list.isEmpty()) {
9503                            return list.get(0);
9504                    }
9505    
9506                    return null;
9507            }
9508    
9509            /**
9510             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9511             *
9512             * @param groupId the group ID
9513             * @param userId the user ID
9514             * @param displayDate the display date
9515             * @param status the status
9516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9517             * @return the last matching blogs entry
9518             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9519             * @throws SystemException if a system exception occurred
9520             */
9521            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
9522                    Date displayDate, int status, OrderByComparator orderByComparator)
9523                    throws NoSuchEntryException, SystemException {
9524                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
9525                                    displayDate, status, orderByComparator);
9526    
9527                    if (blogsEntry != null) {
9528                            return blogsEntry;
9529                    }
9530    
9531                    StringBundler msg = new StringBundler(10);
9532    
9533                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9534    
9535                    msg.append("groupId=");
9536                    msg.append(groupId);
9537    
9538                    msg.append(", userId=");
9539                    msg.append(userId);
9540    
9541                    msg.append(", displayDate=");
9542                    msg.append(displayDate);
9543    
9544                    msg.append(", status=");
9545                    msg.append(status);
9546    
9547                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9548    
9549                    throw new NoSuchEntryException(msg.toString());
9550            }
9551    
9552            /**
9553             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9554             *
9555             * @param groupId the group ID
9556             * @param userId the user ID
9557             * @param displayDate the display date
9558             * @param status the status
9559             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9560             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9561             * @throws SystemException if a system exception occurred
9562             */
9563            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
9564                    Date displayDate, int status, OrderByComparator orderByComparator)
9565                    throws SystemException {
9566                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
9567    
9568                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
9569                                    status, count - 1, count, orderByComparator);
9570    
9571                    if (!list.isEmpty()) {
9572                            return list.get(0);
9573                    }
9574    
9575                    return null;
9576            }
9577    
9578            /**
9579             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9580             *
9581             * @param entryId the primary key of the current blogs entry
9582             * @param groupId the group ID
9583             * @param userId the user ID
9584             * @param displayDate the display date
9585             * @param status the status
9586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9587             * @return the previous, current, and next blogs entry
9588             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9589             * @throws SystemException if a system exception occurred
9590             */
9591            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
9592                    long userId, Date displayDate, int status,
9593                    OrderByComparator orderByComparator)
9594                    throws NoSuchEntryException, SystemException {
9595                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9596    
9597                    Session session = null;
9598    
9599                    try {
9600                            session = openSession();
9601    
9602                            BlogsEntry[] array = new BlogsEntryImpl[3];
9603    
9604                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
9605                                            userId, displayDate, status, orderByComparator, true);
9606    
9607                            array[1] = blogsEntry;
9608    
9609                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
9610                                            userId, displayDate, status, orderByComparator, false);
9611    
9612                            return array;
9613                    }
9614                    catch (Exception e) {
9615                            throw processException(e);
9616                    }
9617                    finally {
9618                            closeSession(session);
9619                    }
9620            }
9621    
9622            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
9623                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9624                    int status, OrderByComparator orderByComparator, boolean previous) {
9625                    StringBundler query = null;
9626    
9627                    if (orderByComparator != null) {
9628                            query = new StringBundler(6 +
9629                                            (orderByComparator.getOrderByFields().length * 6));
9630                    }
9631                    else {
9632                            query = new StringBundler(3);
9633                    }
9634    
9635                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9636    
9637                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
9638    
9639                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
9640    
9641                    if (displayDate == null) {
9642                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
9643                    }
9644                    else {
9645                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
9646                    }
9647    
9648                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
9649    
9650                    if (orderByComparator != null) {
9651                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9652    
9653                            if (orderByConditionFields.length > 0) {
9654                                    query.append(WHERE_AND);
9655                            }
9656    
9657                            for (int i = 0; i < orderByConditionFields.length; i++) {
9658                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9659                                    query.append(orderByConditionFields[i]);
9660    
9661                                    if ((i + 1) < orderByConditionFields.length) {
9662                                            if (orderByComparator.isAscending() ^ previous) {
9663                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9664                                            }
9665                                            else {
9666                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9667                                            }
9668                                    }
9669                                    else {
9670                                            if (orderByComparator.isAscending() ^ previous) {
9671                                                    query.append(WHERE_GREATER_THAN);
9672                                            }
9673                                            else {
9674                                                    query.append(WHERE_LESSER_THAN);
9675                                            }
9676                                    }
9677                            }
9678    
9679                            query.append(ORDER_BY_CLAUSE);
9680    
9681                            String[] orderByFields = orderByComparator.getOrderByFields();
9682    
9683                            for (int i = 0; i < orderByFields.length; i++) {
9684                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9685                                    query.append(orderByFields[i]);
9686    
9687                                    if ((i + 1) < orderByFields.length) {
9688                                            if (orderByComparator.isAscending() ^ previous) {
9689                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9690                                            }
9691                                            else {
9692                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9693                                            }
9694                                    }
9695                                    else {
9696                                            if (orderByComparator.isAscending() ^ previous) {
9697                                                    query.append(ORDER_BY_ASC);
9698                                            }
9699                                            else {
9700                                                    query.append(ORDER_BY_DESC);
9701                                            }
9702                                    }
9703                            }
9704                    }
9705    
9706                    else {
9707                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9708                    }
9709    
9710                    String sql = query.toString();
9711    
9712                    Query q = session.createQuery(sql);
9713    
9714                    q.setFirstResult(0);
9715                    q.setMaxResults(2);
9716    
9717                    QueryPos qPos = QueryPos.getInstance(q);
9718    
9719                    qPos.add(groupId);
9720    
9721                    qPos.add(userId);
9722    
9723                    if (displayDate != null) {
9724                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9725                    }
9726    
9727                    qPos.add(status);
9728    
9729                    if (orderByComparator != null) {
9730                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9731    
9732                            for (Object value : values) {
9733                                    qPos.add(value);
9734                            }
9735                    }
9736    
9737                    List<BlogsEntry> list = q.list();
9738    
9739                    if (list.size() == 2) {
9740                            return list.get(1);
9741                    }
9742                    else {
9743                            return null;
9744                    }
9745            }
9746    
9747            /**
9748             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9749             *
9750             * @param groupId the group ID
9751             * @param userId the user ID
9752             * @param displayDate the display date
9753             * @param status the status
9754             * @return the matching blogs entries that the user has permission to view
9755             * @throws SystemException if a system exception occurred
9756             */
9757            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
9758                    Date displayDate, int status) throws SystemException {
9759                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
9760                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9761            }
9762    
9763            /**
9764             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9765             *
9766             * <p>
9767             * 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.
9768             * </p>
9769             *
9770             * @param groupId the group ID
9771             * @param userId the user ID
9772             * @param displayDate the display date
9773             * @param status the status
9774             * @param start the lower bound of the range of blogs entries
9775             * @param end the upper bound of the range of blogs entries (not inclusive)
9776             * @return the range of matching blogs entries that the user has permission to view
9777             * @throws SystemException if a system exception occurred
9778             */
9779            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
9780                    Date displayDate, int status, int start, int end)
9781                    throws SystemException {
9782                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
9783                            start, end, null);
9784            }
9785    
9786            /**
9787             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9788             *
9789             * <p>
9790             * 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.
9791             * </p>
9792             *
9793             * @param groupId the group ID
9794             * @param userId the user ID
9795             * @param displayDate the display date
9796             * @param status the status
9797             * @param start the lower bound of the range of blogs entries
9798             * @param end the upper bound of the range of blogs entries (not inclusive)
9799             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9800             * @return the ordered range of matching blogs entries that the user has permission to view
9801             * @throws SystemException if a system exception occurred
9802             */
9803            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
9804                    Date displayDate, int status, int start, int end,
9805                    OrderByComparator orderByComparator) throws SystemException {
9806                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9807                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
9808                                    end, orderByComparator);
9809                    }
9810    
9811                    StringBundler query = null;
9812    
9813                    if (orderByComparator != null) {
9814                            query = new StringBundler(6 +
9815                                            (orderByComparator.getOrderByFields().length * 3));
9816                    }
9817                    else {
9818                            query = new StringBundler(6);
9819                    }
9820    
9821                    if (getDB().isSupportsInlineDistinct()) {
9822                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9823                    }
9824                    else {
9825                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9826                    }
9827    
9828                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
9829    
9830                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
9831    
9832                    if (displayDate == null) {
9833                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
9834                    }
9835                    else {
9836                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
9837                    }
9838    
9839                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
9840    
9841                    if (!getDB().isSupportsInlineDistinct()) {
9842                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9843                    }
9844    
9845                    if (orderByComparator != null) {
9846                            if (getDB().isSupportsInlineDistinct()) {
9847                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9848                                            orderByComparator);
9849                            }
9850                            else {
9851                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9852                                            orderByComparator);
9853                            }
9854                    }
9855    
9856                    else {
9857                            if (getDB().isSupportsInlineDistinct()) {
9858                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9859                            }
9860                            else {
9861                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9862                            }
9863                    }
9864    
9865                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9866                                    BlogsEntry.class.getName(),
9867                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9868    
9869                    Session session = null;
9870    
9871                    try {
9872                            session = openSession();
9873    
9874                            SQLQuery q = session.createSQLQuery(sql);
9875    
9876                            if (getDB().isSupportsInlineDistinct()) {
9877                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9878                            }
9879                            else {
9880                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9881                            }
9882    
9883                            QueryPos qPos = QueryPos.getInstance(q);
9884    
9885                            qPos.add(groupId);
9886    
9887                            qPos.add(userId);
9888    
9889                            if (displayDate != null) {
9890                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
9891                            }
9892    
9893                            qPos.add(status);
9894    
9895                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9896                    }
9897                    catch (Exception e) {
9898                            throw processException(e);
9899                    }
9900                    finally {
9901                            closeSession(session);
9902                    }
9903            }
9904    
9905            /**
9906             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
9907             *
9908             * @param entryId the primary key of the current blogs entry
9909             * @param groupId the group ID
9910             * @param userId the user ID
9911             * @param displayDate the display date
9912             * @param status the status
9913             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9914             * @return the previous, current, and next blogs entry
9915             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9916             * @throws SystemException if a system exception occurred
9917             */
9918            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
9919                    long groupId, long userId, Date displayDate, int status,
9920                    OrderByComparator orderByComparator)
9921                    throws NoSuchEntryException, SystemException {
9922                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9923                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
9924                                    displayDate, status, orderByComparator);
9925                    }
9926    
9927                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9928    
9929                    Session session = null;
9930    
9931                    try {
9932                            session = openSession();
9933    
9934                            BlogsEntry[] array = new BlogsEntryImpl[3];
9935    
9936                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
9937                                            groupId, userId, displayDate, status, orderByComparator,
9938                                            true);
9939    
9940                            array[1] = blogsEntry;
9941    
9942                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
9943                                            groupId, userId, displayDate, status, orderByComparator,
9944                                            false);
9945    
9946                            return array;
9947                    }
9948                    catch (Exception e) {
9949                            throw processException(e);
9950                    }
9951                    finally {
9952                            closeSession(session);
9953                    }
9954            }
9955    
9956            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
9957                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9958                    int status, OrderByComparator orderByComparator, boolean previous) {
9959                    StringBundler query = null;
9960    
9961                    if (orderByComparator != null) {
9962                            query = new StringBundler(6 +
9963                                            (orderByComparator.getOrderByFields().length * 6));
9964                    }
9965                    else {
9966                            query = new StringBundler(3);
9967                    }
9968    
9969                    if (getDB().isSupportsInlineDistinct()) {
9970                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9971                    }
9972                    else {
9973                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9974                    }
9975    
9976                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
9977    
9978                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
9979    
9980                    if (displayDate == null) {
9981                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
9982                    }
9983                    else {
9984                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
9985                    }
9986    
9987                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
9988    
9989                    if (!getDB().isSupportsInlineDistinct()) {
9990                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9991                    }
9992    
9993                    if (orderByComparator != null) {
9994                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9995    
9996                            if (orderByConditionFields.length > 0) {
9997                                    query.append(WHERE_AND);
9998                            }
9999    
10000                            for (int i = 0; i < orderByConditionFields.length; i++) {
10001                                    if (getDB().isSupportsInlineDistinct()) {
10002                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10003                                    }
10004                                    else {
10005                                            query.append(_ORDER_BY_ENTITY_TABLE);
10006                                    }
10007    
10008                                    query.append(orderByConditionFields[i]);
10009    
10010                                    if ((i + 1) < orderByConditionFields.length) {
10011                                            if (orderByComparator.isAscending() ^ previous) {
10012                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10013                                            }
10014                                            else {
10015                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10016                                            }
10017                                    }
10018                                    else {
10019                                            if (orderByComparator.isAscending() ^ previous) {
10020                                                    query.append(WHERE_GREATER_THAN);
10021                                            }
10022                                            else {
10023                                                    query.append(WHERE_LESSER_THAN);
10024                                            }
10025                                    }
10026                            }
10027    
10028                            query.append(ORDER_BY_CLAUSE);
10029    
10030                            String[] orderByFields = orderByComparator.getOrderByFields();
10031    
10032                            for (int i = 0; i < orderByFields.length; i++) {
10033                                    if (getDB().isSupportsInlineDistinct()) {
10034                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10035                                    }
10036                                    else {
10037                                            query.append(_ORDER_BY_ENTITY_TABLE);
10038                                    }
10039    
10040                                    query.append(orderByFields[i]);
10041    
10042                                    if ((i + 1) < orderByFields.length) {
10043                                            if (orderByComparator.isAscending() ^ previous) {
10044                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10045                                            }
10046                                            else {
10047                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10048                                            }
10049                                    }
10050                                    else {
10051                                            if (orderByComparator.isAscending() ^ previous) {
10052                                                    query.append(ORDER_BY_ASC);
10053                                            }
10054                                            else {
10055                                                    query.append(ORDER_BY_DESC);
10056                                            }
10057                                    }
10058                            }
10059                    }
10060    
10061                    else {
10062                            if (getDB().isSupportsInlineDistinct()) {
10063                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10064                            }
10065                            else {
10066                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10067                            }
10068                    }
10069    
10070                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10071                                    BlogsEntry.class.getName(),
10072                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10073    
10074                    SQLQuery q = session.createSQLQuery(sql);
10075    
10076                    q.setFirstResult(0);
10077                    q.setMaxResults(2);
10078    
10079                    if (getDB().isSupportsInlineDistinct()) {
10080                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10081                    }
10082                    else {
10083                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10084                    }
10085    
10086                    QueryPos qPos = QueryPos.getInstance(q);
10087    
10088                    qPos.add(groupId);
10089    
10090                    qPos.add(userId);
10091    
10092                    if (displayDate != null) {
10093                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10094                    }
10095    
10096                    qPos.add(status);
10097    
10098                    if (orderByComparator != null) {
10099                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10100    
10101                            for (Object value : values) {
10102                                    qPos.add(value);
10103                            }
10104                    }
10105    
10106                    List<BlogsEntry> list = q.list();
10107    
10108                    if (list.size() == 2) {
10109                            return list.get(1);
10110                    }
10111                    else {
10112                            return null;
10113                    }
10114            }
10115    
10116            /**
10117             * Returns all the blogs entries.
10118             *
10119             * @return the blogs entries
10120             * @throws SystemException if a system exception occurred
10121             */
10122            public List<BlogsEntry> findAll() throws SystemException {
10123                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10124            }
10125    
10126            /**
10127             * Returns a range of all the blogs entries.
10128             *
10129             * <p>
10130             * 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.
10131             * </p>
10132             *
10133             * @param start the lower bound of the range of blogs entries
10134             * @param end the upper bound of the range of blogs entries (not inclusive)
10135             * @return the range of blogs entries
10136             * @throws SystemException if a system exception occurred
10137             */
10138            public List<BlogsEntry> findAll(int start, int end)
10139                    throws SystemException {
10140                    return findAll(start, end, null);
10141            }
10142    
10143            /**
10144             * Returns an ordered range of all the blogs entries.
10145             *
10146             * <p>
10147             * 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.
10148             * </p>
10149             *
10150             * @param start the lower bound of the range of blogs entries
10151             * @param end the upper bound of the range of blogs entries (not inclusive)
10152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10153             * @return the ordered range of blogs entries
10154             * @throws SystemException if a system exception occurred
10155             */
10156            public List<BlogsEntry> findAll(int start, int end,
10157                    OrderByComparator orderByComparator) throws SystemException {
10158                    FinderPath finderPath = null;
10159                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
10160    
10161                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10162                                    (orderByComparator == null)) {
10163                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
10164                            finderArgs = FINDER_ARGS_EMPTY;
10165                    }
10166                    else {
10167                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
10168                            finderArgs = new Object[] { start, end, orderByComparator };
10169                    }
10170    
10171                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10172                                    finderArgs, this);
10173    
10174                    if (list == null) {
10175                            StringBundler query = null;
10176                            String sql = null;
10177    
10178                            if (orderByComparator != null) {
10179                                    query = new StringBundler(2 +
10180                                                    (orderByComparator.getOrderByFields().length * 3));
10181    
10182                                    query.append(_SQL_SELECT_BLOGSENTRY);
10183    
10184                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10185                                            orderByComparator);
10186    
10187                                    sql = query.toString();
10188                            }
10189                            else {
10190                                    sql = _SQL_SELECT_BLOGSENTRY.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
10191                            }
10192    
10193                            Session session = null;
10194    
10195                            try {
10196                                    session = openSession();
10197    
10198                                    Query q = session.createQuery(sql);
10199    
10200                                    if (orderByComparator == null) {
10201                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10202                                                            start, end, false);
10203    
10204                                            Collections.sort(list);
10205                                    }
10206                                    else {
10207                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10208                                                            start, end);
10209                                    }
10210                            }
10211                            catch (Exception e) {
10212                                    throw processException(e);
10213                            }
10214                            finally {
10215                                    if (list == null) {
10216                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10217                                    }
10218                                    else {
10219                                            cacheResult(list);
10220    
10221                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10222                                    }
10223    
10224                                    closeSession(session);
10225                            }
10226                    }
10227    
10228                    return list;
10229            }
10230    
10231            /**
10232             * Removes all the blogs entries where uuid = &#63; from the database.
10233             *
10234             * @param uuid the uuid
10235             * @throws SystemException if a system exception occurred
10236             */
10237            public void removeByUuid(String uuid) throws SystemException {
10238                    for (BlogsEntry blogsEntry : findByUuid(uuid)) {
10239                            remove(blogsEntry);
10240                    }
10241            }
10242    
10243            /**
10244             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
10245             *
10246             * @param uuid the uuid
10247             * @param groupId the group ID
10248             * @return the blogs entry that was removed
10249             * @throws SystemException if a system exception occurred
10250             */
10251            public BlogsEntry removeByUUID_G(String uuid, long groupId)
10252                    throws NoSuchEntryException, SystemException {
10253                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
10254    
10255                    return remove(blogsEntry);
10256            }
10257    
10258            /**
10259             * Removes all the blogs entries where groupId = &#63; from the database.
10260             *
10261             * @param groupId the group ID
10262             * @throws SystemException if a system exception occurred
10263             */
10264            public void removeByGroupId(long groupId) throws SystemException {
10265                    for (BlogsEntry blogsEntry : findByGroupId(groupId)) {
10266                            remove(blogsEntry);
10267                    }
10268            }
10269    
10270            /**
10271             * Removes all the blogs entries where companyId = &#63; from the database.
10272             *
10273             * @param companyId the company ID
10274             * @throws SystemException if a system exception occurred
10275             */
10276            public void removeByCompanyId(long companyId) throws SystemException {
10277                    for (BlogsEntry blogsEntry : findByCompanyId(companyId)) {
10278                            remove(blogsEntry);
10279                    }
10280            }
10281    
10282            /**
10283             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
10284             *
10285             * @param companyId the company ID
10286             * @param userId the user ID
10287             * @throws SystemException if a system exception occurred
10288             */
10289            public void removeByC_U(long companyId, long userId)
10290                    throws SystemException {
10291                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId)) {
10292                            remove(blogsEntry);
10293                    }
10294            }
10295    
10296            /**
10297             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
10298             *
10299             * @param companyId the company ID
10300             * @param displayDate the display date
10301             * @throws SystemException if a system exception occurred
10302             */
10303            public void removeByC_LtD(long companyId, Date displayDate)
10304                    throws SystemException {
10305                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate)) {
10306                            remove(blogsEntry);
10307                    }
10308            }
10309    
10310            /**
10311             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
10312             *
10313             * @param companyId the company ID
10314             * @param status the status
10315             * @throws SystemException if a system exception occurred
10316             */
10317            public void removeByC_S(long companyId, int status)
10318                    throws SystemException {
10319                    for (BlogsEntry blogsEntry : findByC_S(companyId, status)) {
10320                            remove(blogsEntry);
10321                    }
10322            }
10323    
10324            /**
10325             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
10326             *
10327             * @param groupId the group ID
10328             * @param urlTitle the url title
10329             * @return the blogs entry that was removed
10330             * @throws SystemException if a system exception occurred
10331             */
10332            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
10333                    throws NoSuchEntryException, SystemException {
10334                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
10335    
10336                    return remove(blogsEntry);
10337            }
10338    
10339            /**
10340             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
10341             *
10342             * @param groupId the group ID
10343             * @param displayDate the display date
10344             * @throws SystemException if a system exception occurred
10345             */
10346            public void removeByG_LtD(long groupId, Date displayDate)
10347                    throws SystemException {
10348                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate)) {
10349                            remove(blogsEntry);
10350                    }
10351            }
10352    
10353            /**
10354             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
10355             *
10356             * @param groupId the group ID
10357             * @param status the status
10358             * @throws SystemException if a system exception occurred
10359             */
10360            public void removeByG_S(long groupId, int status) throws SystemException {
10361                    for (BlogsEntry blogsEntry : findByG_S(groupId, status)) {
10362                            remove(blogsEntry);
10363                    }
10364            }
10365    
10366            /**
10367             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
10368             *
10369             * @param displayDate the display date
10370             * @param status the status
10371             * @throws SystemException if a system exception occurred
10372             */
10373            public void removeByLtD_S(Date displayDate, int status)
10374                    throws SystemException {
10375                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status)) {
10376                            remove(blogsEntry);
10377                    }
10378            }
10379    
10380            /**
10381             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
10382             *
10383             * @param companyId the company ID
10384             * @param userId the user ID
10385             * @param status the status
10386             * @throws SystemException if a system exception occurred
10387             */
10388            public void removeByC_U_S(long companyId, long userId, int status)
10389                    throws SystemException {
10390                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status)) {
10391                            remove(blogsEntry);
10392                    }
10393            }
10394    
10395            /**
10396             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10397             *
10398             * @param companyId the company ID
10399             * @param displayDate the display date
10400             * @param status the status
10401             * @throws SystemException if a system exception occurred
10402             */
10403            public void removeByC_LtD_S(long companyId, Date displayDate, int status)
10404                    throws SystemException {
10405                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
10406                                    status)) {
10407                            remove(blogsEntry);
10408                    }
10409            }
10410    
10411            /**
10412             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
10413             *
10414             * @param groupId the group ID
10415             * @param userId the user ID
10416             * @param displayDate the display date
10417             * @throws SystemException if a system exception occurred
10418             */
10419            public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
10420                    throws SystemException {
10421                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId, displayDate)) {
10422                            remove(blogsEntry);
10423                    }
10424            }
10425    
10426            /**
10427             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10428             *
10429             * @param groupId the group ID
10430             * @param userId the user ID
10431             * @param status the status
10432             * @throws SystemException if a system exception occurred
10433             */
10434            public void removeByG_U_S(long groupId, long userId, int status)
10435                    throws SystemException {
10436                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status)) {
10437                            remove(blogsEntry);
10438                    }
10439            }
10440    
10441            /**
10442             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10443             *
10444             * @param groupId the group ID
10445             * @param displayDate the display date
10446             * @param status the status
10447             * @throws SystemException if a system exception occurred
10448             */
10449            public void removeByG_LtD_S(long groupId, Date displayDate, int status)
10450                    throws SystemException {
10451                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate, status)) {
10452                            remove(blogsEntry);
10453                    }
10454            }
10455    
10456            /**
10457             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10458             *
10459             * @param groupId the group ID
10460             * @param userId the user ID
10461             * @param displayDate the display date
10462             * @param status the status
10463             * @throws SystemException if a system exception occurred
10464             */
10465            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
10466                    int status) throws SystemException {
10467                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
10468                                    displayDate, status)) {
10469                            remove(blogsEntry);
10470                    }
10471            }
10472    
10473            /**
10474             * Removes all the blogs entries from the database.
10475             *
10476             * @throws SystemException if a system exception occurred
10477             */
10478            public void removeAll() throws SystemException {
10479                    for (BlogsEntry blogsEntry : findAll()) {
10480                            remove(blogsEntry);
10481                    }
10482            }
10483    
10484            /**
10485             * Returns the number of blogs entries where uuid = &#63;.
10486             *
10487             * @param uuid the uuid
10488             * @return the number of matching blogs entries
10489             * @throws SystemException if a system exception occurred
10490             */
10491            public int countByUuid(String uuid) throws SystemException {
10492                    Object[] finderArgs = new Object[] { uuid };
10493    
10494                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
10495                                    finderArgs, this);
10496    
10497                    if (count == null) {
10498                            StringBundler query = new StringBundler(2);
10499    
10500                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10501    
10502                            if (uuid == null) {
10503                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
10504                            }
10505                            else {
10506                                    if (uuid.equals(StringPool.BLANK)) {
10507                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
10508                                    }
10509                                    else {
10510                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
10511                                    }
10512                            }
10513    
10514                            String sql = query.toString();
10515    
10516                            Session session = null;
10517    
10518                            try {
10519                                    session = openSession();
10520    
10521                                    Query q = session.createQuery(sql);
10522    
10523                                    QueryPos qPos = QueryPos.getInstance(q);
10524    
10525                                    if (uuid != null) {
10526                                            qPos.add(uuid);
10527                                    }
10528    
10529                                    count = (Long)q.uniqueResult();
10530                            }
10531                            catch (Exception e) {
10532                                    throw processException(e);
10533                            }
10534                            finally {
10535                                    if (count == null) {
10536                                            count = Long.valueOf(0);
10537                                    }
10538    
10539                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
10540                                            finderArgs, count);
10541    
10542                                    closeSession(session);
10543                            }
10544                    }
10545    
10546                    return count.intValue();
10547            }
10548    
10549            /**
10550             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
10551             *
10552             * @param uuid the uuid
10553             * @param groupId the group ID
10554             * @return the number of matching blogs entries
10555             * @throws SystemException if a system exception occurred
10556             */
10557            public int countByUUID_G(String uuid, long groupId)
10558                    throws SystemException {
10559                    Object[] finderArgs = new Object[] { uuid, groupId };
10560    
10561                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
10562                                    finderArgs, this);
10563    
10564                    if (count == null) {
10565                            StringBundler query = new StringBundler(3);
10566    
10567                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10568    
10569                            if (uuid == null) {
10570                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
10571                            }
10572                            else {
10573                                    if (uuid.equals(StringPool.BLANK)) {
10574                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
10575                                    }
10576                                    else {
10577                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
10578                                    }
10579                            }
10580    
10581                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
10582    
10583                            String sql = query.toString();
10584    
10585                            Session session = null;
10586    
10587                            try {
10588                                    session = openSession();
10589    
10590                                    Query q = session.createQuery(sql);
10591    
10592                                    QueryPos qPos = QueryPos.getInstance(q);
10593    
10594                                    if (uuid != null) {
10595                                            qPos.add(uuid);
10596                                    }
10597    
10598                                    qPos.add(groupId);
10599    
10600                                    count = (Long)q.uniqueResult();
10601                            }
10602                            catch (Exception e) {
10603                                    throw processException(e);
10604                            }
10605                            finally {
10606                                    if (count == null) {
10607                                            count = Long.valueOf(0);
10608                                    }
10609    
10610                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
10611                                            finderArgs, count);
10612    
10613                                    closeSession(session);
10614                            }
10615                    }
10616    
10617                    return count.intValue();
10618            }
10619    
10620            /**
10621             * Returns the number of blogs entries where groupId = &#63;.
10622             *
10623             * @param groupId the group ID
10624             * @return the number of matching blogs entries
10625             * @throws SystemException if a system exception occurred
10626             */
10627            public int countByGroupId(long groupId) throws SystemException {
10628                    Object[] finderArgs = new Object[] { groupId };
10629    
10630                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
10631                                    finderArgs, this);
10632    
10633                    if (count == null) {
10634                            StringBundler query = new StringBundler(2);
10635    
10636                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10637    
10638                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
10639    
10640                            String sql = query.toString();
10641    
10642                            Session session = null;
10643    
10644                            try {
10645                                    session = openSession();
10646    
10647                                    Query q = session.createQuery(sql);
10648    
10649                                    QueryPos qPos = QueryPos.getInstance(q);
10650    
10651                                    qPos.add(groupId);
10652    
10653                                    count = (Long)q.uniqueResult();
10654                            }
10655                            catch (Exception e) {
10656                                    throw processException(e);
10657                            }
10658                            finally {
10659                                    if (count == null) {
10660                                            count = Long.valueOf(0);
10661                                    }
10662    
10663                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
10664                                            finderArgs, count);
10665    
10666                                    closeSession(session);
10667                            }
10668                    }
10669    
10670                    return count.intValue();
10671            }
10672    
10673            /**
10674             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
10675             *
10676             * @param groupId the group ID
10677             * @return the number of matching blogs entries that the user has permission to view
10678             * @throws SystemException if a system exception occurred
10679             */
10680            public int filterCountByGroupId(long groupId) throws SystemException {
10681                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10682                            return countByGroupId(groupId);
10683                    }
10684    
10685                    StringBundler query = new StringBundler(2);
10686    
10687                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10688    
10689                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
10690    
10691                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10692                                    BlogsEntry.class.getName(),
10693                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10694    
10695                    Session session = null;
10696    
10697                    try {
10698                            session = openSession();
10699    
10700                            SQLQuery q = session.createSQLQuery(sql);
10701    
10702                            q.addScalar(COUNT_COLUMN_NAME,
10703                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10704    
10705                            QueryPos qPos = QueryPos.getInstance(q);
10706    
10707                            qPos.add(groupId);
10708    
10709                            Long count = (Long)q.uniqueResult();
10710    
10711                            return count.intValue();
10712                    }
10713                    catch (Exception e) {
10714                            throw processException(e);
10715                    }
10716                    finally {
10717                            closeSession(session);
10718                    }
10719            }
10720    
10721            /**
10722             * Returns the number of blogs entries where companyId = &#63;.
10723             *
10724             * @param companyId the company ID
10725             * @return the number of matching blogs entries
10726             * @throws SystemException if a system exception occurred
10727             */
10728            public int countByCompanyId(long companyId) throws SystemException {
10729                    Object[] finderArgs = new Object[] { companyId };
10730    
10731                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
10732                                    finderArgs, this);
10733    
10734                    if (count == null) {
10735                            StringBundler query = new StringBundler(2);
10736    
10737                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10738    
10739                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
10740    
10741                            String sql = query.toString();
10742    
10743                            Session session = null;
10744    
10745                            try {
10746                                    session = openSession();
10747    
10748                                    Query q = session.createQuery(sql);
10749    
10750                                    QueryPos qPos = QueryPos.getInstance(q);
10751    
10752                                    qPos.add(companyId);
10753    
10754                                    count = (Long)q.uniqueResult();
10755                            }
10756                            catch (Exception e) {
10757                                    throw processException(e);
10758                            }
10759                            finally {
10760                                    if (count == null) {
10761                                            count = Long.valueOf(0);
10762                                    }
10763    
10764                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
10765                                            finderArgs, count);
10766    
10767                                    closeSession(session);
10768                            }
10769                    }
10770    
10771                    return count.intValue();
10772            }
10773    
10774            /**
10775             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
10776             *
10777             * @param companyId the company ID
10778             * @param userId the user ID
10779             * @return the number of matching blogs entries
10780             * @throws SystemException if a system exception occurred
10781             */
10782            public int countByC_U(long companyId, long userId)
10783                    throws SystemException {
10784                    Object[] finderArgs = new Object[] { companyId, userId };
10785    
10786                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
10787                                    finderArgs, this);
10788    
10789                    if (count == null) {
10790                            StringBundler query = new StringBundler(3);
10791    
10792                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10793    
10794                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
10795    
10796                            query.append(_FINDER_COLUMN_C_U_USERID_2);
10797    
10798                            String sql = query.toString();
10799    
10800                            Session session = null;
10801    
10802                            try {
10803                                    session = openSession();
10804    
10805                                    Query q = session.createQuery(sql);
10806    
10807                                    QueryPos qPos = QueryPos.getInstance(q);
10808    
10809                                    qPos.add(companyId);
10810    
10811                                    qPos.add(userId);
10812    
10813                                    count = (Long)q.uniqueResult();
10814                            }
10815                            catch (Exception e) {
10816                                    throw processException(e);
10817                            }
10818                            finally {
10819                                    if (count == null) {
10820                                            count = Long.valueOf(0);
10821                                    }
10822    
10823                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
10824                                            count);
10825    
10826                                    closeSession(session);
10827                            }
10828                    }
10829    
10830                    return count.intValue();
10831            }
10832    
10833            /**
10834             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
10835             *
10836             * @param companyId the company ID
10837             * @param displayDate the display date
10838             * @return the number of matching blogs entries
10839             * @throws SystemException if a system exception occurred
10840             */
10841            public int countByC_LtD(long companyId, Date displayDate)
10842                    throws SystemException {
10843                    Object[] finderArgs = new Object[] { companyId, displayDate };
10844    
10845                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD,
10846                                    finderArgs, this);
10847    
10848                    if (count == null) {
10849                            StringBundler query = new StringBundler(3);
10850    
10851                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10852    
10853                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
10854    
10855                            if (displayDate == null) {
10856                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
10857                            }
10858                            else {
10859                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
10860                            }
10861    
10862                            String sql = query.toString();
10863    
10864                            Session session = null;
10865    
10866                            try {
10867                                    session = openSession();
10868    
10869                                    Query q = session.createQuery(sql);
10870    
10871                                    QueryPos qPos = QueryPos.getInstance(q);
10872    
10873                                    qPos.add(companyId);
10874    
10875                                    if (displayDate != null) {
10876                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10877                                    }
10878    
10879                                    count = (Long)q.uniqueResult();
10880                            }
10881                            catch (Exception e) {
10882                                    throw processException(e);
10883                            }
10884                            finally {
10885                                    if (count == null) {
10886                                            count = Long.valueOf(0);
10887                                    }
10888    
10889                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD,
10890                                            finderArgs, count);
10891    
10892                                    closeSession(session);
10893                            }
10894                    }
10895    
10896                    return count.intValue();
10897            }
10898    
10899            /**
10900             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
10901             *
10902             * @param companyId the company ID
10903             * @param status the status
10904             * @return the number of matching blogs entries
10905             * @throws SystemException if a system exception occurred
10906             */
10907            public int countByC_S(long companyId, int status) throws SystemException {
10908                    Object[] finderArgs = new Object[] { companyId, status };
10909    
10910                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
10911                                    finderArgs, this);
10912    
10913                    if (count == null) {
10914                            StringBundler query = new StringBundler(3);
10915    
10916                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10917    
10918                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
10919    
10920                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
10921    
10922                            String sql = query.toString();
10923    
10924                            Session session = null;
10925    
10926                            try {
10927                                    session = openSession();
10928    
10929                                    Query q = session.createQuery(sql);
10930    
10931                                    QueryPos qPos = QueryPos.getInstance(q);
10932    
10933                                    qPos.add(companyId);
10934    
10935                                    qPos.add(status);
10936    
10937                                    count = (Long)q.uniqueResult();
10938                            }
10939                            catch (Exception e) {
10940                                    throw processException(e);
10941                            }
10942                            finally {
10943                                    if (count == null) {
10944                                            count = Long.valueOf(0);
10945                                    }
10946    
10947                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
10948                                            count);
10949    
10950                                    closeSession(session);
10951                            }
10952                    }
10953    
10954                    return count.intValue();
10955            }
10956    
10957            /**
10958             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
10959             *
10960             * @param groupId the group ID
10961             * @param urlTitle the url title
10962             * @return the number of matching blogs entries
10963             * @throws SystemException if a system exception occurred
10964             */
10965            public int countByG_UT(long groupId, String urlTitle)
10966                    throws SystemException {
10967                    Object[] finderArgs = new Object[] { groupId, urlTitle };
10968    
10969                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
10970                                    finderArgs, this);
10971    
10972                    if (count == null) {
10973                            StringBundler query = new StringBundler(3);
10974    
10975                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10976    
10977                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10978    
10979                            if (urlTitle == null) {
10980                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10981                            }
10982                            else {
10983                                    if (urlTitle.equals(StringPool.BLANK)) {
10984                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10985                                    }
10986                                    else {
10987                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10988                                    }
10989                            }
10990    
10991                            String sql = query.toString();
10992    
10993                            Session session = null;
10994    
10995                            try {
10996                                    session = openSession();
10997    
10998                                    Query q = session.createQuery(sql);
10999    
11000                                    QueryPos qPos = QueryPos.getInstance(q);
11001    
11002                                    qPos.add(groupId);
11003    
11004                                    if (urlTitle != null) {
11005                                            qPos.add(urlTitle);
11006                                    }
11007    
11008                                    count = (Long)q.uniqueResult();
11009                            }
11010                            catch (Exception e) {
11011                                    throw processException(e);
11012                            }
11013                            finally {
11014                                    if (count == null) {
11015                                            count = Long.valueOf(0);
11016                                    }
11017    
11018                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
11019                                            finderArgs, count);
11020    
11021                                    closeSession(session);
11022                            }
11023                    }
11024    
11025                    return count.intValue();
11026            }
11027    
11028            /**
11029             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
11030             *
11031             * @param groupId the group ID
11032             * @param displayDate the display date
11033             * @return the number of matching blogs entries
11034             * @throws SystemException if a system exception occurred
11035             */
11036            public int countByG_LtD(long groupId, Date displayDate)
11037                    throws SystemException {
11038                    Object[] finderArgs = new Object[] { groupId, displayDate };
11039    
11040                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD,
11041                                    finderArgs, this);
11042    
11043                    if (count == null) {
11044                            StringBundler query = new StringBundler(3);
11045    
11046                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11047    
11048                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
11049    
11050                            if (displayDate == null) {
11051                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
11052                            }
11053                            else {
11054                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
11055                            }
11056    
11057                            String sql = query.toString();
11058    
11059                            Session session = null;
11060    
11061                            try {
11062                                    session = openSession();
11063    
11064                                    Query q = session.createQuery(sql);
11065    
11066                                    QueryPos qPos = QueryPos.getInstance(q);
11067    
11068                                    qPos.add(groupId);
11069    
11070                                    if (displayDate != null) {
11071                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11072                                    }
11073    
11074                                    count = (Long)q.uniqueResult();
11075                            }
11076                            catch (Exception e) {
11077                                    throw processException(e);
11078                            }
11079                            finally {
11080                                    if (count == null) {
11081                                            count = Long.valueOf(0);
11082                                    }
11083    
11084                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD,
11085                                            finderArgs, count);
11086    
11087                                    closeSession(session);
11088                            }
11089                    }
11090    
11091                    return count.intValue();
11092            }
11093    
11094            /**
11095             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
11096             *
11097             * @param groupId the group ID
11098             * @param displayDate the display date
11099             * @return the number of matching blogs entries that the user has permission to view
11100             * @throws SystemException if a system exception occurred
11101             */
11102            public int filterCountByG_LtD(long groupId, Date displayDate)
11103                    throws SystemException {
11104                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11105                            return countByG_LtD(groupId, displayDate);
11106                    }
11107    
11108                    StringBundler query = new StringBundler(3);
11109    
11110                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11111    
11112                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
11113    
11114                    if (displayDate == null) {
11115                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
11116                    }
11117                    else {
11118                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
11119                    }
11120    
11121                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11122                                    BlogsEntry.class.getName(),
11123                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11124    
11125                    Session session = null;
11126    
11127                    try {
11128                            session = openSession();
11129    
11130                            SQLQuery q = session.createSQLQuery(sql);
11131    
11132                            q.addScalar(COUNT_COLUMN_NAME,
11133                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11134    
11135                            QueryPos qPos = QueryPos.getInstance(q);
11136    
11137                            qPos.add(groupId);
11138    
11139                            if (displayDate != null) {
11140                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11141                            }
11142    
11143                            Long count = (Long)q.uniqueResult();
11144    
11145                            return count.intValue();
11146                    }
11147                    catch (Exception e) {
11148                            throw processException(e);
11149                    }
11150                    finally {
11151                            closeSession(session);
11152                    }
11153            }
11154    
11155            /**
11156             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
11157             *
11158             * @param groupId the group ID
11159             * @param status the status
11160             * @return the number of matching blogs entries
11161             * @throws SystemException if a system exception occurred
11162             */
11163            public int countByG_S(long groupId, int status) throws SystemException {
11164                    Object[] finderArgs = new Object[] { groupId, status };
11165    
11166                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
11167                                    finderArgs, this);
11168    
11169                    if (count == null) {
11170                            StringBundler query = new StringBundler(3);
11171    
11172                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11173    
11174                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11175    
11176                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
11177    
11178                            String sql = query.toString();
11179    
11180                            Session session = null;
11181    
11182                            try {
11183                                    session = openSession();
11184    
11185                                    Query q = session.createQuery(sql);
11186    
11187                                    QueryPos qPos = QueryPos.getInstance(q);
11188    
11189                                    qPos.add(groupId);
11190    
11191                                    qPos.add(status);
11192    
11193                                    count = (Long)q.uniqueResult();
11194                            }
11195                            catch (Exception e) {
11196                                    throw processException(e);
11197                            }
11198                            finally {
11199                                    if (count == null) {
11200                                            count = Long.valueOf(0);
11201                                    }
11202    
11203                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
11204                                            count);
11205    
11206                                    closeSession(session);
11207                            }
11208                    }
11209    
11210                    return count.intValue();
11211            }
11212    
11213            /**
11214             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
11215             *
11216             * @param groupId the group ID
11217             * @param status the status
11218             * @return the number of matching blogs entries that the user has permission to view
11219             * @throws SystemException if a system exception occurred
11220             */
11221            public int filterCountByG_S(long groupId, int status)
11222                    throws SystemException {
11223                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11224                            return countByG_S(groupId, status);
11225                    }
11226    
11227                    StringBundler query = new StringBundler(3);
11228    
11229                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11230    
11231                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11232    
11233                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
11234    
11235                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11236                                    BlogsEntry.class.getName(),
11237                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11238    
11239                    Session session = null;
11240    
11241                    try {
11242                            session = openSession();
11243    
11244                            SQLQuery q = session.createSQLQuery(sql);
11245    
11246                            q.addScalar(COUNT_COLUMN_NAME,
11247                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11248    
11249                            QueryPos qPos = QueryPos.getInstance(q);
11250    
11251                            qPos.add(groupId);
11252    
11253                            qPos.add(status);
11254    
11255                            Long count = (Long)q.uniqueResult();
11256    
11257                            return count.intValue();
11258                    }
11259                    catch (Exception e) {
11260                            throw processException(e);
11261                    }
11262                    finally {
11263                            closeSession(session);
11264                    }
11265            }
11266    
11267            /**
11268             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
11269             *
11270             * @param displayDate the display date
11271             * @param status the status
11272             * @return the number of matching blogs entries
11273             * @throws SystemException if a system exception occurred
11274             */
11275            public int countByLtD_S(Date displayDate, int status)
11276                    throws SystemException {
11277                    Object[] finderArgs = new Object[] { displayDate, status };
11278    
11279                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S,
11280                                    finderArgs, this);
11281    
11282                    if (count == null) {
11283                            StringBundler query = new StringBundler(3);
11284    
11285                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11286    
11287                            if (displayDate == null) {
11288                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
11289                            }
11290                            else {
11291                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
11292                            }
11293    
11294                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
11295    
11296                            String sql = query.toString();
11297    
11298                            Session session = null;
11299    
11300                            try {
11301                                    session = openSession();
11302    
11303                                    Query q = session.createQuery(sql);
11304    
11305                                    QueryPos qPos = QueryPos.getInstance(q);
11306    
11307                                    if (displayDate != null) {
11308                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11309                                    }
11310    
11311                                    qPos.add(status);
11312    
11313                                    count = (Long)q.uniqueResult();
11314                            }
11315                            catch (Exception e) {
11316                                    throw processException(e);
11317                            }
11318                            finally {
11319                                    if (count == null) {
11320                                            count = Long.valueOf(0);
11321                                    }
11322    
11323                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S,
11324                                            finderArgs, count);
11325    
11326                                    closeSession(session);
11327                            }
11328                    }
11329    
11330                    return count.intValue();
11331            }
11332    
11333            /**
11334             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
11335             *
11336             * @param companyId the company ID
11337             * @param userId the user ID
11338             * @param status the status
11339             * @return the number of matching blogs entries
11340             * @throws SystemException if a system exception occurred
11341             */
11342            public int countByC_U_S(long companyId, long userId, int status)
11343                    throws SystemException {
11344                    Object[] finderArgs = new Object[] { companyId, userId, status };
11345    
11346                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_S,
11347                                    finderArgs, this);
11348    
11349                    if (count == null) {
11350                            StringBundler query = new StringBundler(4);
11351    
11352                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11353    
11354                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
11355    
11356                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
11357    
11358                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
11359    
11360                            String sql = query.toString();
11361    
11362                            Session session = null;
11363    
11364                            try {
11365                                    session = openSession();
11366    
11367                                    Query q = session.createQuery(sql);
11368    
11369                                    QueryPos qPos = QueryPos.getInstance(q);
11370    
11371                                    qPos.add(companyId);
11372    
11373                                    qPos.add(userId);
11374    
11375                                    qPos.add(status);
11376    
11377                                    count = (Long)q.uniqueResult();
11378                            }
11379                            catch (Exception e) {
11380                                    throw processException(e);
11381                            }
11382                            finally {
11383                                    if (count == null) {
11384                                            count = Long.valueOf(0);
11385                                    }
11386    
11387                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_S,
11388                                            finderArgs, count);
11389    
11390                                    closeSession(session);
11391                            }
11392                    }
11393    
11394                    return count.intValue();
11395            }
11396    
11397            /**
11398             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
11399             *
11400             * @param companyId the company ID
11401             * @param displayDate the display date
11402             * @param status the status
11403             * @return the number of matching blogs entries
11404             * @throws SystemException if a system exception occurred
11405             */
11406            public int countByC_LtD_S(long companyId, Date displayDate, int status)
11407                    throws SystemException {
11408                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
11409    
11410                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S,
11411                                    finderArgs, this);
11412    
11413                    if (count == null) {
11414                            StringBundler query = new StringBundler(4);
11415    
11416                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11417    
11418                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
11419    
11420                            if (displayDate == null) {
11421                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
11422                            }
11423                            else {
11424                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
11425                            }
11426    
11427                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
11428    
11429                            String sql = query.toString();
11430    
11431                            Session session = null;
11432    
11433                            try {
11434                                    session = openSession();
11435    
11436                                    Query q = session.createQuery(sql);
11437    
11438                                    QueryPos qPos = QueryPos.getInstance(q);
11439    
11440                                    qPos.add(companyId);
11441    
11442                                    if (displayDate != null) {
11443                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11444                                    }
11445    
11446                                    qPos.add(status);
11447    
11448                                    count = (Long)q.uniqueResult();
11449                            }
11450                            catch (Exception e) {
11451                                    throw processException(e);
11452                            }
11453                            finally {
11454                                    if (count == null) {
11455                                            count = Long.valueOf(0);
11456                                    }
11457    
11458                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S,
11459                                            finderArgs, count);
11460    
11461                                    closeSession(session);
11462                            }
11463                    }
11464    
11465                    return count.intValue();
11466            }
11467    
11468            /**
11469             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11470             *
11471             * @param groupId the group ID
11472             * @param userId the user ID
11473             * @param displayDate the display date
11474             * @return the number of matching blogs entries
11475             * @throws SystemException if a system exception occurred
11476             */
11477            public int countByG_U_LtD(long groupId, long userId, Date displayDate)
11478                    throws SystemException {
11479                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
11480    
11481                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD,
11482                                    finderArgs, this);
11483    
11484                    if (count == null) {
11485                            StringBundler query = new StringBundler(4);
11486    
11487                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11488    
11489                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11490    
11491                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11492    
11493                            if (displayDate == null) {
11494                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11495                            }
11496                            else {
11497                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11498                            }
11499    
11500                            String sql = query.toString();
11501    
11502                            Session session = null;
11503    
11504                            try {
11505                                    session = openSession();
11506    
11507                                    Query q = session.createQuery(sql);
11508    
11509                                    QueryPos qPos = QueryPos.getInstance(q);
11510    
11511                                    qPos.add(groupId);
11512    
11513                                    qPos.add(userId);
11514    
11515                                    if (displayDate != null) {
11516                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11517                                    }
11518    
11519                                    count = (Long)q.uniqueResult();
11520                            }
11521                            catch (Exception e) {
11522                                    throw processException(e);
11523                            }
11524                            finally {
11525                                    if (count == null) {
11526                                            count = Long.valueOf(0);
11527                                    }
11528    
11529                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD,
11530                                            finderArgs, count);
11531    
11532                                    closeSession(session);
11533                            }
11534                    }
11535    
11536                    return count.intValue();
11537            }
11538    
11539            /**
11540             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11541             *
11542             * @param groupId the group ID
11543             * @param userId the user ID
11544             * @param displayDate the display date
11545             * @return the number of matching blogs entries that the user has permission to view
11546             * @throws SystemException if a system exception occurred
11547             */
11548            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
11549                    throws SystemException {
11550                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11551                            return countByG_U_LtD(groupId, userId, displayDate);
11552                    }
11553    
11554                    StringBundler query = new StringBundler(4);
11555    
11556                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11557    
11558                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11559    
11560                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11561    
11562                    if (displayDate == null) {
11563                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11564                    }
11565                    else {
11566                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11567                    }
11568    
11569                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11570                                    BlogsEntry.class.getName(),
11571                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11572    
11573                    Session session = null;
11574    
11575                    try {
11576                            session = openSession();
11577    
11578                            SQLQuery q = session.createSQLQuery(sql);
11579    
11580                            q.addScalar(COUNT_COLUMN_NAME,
11581                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11582    
11583                            QueryPos qPos = QueryPos.getInstance(q);
11584    
11585                            qPos.add(groupId);
11586    
11587                            qPos.add(userId);
11588    
11589                            if (displayDate != null) {
11590                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11591                            }
11592    
11593                            Long count = (Long)q.uniqueResult();
11594    
11595                            return count.intValue();
11596                    }
11597                    catch (Exception e) {
11598                            throw processException(e);
11599                    }
11600                    finally {
11601                            closeSession(session);
11602                    }
11603            }
11604    
11605            /**
11606             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
11607             *
11608             * @param groupId the group ID
11609             * @param userId the user ID
11610             * @param status the status
11611             * @return the number of matching blogs entries
11612             * @throws SystemException if a system exception occurred
11613             */
11614            public int countByG_U_S(long groupId, long userId, int status)
11615                    throws SystemException {
11616                    Object[] finderArgs = new Object[] { groupId, userId, status };
11617    
11618                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_S,
11619                                    finderArgs, this);
11620    
11621                    if (count == null) {
11622                            StringBundler query = new StringBundler(4);
11623    
11624                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11625    
11626                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11627    
11628                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11629    
11630                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11631    
11632                            String sql = query.toString();
11633    
11634                            Session session = null;
11635    
11636                            try {
11637                                    session = openSession();
11638    
11639                                    Query q = session.createQuery(sql);
11640    
11641                                    QueryPos qPos = QueryPos.getInstance(q);
11642    
11643                                    qPos.add(groupId);
11644    
11645                                    qPos.add(userId);
11646    
11647                                    qPos.add(status);
11648    
11649                                    count = (Long)q.uniqueResult();
11650                            }
11651                            catch (Exception e) {
11652                                    throw processException(e);
11653                            }
11654                            finally {
11655                                    if (count == null) {
11656                                            count = Long.valueOf(0);
11657                                    }
11658    
11659                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_S,
11660                                            finderArgs, count);
11661    
11662                                    closeSession(session);
11663                            }
11664                    }
11665    
11666                    return count.intValue();
11667            }
11668    
11669            /**
11670             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11671             *
11672             * @param groupId the group ID
11673             * @param userId the user ID
11674             * @param status the status
11675             * @return the number of matching blogs entries that the user has permission to view
11676             * @throws SystemException if a system exception occurred
11677             */
11678            public int filterCountByG_U_S(long groupId, long userId, int status)
11679                    throws SystemException {
11680                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11681                            return countByG_U_S(groupId, userId, status);
11682                    }
11683    
11684                    StringBundler query = new StringBundler(4);
11685    
11686                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11687    
11688                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11689    
11690                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11691    
11692                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11693    
11694                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11695                                    BlogsEntry.class.getName(),
11696                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11697    
11698                    Session session = null;
11699    
11700                    try {
11701                            session = openSession();
11702    
11703                            SQLQuery q = session.createSQLQuery(sql);
11704    
11705                            q.addScalar(COUNT_COLUMN_NAME,
11706                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11707    
11708                            QueryPos qPos = QueryPos.getInstance(q);
11709    
11710                            qPos.add(groupId);
11711    
11712                            qPos.add(userId);
11713    
11714                            qPos.add(status);
11715    
11716                            Long count = (Long)q.uniqueResult();
11717    
11718                            return count.intValue();
11719                    }
11720                    catch (Exception e) {
11721                            throw processException(e);
11722                    }
11723                    finally {
11724                            closeSession(session);
11725                    }
11726            }
11727    
11728            /**
11729             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11730             *
11731             * @param groupId the group ID
11732             * @param displayDate the display date
11733             * @param status the status
11734             * @return the number of matching blogs entries
11735             * @throws SystemException if a system exception occurred
11736             */
11737            public int countByG_LtD_S(long groupId, Date displayDate, int status)
11738                    throws SystemException {
11739                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
11740    
11741                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S,
11742                                    finderArgs, this);
11743    
11744                    if (count == null) {
11745                            StringBundler query = new StringBundler(4);
11746    
11747                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11748    
11749                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11750    
11751                            if (displayDate == null) {
11752                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11753                            }
11754                            else {
11755                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11756                            }
11757    
11758                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11759    
11760                            String sql = query.toString();
11761    
11762                            Session session = null;
11763    
11764                            try {
11765                                    session = openSession();
11766    
11767                                    Query q = session.createQuery(sql);
11768    
11769                                    QueryPos qPos = QueryPos.getInstance(q);
11770    
11771                                    qPos.add(groupId);
11772    
11773                                    if (displayDate != null) {
11774                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11775                                    }
11776    
11777                                    qPos.add(status);
11778    
11779                                    count = (Long)q.uniqueResult();
11780                            }
11781                            catch (Exception e) {
11782                                    throw processException(e);
11783                            }
11784                            finally {
11785                                    if (count == null) {
11786                                            count = Long.valueOf(0);
11787                                    }
11788    
11789                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S,
11790                                            finderArgs, count);
11791    
11792                                    closeSession(session);
11793                            }
11794                    }
11795    
11796                    return count.intValue();
11797            }
11798    
11799            /**
11800             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11801             *
11802             * @param groupId the group ID
11803             * @param displayDate the display date
11804             * @param status the status
11805             * @return the number of matching blogs entries that the user has permission to view
11806             * @throws SystemException if a system exception occurred
11807             */
11808            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
11809                    throws SystemException {
11810                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11811                            return countByG_LtD_S(groupId, displayDate, status);
11812                    }
11813    
11814                    StringBundler query = new StringBundler(4);
11815    
11816                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11817    
11818                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11819    
11820                    if (displayDate == null) {
11821                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11822                    }
11823                    else {
11824                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11825                    }
11826    
11827                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11828    
11829                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11830                                    BlogsEntry.class.getName(),
11831                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11832    
11833                    Session session = null;
11834    
11835                    try {
11836                            session = openSession();
11837    
11838                            SQLQuery q = session.createSQLQuery(sql);
11839    
11840                            q.addScalar(COUNT_COLUMN_NAME,
11841                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11842    
11843                            QueryPos qPos = QueryPos.getInstance(q);
11844    
11845                            qPos.add(groupId);
11846    
11847                            if (displayDate != null) {
11848                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11849                            }
11850    
11851                            qPos.add(status);
11852    
11853                            Long count = (Long)q.uniqueResult();
11854    
11855                            return count.intValue();
11856                    }
11857                    catch (Exception e) {
11858                            throw processException(e);
11859                    }
11860                    finally {
11861                            closeSession(session);
11862                    }
11863            }
11864    
11865            /**
11866             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
11867             *
11868             * @param groupId the group ID
11869             * @param userId the user ID
11870             * @param displayDate the display date
11871             * @param status the status
11872             * @return the number of matching blogs entries
11873             * @throws SystemException if a system exception occurred
11874             */
11875            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
11876                    int status) throws SystemException {
11877                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
11878    
11879                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S,
11880                                    finderArgs, this);
11881    
11882                    if (count == null) {
11883                            StringBundler query = new StringBundler(5);
11884    
11885                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11886    
11887                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
11888    
11889                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
11890    
11891                            if (displayDate == null) {
11892                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
11893                            }
11894                            else {
11895                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
11896                            }
11897    
11898                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
11899    
11900                            String sql = query.toString();
11901    
11902                            Session session = null;
11903    
11904                            try {
11905                                    session = openSession();
11906    
11907                                    Query q = session.createQuery(sql);
11908    
11909                                    QueryPos qPos = QueryPos.getInstance(q);
11910    
11911                                    qPos.add(groupId);
11912    
11913                                    qPos.add(userId);
11914    
11915                                    if (displayDate != null) {
11916                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11917                                    }
11918    
11919                                    qPos.add(status);
11920    
11921                                    count = (Long)q.uniqueResult();
11922                            }
11923                            catch (Exception e) {
11924                                    throw processException(e);
11925                            }
11926                            finally {
11927                                    if (count == null) {
11928                                            count = Long.valueOf(0);
11929                                    }
11930    
11931                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S,
11932                                            finderArgs, count);
11933    
11934                                    closeSession(session);
11935                            }
11936                    }
11937    
11938                    return count.intValue();
11939            }
11940    
11941            /**
11942             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
11943             *
11944             * @param groupId the group ID
11945             * @param userId the user ID
11946             * @param displayDate the display date
11947             * @param status the status
11948             * @return the number of matching blogs entries that the user has permission to view
11949             * @throws SystemException if a system exception occurred
11950             */
11951            public int filterCountByG_U_LtD_S(long groupId, long userId,
11952                    Date displayDate, int status) throws SystemException {
11953                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11954                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
11955                    }
11956    
11957                    StringBundler query = new StringBundler(5);
11958    
11959                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11960    
11961                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
11962    
11963                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
11964    
11965                    if (displayDate == null) {
11966                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
11967                    }
11968                    else {
11969                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
11970                    }
11971    
11972                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
11973    
11974                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11975                                    BlogsEntry.class.getName(),
11976                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11977    
11978                    Session session = null;
11979    
11980                    try {
11981                            session = openSession();
11982    
11983                            SQLQuery q = session.createSQLQuery(sql);
11984    
11985                            q.addScalar(COUNT_COLUMN_NAME,
11986                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11987    
11988                            QueryPos qPos = QueryPos.getInstance(q);
11989    
11990                            qPos.add(groupId);
11991    
11992                            qPos.add(userId);
11993    
11994                            if (displayDate != null) {
11995                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11996                            }
11997    
11998                            qPos.add(status);
11999    
12000                            Long count = (Long)q.uniqueResult();
12001    
12002                            return count.intValue();
12003                    }
12004                    catch (Exception e) {
12005                            throw processException(e);
12006                    }
12007                    finally {
12008                            closeSession(session);
12009                    }
12010            }
12011    
12012            /**
12013             * Returns the number of blogs entries.
12014             *
12015             * @return the number of blogs entries
12016             * @throws SystemException if a system exception occurred
12017             */
12018            public int countAll() throws SystemException {
12019                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
12020                                    FINDER_ARGS_EMPTY, this);
12021    
12022                    if (count == null) {
12023                            Session session = null;
12024    
12025                            try {
12026                                    session = openSession();
12027    
12028                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
12029    
12030                                    count = (Long)q.uniqueResult();
12031                            }
12032                            catch (Exception e) {
12033                                    throw processException(e);
12034                            }
12035                            finally {
12036                                    if (count == null) {
12037                                            count = Long.valueOf(0);
12038                                    }
12039    
12040                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
12041                                            FINDER_ARGS_EMPTY, count);
12042    
12043                                    closeSession(session);
12044                            }
12045                    }
12046    
12047                    return count.intValue();
12048            }
12049    
12050            /**
12051             * Initializes the blogs entry persistence.
12052             */
12053            public void afterPropertiesSet() {
12054                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
12055                                            com.liferay.portal.util.PropsUtil.get(
12056                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
12057    
12058                    if (listenerClassNames.length > 0) {
12059                            try {
12060                                    List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
12061    
12062                                    for (String listenerClassName : listenerClassNames) {
12063                                            Class<?> clazz = getClass();
12064    
12065                                            listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
12066                                                            clazz.getClassLoader(), listenerClassName));
12067                                    }
12068    
12069                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
12070                            }
12071                            catch (Exception e) {
12072                                    _log.error(e);
12073                            }
12074                    }
12075            }
12076    
12077            public void destroy() {
12078                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
12079                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12080                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12081            }
12082    
12083            @BeanReference(type = BlogsEntryPersistence.class)
12084            protected BlogsEntryPersistence blogsEntryPersistence;
12085            @BeanReference(type = BlogsStatsUserPersistence.class)
12086            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
12087            @BeanReference(type = CompanyPersistence.class)
12088            protected CompanyPersistence companyPersistence;
12089            @BeanReference(type = GroupPersistence.class)
12090            protected GroupPersistence groupPersistence;
12091            @BeanReference(type = ImagePersistence.class)
12092            protected ImagePersistence imagePersistence;
12093            @BeanReference(type = OrganizationPersistence.class)
12094            protected OrganizationPersistence organizationPersistence;
12095            @BeanReference(type = PortletPreferencesPersistence.class)
12096            protected PortletPreferencesPersistence portletPreferencesPersistence;
12097            @BeanReference(type = ResourcePersistence.class)
12098            protected ResourcePersistence resourcePersistence;
12099            @BeanReference(type = SubscriptionPersistence.class)
12100            protected SubscriptionPersistence subscriptionPersistence;
12101            @BeanReference(type = UserPersistence.class)
12102            protected UserPersistence userPersistence;
12103            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
12104            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
12105            @BeanReference(type = AssetEntryPersistence.class)
12106            protected AssetEntryPersistence assetEntryPersistence;
12107            @BeanReference(type = AssetLinkPersistence.class)
12108            protected AssetLinkPersistence assetLinkPersistence;
12109            @BeanReference(type = AssetTagPersistence.class)
12110            protected AssetTagPersistence assetTagPersistence;
12111            @BeanReference(type = ExpandoValuePersistence.class)
12112            protected ExpandoValuePersistence expandoValuePersistence;
12113            @BeanReference(type = MBMessagePersistence.class)
12114            protected MBMessagePersistence mbMessagePersistence;
12115            @BeanReference(type = RatingsStatsPersistence.class)
12116            protected RatingsStatsPersistence ratingsStatsPersistence;
12117            @BeanReference(type = SocialActivityPersistence.class)
12118            protected SocialActivityPersistence socialActivityPersistence;
12119            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
12120            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
12121            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
12122            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
12123            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
12124            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
12125            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?)";
12126            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
12127            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
12128            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?) AND ";
12129            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
12130            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
12131            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
12132            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
12133            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
12134            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
12135            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
12136            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
12137            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
12138            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
12139            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12140            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
12141            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
12142            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = ?)";
12143            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12144            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
12145            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
12146            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12147            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
12148            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12149            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12150            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12151            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
12152            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
12153            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
12154            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
12155            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12156            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12157            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12158            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12159            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
12160            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
12161            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
12162            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12163            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
12164            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
12165            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12166            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12167            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12168            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12169            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12170            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
12171            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12172            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12173            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12174            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
12175            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
12176            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
12177                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
12178            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
12179                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
12180            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
12181            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
12182            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
12183            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
12184            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
12185            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
12186            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
12187            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12188            private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
12189            private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
12190                            @Override
12191                            public Object clone() {
12192                                    return this;
12193                            }
12194    
12195                            @Override
12196                            public CacheModel<BlogsEntry> toCacheModel() {
12197                                    return _nullBlogsEntryCacheModel;
12198                            }
12199                    };
12200    
12201            private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
12202                            public BlogsEntry toEntityModel() {
12203                                    return _nullBlogsEntry;
12204                            }
12205                    };
12206    }