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