001
014
015 package com.liferay.portlet.asset.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.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.ArrayUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046 import com.liferay.portal.model.CacheModel;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
049 import com.liferay.portal.service.persistence.BatchSessionUtil;
050 import com.liferay.portal.service.persistence.ResourcePersistence;
051 import com.liferay.portal.service.persistence.UserPersistence;
052 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053
054 import com.liferay.portlet.asset.NoSuchCategoryException;
055 import com.liferay.portlet.asset.model.AssetCategory;
056 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
057 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
058
059 import java.io.Serializable;
060
061 import java.util.ArrayList;
062 import java.util.Collections;
063 import java.util.List;
064 import java.util.Set;
065
066
078 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
079 implements AssetCategoryPersistence {
080
085 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
086 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087 ".List1";
088 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089 ".List2";
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
091 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
092 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
093 "findByUuid",
094 new String[] {
095 String.class.getName(),
096
097 "java.lang.Integer", "java.lang.Integer",
098 "com.liferay.portal.kernel.util.OrderByComparator"
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
101 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
102 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
103 "findByUuid", new String[] { String.class.getName() },
104 AssetCategoryModelImpl.UUID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
106 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108 new String[] { String.class.getName() });
109 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
110 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
111 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
112 new String[] { String.class.getName(), Long.class.getName() },
113 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
114 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
115 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
116 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
118 new String[] { String.class.getName(), Long.class.getName() });
119 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
120 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
121 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
122 "findByGroupId",
123 new String[] {
124 Long.class.getName(),
125
126 "java.lang.Integer", "java.lang.Integer",
127 "com.liferay.portal.kernel.util.OrderByComparator"
128 });
129 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
130 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
131 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
132 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
133 "findByGroupId", new String[] { Long.class.getName() },
134 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
135 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
136 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
138 new String[] { Long.class.getName() });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
140 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
141 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
142 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
143 "findByParentCategoryId",
144 new String[] {
145 Long.class.getName(),
146
147 "java.lang.Integer", "java.lang.Integer",
148 "com.liferay.portal.kernel.util.OrderByComparator"
149 });
150 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
151 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
152 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
153 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
154 "findByParentCategoryId", new String[] { Long.class.getName() },
155 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
156 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
157 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
158 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
159 "countByParentCategoryId", new String[] { Long.class.getName() });
160 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
161 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
162 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
163 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
164 "findByVocabularyId",
165 new String[] {
166 Long.class.getName(),
167
168 "java.lang.Integer", "java.lang.Integer",
169 "com.liferay.portal.kernel.util.OrderByComparator"
170 });
171 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
172 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
173 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
174 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
175 "findByVocabularyId", new String[] { Long.class.getName() },
176 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
177 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
178 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
179 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
180 new String[] { Long.class.getName() });
181 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
182 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
183 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
184 "findByG_V",
185 new String[] {
186 Long.class.getName(), Long.class.getName(),
187
188 "java.lang.Integer", "java.lang.Integer",
189 "com.liferay.portal.kernel.util.OrderByComparator"
190 });
191 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
192 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
193 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
194 "findByG_V",
195 new String[] { Long.class.getName(), Long.class.getName() },
196 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
197 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
198 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
199 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
200 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
201 new String[] { Long.class.getName(), Long.class.getName() });
202 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
203 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
204 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
205 new String[] { Long.class.getName(), Long.class.getName() });
206 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
207 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
208 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
209 "findByP_N",
210 new String[] {
211 Long.class.getName(), String.class.getName(),
212
213 "java.lang.Integer", "java.lang.Integer",
214 "com.liferay.portal.kernel.util.OrderByComparator"
215 });
216 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
217 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
218 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
219 "findByP_N",
220 new String[] { Long.class.getName(), String.class.getName() },
221 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
222 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
223 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
224 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
225 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
226 new String[] { Long.class.getName(), String.class.getName() });
227 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
228 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
229 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
230 "findByP_V",
231 new String[] {
232 Long.class.getName(), Long.class.getName(),
233
234 "java.lang.Integer", "java.lang.Integer",
235 "com.liferay.portal.kernel.util.OrderByComparator"
236 });
237 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
238 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
239 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
240 "findByP_V",
241 new String[] { Long.class.getName(), Long.class.getName() },
242 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
243 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
244 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
245 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
246 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
247 new String[] { Long.class.getName(), Long.class.getName() });
248 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
249 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
250 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
251 "findByN_V",
252 new String[] {
253 String.class.getName(), Long.class.getName(),
254
255 "java.lang.Integer", "java.lang.Integer",
256 "com.liferay.portal.kernel.util.OrderByComparator"
257 });
258 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
259 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
260 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
261 "findByN_V",
262 new String[] { String.class.getName(), Long.class.getName() },
263 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
264 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
265 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
266 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
267 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
268 new String[] { String.class.getName(), Long.class.getName() });
269 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
270 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
271 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
272 "findByG_P_V",
273 new String[] {
274 Long.class.getName(), Long.class.getName(), Long.class.getName(),
275
276 "java.lang.Integer", "java.lang.Integer",
277 "com.liferay.portal.kernel.util.OrderByComparator"
278 });
279 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
280 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
281 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
282 "findByG_P_V",
283 new String[] {
284 Long.class.getName(), Long.class.getName(), Long.class.getName()
285 },
286 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
287 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
288 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
289 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
290 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
291 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
292 new String[] {
293 Long.class.getName(), Long.class.getName(), Long.class.getName()
294 });
295 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
296 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
297 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
298 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
299 "findByG_LikeN_V",
300 new String[] {
301 Long.class.getName(), String.class.getName(),
302 Long.class.getName(),
303
304 "java.lang.Integer", "java.lang.Integer",
305 "com.liferay.portal.kernel.util.OrderByComparator"
306 });
307 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
308 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
309 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
310 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
311 new String[] {
312 Long.class.getName(), String.class.getName(),
313 Long.class.getName()
314 });
315 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
316 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
317 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
318 new String[] {
319 Long.class.getName(), String.class.getName(),
320 Long.class.getName()
321 },
322 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
323 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
324 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
325 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
326 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
327 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
328 new String[] {
329 Long.class.getName(), String.class.getName(),
330 Long.class.getName()
331 });
332 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
333 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
334 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
335 "findByG_P_N_V",
336 new String[] {
337 Long.class.getName(), Long.class.getName(),
338 String.class.getName(), Long.class.getName(),
339
340 "java.lang.Integer", "java.lang.Integer",
341 "com.liferay.portal.kernel.util.OrderByComparator"
342 });
343 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
344 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
345 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
346 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
347 "findByG_P_N_V",
348 new String[] {
349 Long.class.getName(), Long.class.getName(),
350 String.class.getName(), Long.class.getName()
351 },
352 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
353 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
354 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
355 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
356 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
357 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
358 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
359 new String[] {
360 Long.class.getName(), Long.class.getName(),
361 String.class.getName(), Long.class.getName()
362 });
363 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
364 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
365 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
366 "findAll", new String[0]);
367 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
368 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
369 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
370 "findAll", new String[0]);
371 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
372 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
373 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
374
375
380 public void cacheResult(AssetCategory assetCategory) {
381 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
382 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
383 assetCategory);
384
385 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
386 new Object[] {
387 assetCategory.getUuid(),
388 Long.valueOf(assetCategory.getGroupId())
389 }, assetCategory);
390
391 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
392 new Object[] {
393 Long.valueOf(assetCategory.getParentCategoryId()),
394
395 assetCategory.getName(),
396 Long.valueOf(assetCategory.getVocabularyId())
397 }, assetCategory);
398
399 assetCategory.resetOriginalValues();
400 }
401
402
407 public void cacheResult(List<AssetCategory> assetCategories) {
408 for (AssetCategory assetCategory : assetCategories) {
409 if (EntityCacheUtil.getResult(
410 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
411 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
412 cacheResult(assetCategory);
413 }
414 else {
415 assetCategory.resetOriginalValues();
416 }
417 }
418 }
419
420
427 @Override
428 public void clearCache() {
429 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
430 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
431 }
432
433 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
434
435 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
436 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
437 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
438 }
439
440
447 @Override
448 public void clearCache(AssetCategory assetCategory) {
449 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
450 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
451
452 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
453 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
454
455 clearUniqueFindersCache(assetCategory);
456 }
457
458 @Override
459 public void clearCache(List<AssetCategory> assetCategories) {
460 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
461 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
462
463 for (AssetCategory assetCategory : assetCategories) {
464 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
465 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
466
467 clearUniqueFindersCache(assetCategory);
468 }
469 }
470
471 protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
472 if (assetCategory.isNew()) {
473 Object[] args = new Object[] {
474 assetCategory.getUuid(),
475 Long.valueOf(assetCategory.getGroupId())
476 };
477
478 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
479 Long.valueOf(1));
480 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
481 assetCategory);
482
483 args = new Object[] {
484 Long.valueOf(assetCategory.getParentCategoryId()),
485
486 assetCategory.getName(),
487 Long.valueOf(assetCategory.getVocabularyId())
488 };
489
490 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
491 Long.valueOf(1));
492 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
493 assetCategory);
494 }
495 else {
496 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
497
498 if ((assetCategoryModelImpl.getColumnBitmask() &
499 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] {
501 assetCategory.getUuid(),
502 Long.valueOf(assetCategory.getGroupId())
503 };
504
505 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
506 Long.valueOf(1));
507 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
508 assetCategory);
509 }
510
511 if ((assetCategoryModelImpl.getColumnBitmask() &
512 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
513 Object[] args = new Object[] {
514 Long.valueOf(assetCategory.getParentCategoryId()),
515
516 assetCategory.getName(),
517 Long.valueOf(assetCategory.getVocabularyId())
518 };
519
520 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
521 Long.valueOf(1));
522 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
523 assetCategory);
524 }
525 }
526 }
527
528 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
529 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
530
531 Object[] args = new Object[] {
532 assetCategory.getUuid(),
533 Long.valueOf(assetCategory.getGroupId())
534 };
535
536 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
537 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
538
539 if ((assetCategoryModelImpl.getColumnBitmask() &
540 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
541 args = new Object[] {
542 assetCategoryModelImpl.getOriginalUuid(),
543 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
544 };
545
546 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
547 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
548 }
549
550 args = new Object[] {
551 Long.valueOf(assetCategory.getParentCategoryId()),
552
553 assetCategory.getName(),
554 Long.valueOf(assetCategory.getVocabularyId())
555 };
556
557 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
558 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
559
560 if ((assetCategoryModelImpl.getColumnBitmask() &
561 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
562 args = new Object[] {
563 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
564
565 assetCategoryModelImpl.getOriginalName(),
566 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
567 };
568
569 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
571 }
572 }
573
574
580 public AssetCategory create(long categoryId) {
581 AssetCategory assetCategory = new AssetCategoryImpl();
582
583 assetCategory.setNew(true);
584 assetCategory.setPrimaryKey(categoryId);
585
586 String uuid = PortalUUIDUtil.generate();
587
588 assetCategory.setUuid(uuid);
589
590 return assetCategory;
591 }
592
593
601 public AssetCategory remove(long categoryId)
602 throws NoSuchCategoryException, SystemException {
603 return remove(Long.valueOf(categoryId));
604 }
605
606
614 @Override
615 public AssetCategory remove(Serializable primaryKey)
616 throws NoSuchCategoryException, SystemException {
617 Session session = null;
618
619 try {
620 session = openSession();
621
622 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
623 primaryKey);
624
625 if (assetCategory == null) {
626 if (_log.isWarnEnabled()) {
627 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
628 }
629
630 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
631 primaryKey);
632 }
633
634 return remove(assetCategory);
635 }
636 catch (NoSuchCategoryException nsee) {
637 throw nsee;
638 }
639 catch (Exception e) {
640 throw processException(e);
641 }
642 finally {
643 closeSession(session);
644 }
645 }
646
647 @Override
648 protected AssetCategory removeImpl(AssetCategory assetCategory)
649 throws SystemException {
650 assetCategory = toUnwrappedModel(assetCategory);
651
652 try {
653 clearAssetEntries.clear(assetCategory.getPrimaryKey());
654 }
655 catch (Exception e) {
656 throw processException(e);
657 }
658 finally {
659 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
660 }
661
662 shrinkTree(assetCategory);
663
664 Session session = null;
665
666 try {
667 session = openSession();
668
669 BatchSessionUtil.delete(session, assetCategory);
670 }
671 catch (Exception e) {
672 throw processException(e);
673 }
674 finally {
675 closeSession(session);
676 }
677
678 clearCache(assetCategory);
679
680 return assetCategory;
681 }
682
683 @Override
684 public AssetCategory updateImpl(
685 com.liferay.portlet.asset.model.AssetCategory assetCategory,
686 boolean merge) throws SystemException {
687 assetCategory = toUnwrappedModel(assetCategory);
688
689 boolean isNew = assetCategory.isNew();
690
691 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
692
693 if (Validator.isNull(assetCategory.getUuid())) {
694 String uuid = PortalUUIDUtil.generate();
695
696 assetCategory.setUuid(uuid);
697 }
698
699 if (isNew) {
700 expandTree(assetCategory, null);
701 }
702 else {
703 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
704 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
705
706 shrinkTree(assetCategory);
707 expandTree(assetCategory, childrenCategoryIds);
708 }
709 }
710
711 Session session = null;
712
713 try {
714 session = openSession();
715
716 BatchSessionUtil.update(session, assetCategory, merge);
717
718 assetCategory.setNew(false);
719 }
720 catch (Exception e) {
721 throw processException(e);
722 }
723 finally {
724 closeSession(session);
725 }
726
727 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
728
729 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
730 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
731 }
732
733 else {
734 if ((assetCategoryModelImpl.getColumnBitmask() &
735 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
736 Object[] args = new Object[] {
737 assetCategoryModelImpl.getOriginalUuid()
738 };
739
740 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
741 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
742 args);
743
744 args = new Object[] { assetCategoryModelImpl.getUuid() };
745
746 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
747 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
748 args);
749 }
750
751 if ((assetCategoryModelImpl.getColumnBitmask() &
752 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
753 Object[] args = new Object[] {
754 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
755 };
756
757 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
758 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
759 args);
760
761 args = new Object[] {
762 Long.valueOf(assetCategoryModelImpl.getGroupId())
763 };
764
765 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
766 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
767 args);
768 }
769
770 if ((assetCategoryModelImpl.getColumnBitmask() &
771 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
772 Object[] args = new Object[] {
773 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
774 };
775
776 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
777 args);
778 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
779 args);
780
781 args = new Object[] {
782 Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
783 };
784
785 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
786 args);
787 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
788 args);
789 }
790
791 if ((assetCategoryModelImpl.getColumnBitmask() &
792 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
793 Object[] args = new Object[] {
794 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
795 };
796
797 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
798 args);
799 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
800 args);
801
802 args = new Object[] {
803 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
804 };
805
806 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
807 args);
808 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
809 args);
810 }
811
812 if ((assetCategoryModelImpl.getColumnBitmask() &
813 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
814 Object[] args = new Object[] {
815 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
816 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
817 };
818
819 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
820 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
821 args);
822
823 args = new Object[] {
824 Long.valueOf(assetCategoryModelImpl.getGroupId()),
825 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
826 };
827
828 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
829 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
830 args);
831 }
832
833 if ((assetCategoryModelImpl.getColumnBitmask() &
834 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
835 Object[] args = new Object[] {
836 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
837
838 assetCategoryModelImpl.getOriginalName()
839 };
840
841 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
842 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
843 args);
844
845 args = new Object[] {
846 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
847
848 assetCategoryModelImpl.getName()
849 };
850
851 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
852 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
853 args);
854 }
855
856 if ((assetCategoryModelImpl.getColumnBitmask() &
857 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
858 Object[] args = new Object[] {
859 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
860 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
861 };
862
863 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
864 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
865 args);
866
867 args = new Object[] {
868 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
869 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
870 };
871
872 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
873 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
874 args);
875 }
876
877 if ((assetCategoryModelImpl.getColumnBitmask() &
878 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
879 Object[] args = new Object[] {
880 assetCategoryModelImpl.getOriginalName(),
881 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
882 };
883
884 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
885 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
886 args);
887
888 args = new Object[] {
889 assetCategoryModelImpl.getName(),
890 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
891 };
892
893 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
894 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
895 args);
896 }
897
898 if ((assetCategoryModelImpl.getColumnBitmask() &
899 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
900 Object[] args = new Object[] {
901 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
902 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
903 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
904 };
905
906 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
907 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
908 args);
909
910 args = new Object[] {
911 Long.valueOf(assetCategoryModelImpl.getGroupId()),
912 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
913 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
914 };
915
916 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
917 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
918 args);
919 }
920
921 if ((assetCategoryModelImpl.getColumnBitmask() &
922 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
923 Object[] args = new Object[] {
924 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
925 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
926
927 assetCategoryModelImpl.getOriginalName(),
928 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
929 };
930
931 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
932 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
933 args);
934
935 args = new Object[] {
936 Long.valueOf(assetCategoryModelImpl.getGroupId()),
937 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
938
939 assetCategoryModelImpl.getName(),
940 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
941 };
942
943 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
944 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
945 args);
946 }
947 }
948
949 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
950 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
951 assetCategory);
952
953 clearUniqueFindersCache(assetCategory);
954 cacheUniqueFindersCache(assetCategory);
955
956 return assetCategory;
957 }
958
959 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
960 if (assetCategory instanceof AssetCategoryImpl) {
961 return assetCategory;
962 }
963
964 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
965
966 assetCategoryImpl.setNew(assetCategory.isNew());
967 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
968
969 assetCategoryImpl.setUuid(assetCategory.getUuid());
970 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
971 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
972 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
973 assetCategoryImpl.setUserId(assetCategory.getUserId());
974 assetCategoryImpl.setUserName(assetCategory.getUserName());
975 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
976 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
977 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
978 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
979 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
980 assetCategoryImpl.setName(assetCategory.getName());
981 assetCategoryImpl.setTitle(assetCategory.getTitle());
982 assetCategoryImpl.setDescription(assetCategory.getDescription());
983 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
984
985 return assetCategoryImpl;
986 }
987
988
996 @Override
997 public AssetCategory findByPrimaryKey(Serializable primaryKey)
998 throws NoSuchModelException, SystemException {
999 return findByPrimaryKey(((Long)primaryKey).longValue());
1000 }
1001
1002
1010 public AssetCategory findByPrimaryKey(long categoryId)
1011 throws NoSuchCategoryException, SystemException {
1012 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
1013
1014 if (assetCategory == null) {
1015 if (_log.isWarnEnabled()) {
1016 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
1017 }
1018
1019 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1020 categoryId);
1021 }
1022
1023 return assetCategory;
1024 }
1025
1026
1033 @Override
1034 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
1035 throws SystemException {
1036 return fetchByPrimaryKey(((Long)primaryKey).longValue());
1037 }
1038
1039
1046 public AssetCategory fetchByPrimaryKey(long categoryId)
1047 throws SystemException {
1048 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1049 AssetCategoryImpl.class, categoryId);
1050
1051 if (assetCategory == _nullAssetCategory) {
1052 return null;
1053 }
1054
1055 if (assetCategory == null) {
1056 Session session = null;
1057
1058 boolean hasException = false;
1059
1060 try {
1061 session = openSession();
1062
1063 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
1064 Long.valueOf(categoryId));
1065 }
1066 catch (Exception e) {
1067 hasException = true;
1068
1069 throw processException(e);
1070 }
1071 finally {
1072 if (assetCategory != null) {
1073 cacheResult(assetCategory);
1074 }
1075 else if (!hasException) {
1076 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1077 AssetCategoryImpl.class, categoryId, _nullAssetCategory);
1078 }
1079
1080 closeSession(session);
1081 }
1082 }
1083
1084 return assetCategory;
1085 }
1086
1087
1094 public List<AssetCategory> findByUuid(String uuid)
1095 throws SystemException {
1096 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1097 }
1098
1099
1112 public List<AssetCategory> findByUuid(String uuid, int start, int end)
1113 throws SystemException {
1114 return findByUuid(uuid, start, end, null);
1115 }
1116
1117
1131 public List<AssetCategory> findByUuid(String uuid, int start, int end,
1132 OrderByComparator orderByComparator) throws SystemException {
1133 FinderPath finderPath = null;
1134 Object[] finderArgs = null;
1135
1136 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1137 (orderByComparator == null)) {
1138 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1139 finderArgs = new Object[] { uuid };
1140 }
1141 else {
1142 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1143 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1144 }
1145
1146 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1147 finderArgs, this);
1148
1149 if ((list != null) && !list.isEmpty()) {
1150 for (AssetCategory assetCategory : list) {
1151 if (!Validator.equals(uuid, assetCategory.getUuid())) {
1152 list = null;
1153
1154 break;
1155 }
1156 }
1157 }
1158
1159 if (list == null) {
1160 StringBundler query = null;
1161
1162 if (orderByComparator != null) {
1163 query = new StringBundler(3 +
1164 (orderByComparator.getOrderByFields().length * 3));
1165 }
1166 else {
1167 query = new StringBundler(3);
1168 }
1169
1170 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1171
1172 if (uuid == null) {
1173 query.append(_FINDER_COLUMN_UUID_UUID_1);
1174 }
1175 else {
1176 if (uuid.equals(StringPool.BLANK)) {
1177 query.append(_FINDER_COLUMN_UUID_UUID_3);
1178 }
1179 else {
1180 query.append(_FINDER_COLUMN_UUID_UUID_2);
1181 }
1182 }
1183
1184 if (orderByComparator != null) {
1185 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1186 orderByComparator);
1187 }
1188
1189 else {
1190 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1191 }
1192
1193 String sql = query.toString();
1194
1195 Session session = null;
1196
1197 try {
1198 session = openSession();
1199
1200 Query q = session.createQuery(sql);
1201
1202 QueryPos qPos = QueryPos.getInstance(q);
1203
1204 if (uuid != null) {
1205 qPos.add(uuid);
1206 }
1207
1208 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1209 start, end);
1210 }
1211 catch (Exception e) {
1212 throw processException(e);
1213 }
1214 finally {
1215 if (list == null) {
1216 FinderCacheUtil.removeResult(finderPath, finderArgs);
1217 }
1218 else {
1219 cacheResult(list);
1220
1221 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1222 }
1223
1224 closeSession(session);
1225 }
1226 }
1227
1228 return list;
1229 }
1230
1231
1240 public AssetCategory findByUuid_First(String uuid,
1241 OrderByComparator orderByComparator)
1242 throws NoSuchCategoryException, SystemException {
1243 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
1244
1245 if (assetCategory != null) {
1246 return assetCategory;
1247 }
1248
1249 StringBundler msg = new StringBundler(4);
1250
1251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252
1253 msg.append("uuid=");
1254 msg.append(uuid);
1255
1256 msg.append(StringPool.CLOSE_CURLY_BRACE);
1257
1258 throw new NoSuchCategoryException(msg.toString());
1259 }
1260
1261
1269 public AssetCategory fetchByUuid_First(String uuid,
1270 OrderByComparator orderByComparator) throws SystemException {
1271 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1272
1273 if (!list.isEmpty()) {
1274 return list.get(0);
1275 }
1276
1277 return null;
1278 }
1279
1280
1289 public AssetCategory findByUuid_Last(String uuid,
1290 OrderByComparator orderByComparator)
1291 throws NoSuchCategoryException, SystemException {
1292 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
1293
1294 if (assetCategory != null) {
1295 return assetCategory;
1296 }
1297
1298 StringBundler msg = new StringBundler(4);
1299
1300 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1301
1302 msg.append("uuid=");
1303 msg.append(uuid);
1304
1305 msg.append(StringPool.CLOSE_CURLY_BRACE);
1306
1307 throw new NoSuchCategoryException(msg.toString());
1308 }
1309
1310
1318 public AssetCategory fetchByUuid_Last(String uuid,
1319 OrderByComparator orderByComparator) throws SystemException {
1320 int count = countByUuid(uuid);
1321
1322 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1323 orderByComparator);
1324
1325 if (!list.isEmpty()) {
1326 return list.get(0);
1327 }
1328
1329 return null;
1330 }
1331
1332
1342 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1343 OrderByComparator orderByComparator)
1344 throws NoSuchCategoryException, SystemException {
1345 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1346
1347 Session session = null;
1348
1349 try {
1350 session = openSession();
1351
1352 AssetCategory[] array = new AssetCategoryImpl[3];
1353
1354 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1355 orderByComparator, true);
1356
1357 array[1] = assetCategory;
1358
1359 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1360 orderByComparator, false);
1361
1362 return array;
1363 }
1364 catch (Exception e) {
1365 throw processException(e);
1366 }
1367 finally {
1368 closeSession(session);
1369 }
1370 }
1371
1372 protected AssetCategory getByUuid_PrevAndNext(Session session,
1373 AssetCategory assetCategory, String uuid,
1374 OrderByComparator orderByComparator, boolean previous) {
1375 StringBundler query = null;
1376
1377 if (orderByComparator != null) {
1378 query = new StringBundler(6 +
1379 (orderByComparator.getOrderByFields().length * 6));
1380 }
1381 else {
1382 query = new StringBundler(3);
1383 }
1384
1385 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1386
1387 if (uuid == null) {
1388 query.append(_FINDER_COLUMN_UUID_UUID_1);
1389 }
1390 else {
1391 if (uuid.equals(StringPool.BLANK)) {
1392 query.append(_FINDER_COLUMN_UUID_UUID_3);
1393 }
1394 else {
1395 query.append(_FINDER_COLUMN_UUID_UUID_2);
1396 }
1397 }
1398
1399 if (orderByComparator != null) {
1400 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1401
1402 if (orderByConditionFields.length > 0) {
1403 query.append(WHERE_AND);
1404 }
1405
1406 for (int i = 0; i < orderByConditionFields.length; i++) {
1407 query.append(_ORDER_BY_ENTITY_ALIAS);
1408 query.append(orderByConditionFields[i]);
1409
1410 if ((i + 1) < orderByConditionFields.length) {
1411 if (orderByComparator.isAscending() ^ previous) {
1412 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1413 }
1414 else {
1415 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1416 }
1417 }
1418 else {
1419 if (orderByComparator.isAscending() ^ previous) {
1420 query.append(WHERE_GREATER_THAN);
1421 }
1422 else {
1423 query.append(WHERE_LESSER_THAN);
1424 }
1425 }
1426 }
1427
1428 query.append(ORDER_BY_CLAUSE);
1429
1430 String[] orderByFields = orderByComparator.getOrderByFields();
1431
1432 for (int i = 0; i < orderByFields.length; i++) {
1433 query.append(_ORDER_BY_ENTITY_ALIAS);
1434 query.append(orderByFields[i]);
1435
1436 if ((i + 1) < orderByFields.length) {
1437 if (orderByComparator.isAscending() ^ previous) {
1438 query.append(ORDER_BY_ASC_HAS_NEXT);
1439 }
1440 else {
1441 query.append(ORDER_BY_DESC_HAS_NEXT);
1442 }
1443 }
1444 else {
1445 if (orderByComparator.isAscending() ^ previous) {
1446 query.append(ORDER_BY_ASC);
1447 }
1448 else {
1449 query.append(ORDER_BY_DESC);
1450 }
1451 }
1452 }
1453 }
1454
1455 else {
1456 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1457 }
1458
1459 String sql = query.toString();
1460
1461 Query q = session.createQuery(sql);
1462
1463 q.setFirstResult(0);
1464 q.setMaxResults(2);
1465
1466 QueryPos qPos = QueryPos.getInstance(q);
1467
1468 if (uuid != null) {
1469 qPos.add(uuid);
1470 }
1471
1472 if (orderByComparator != null) {
1473 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1474
1475 for (Object value : values) {
1476 qPos.add(value);
1477 }
1478 }
1479
1480 List<AssetCategory> list = q.list();
1481
1482 if (list.size() == 2) {
1483 return list.get(1);
1484 }
1485 else {
1486 return null;
1487 }
1488 }
1489
1490
1499 public AssetCategory findByUUID_G(String uuid, long groupId)
1500 throws NoSuchCategoryException, SystemException {
1501 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1502
1503 if (assetCategory == null) {
1504 StringBundler msg = new StringBundler(6);
1505
1506 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1507
1508 msg.append("uuid=");
1509 msg.append(uuid);
1510
1511 msg.append(", groupId=");
1512 msg.append(groupId);
1513
1514 msg.append(StringPool.CLOSE_CURLY_BRACE);
1515
1516 if (_log.isWarnEnabled()) {
1517 _log.warn(msg.toString());
1518 }
1519
1520 throw new NoSuchCategoryException(msg.toString());
1521 }
1522
1523 return assetCategory;
1524 }
1525
1526
1534 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1535 throws SystemException {
1536 return fetchByUUID_G(uuid, groupId, true);
1537 }
1538
1539
1548 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1549 boolean retrieveFromCache) throws SystemException {
1550 Object[] finderArgs = new Object[] { uuid, groupId };
1551
1552 Object result = null;
1553
1554 if (retrieveFromCache) {
1555 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1556 finderArgs, this);
1557 }
1558
1559 if (result instanceof AssetCategory) {
1560 AssetCategory assetCategory = (AssetCategory)result;
1561
1562 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1563 (groupId != assetCategory.getGroupId())) {
1564 result = null;
1565 }
1566 }
1567
1568 if (result == null) {
1569 StringBundler query = new StringBundler(4);
1570
1571 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1572
1573 if (uuid == null) {
1574 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1575 }
1576 else {
1577 if (uuid.equals(StringPool.BLANK)) {
1578 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1579 }
1580 else {
1581 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1582 }
1583 }
1584
1585 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1586
1587 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1588
1589 String sql = query.toString();
1590
1591 Session session = null;
1592
1593 try {
1594 session = openSession();
1595
1596 Query q = session.createQuery(sql);
1597
1598 QueryPos qPos = QueryPos.getInstance(q);
1599
1600 if (uuid != null) {
1601 qPos.add(uuid);
1602 }
1603
1604 qPos.add(groupId);
1605
1606 List<AssetCategory> list = q.list();
1607
1608 result = list;
1609
1610 AssetCategory assetCategory = null;
1611
1612 if (list.isEmpty()) {
1613 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1614 finderArgs, list);
1615 }
1616 else {
1617 assetCategory = list.get(0);
1618
1619 cacheResult(assetCategory);
1620
1621 if ((assetCategory.getUuid() == null) ||
1622 !assetCategory.getUuid().equals(uuid) ||
1623 (assetCategory.getGroupId() != groupId)) {
1624 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1625 finderArgs, assetCategory);
1626 }
1627 }
1628
1629 return assetCategory;
1630 }
1631 catch (Exception e) {
1632 throw processException(e);
1633 }
1634 finally {
1635 if (result == null) {
1636 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1637 finderArgs);
1638 }
1639
1640 closeSession(session);
1641 }
1642 }
1643 else {
1644 if (result instanceof List<?>) {
1645 return null;
1646 }
1647 else {
1648 return (AssetCategory)result;
1649 }
1650 }
1651 }
1652
1653
1660 public List<AssetCategory> findByGroupId(long groupId)
1661 throws SystemException {
1662 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1663 }
1664
1665
1678 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1679 throws SystemException {
1680 return findByGroupId(groupId, start, end, null);
1681 }
1682
1683
1697 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1698 OrderByComparator orderByComparator) throws SystemException {
1699 FinderPath finderPath = null;
1700 Object[] finderArgs = null;
1701
1702 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1703 (orderByComparator == null)) {
1704 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1705 finderArgs = new Object[] { groupId };
1706 }
1707 else {
1708 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1709 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1710 }
1711
1712 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1713 finderArgs, this);
1714
1715 if ((list != null) && !list.isEmpty()) {
1716 for (AssetCategory assetCategory : list) {
1717 if ((groupId != assetCategory.getGroupId())) {
1718 list = null;
1719
1720 break;
1721 }
1722 }
1723 }
1724
1725 if (list == null) {
1726 StringBundler query = null;
1727
1728 if (orderByComparator != null) {
1729 query = new StringBundler(3 +
1730 (orderByComparator.getOrderByFields().length * 3));
1731 }
1732 else {
1733 query = new StringBundler(3);
1734 }
1735
1736 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1737
1738 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1739
1740 if (orderByComparator != null) {
1741 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1742 orderByComparator);
1743 }
1744
1745 else {
1746 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1747 }
1748
1749 String sql = query.toString();
1750
1751 Session session = null;
1752
1753 try {
1754 session = openSession();
1755
1756 Query q = session.createQuery(sql);
1757
1758 QueryPos qPos = QueryPos.getInstance(q);
1759
1760 qPos.add(groupId);
1761
1762 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1763 start, end);
1764 }
1765 catch (Exception e) {
1766 throw processException(e);
1767 }
1768 finally {
1769 if (list == null) {
1770 FinderCacheUtil.removeResult(finderPath, finderArgs);
1771 }
1772 else {
1773 cacheResult(list);
1774
1775 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1776 }
1777
1778 closeSession(session);
1779 }
1780 }
1781
1782 return list;
1783 }
1784
1785
1794 public AssetCategory findByGroupId_First(long groupId,
1795 OrderByComparator orderByComparator)
1796 throws NoSuchCategoryException, SystemException {
1797 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1798 orderByComparator);
1799
1800 if (assetCategory != null) {
1801 return assetCategory;
1802 }
1803
1804 StringBundler msg = new StringBundler(4);
1805
1806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1807
1808 msg.append("groupId=");
1809 msg.append(groupId);
1810
1811 msg.append(StringPool.CLOSE_CURLY_BRACE);
1812
1813 throw new NoSuchCategoryException(msg.toString());
1814 }
1815
1816
1824 public AssetCategory fetchByGroupId_First(long groupId,
1825 OrderByComparator orderByComparator) throws SystemException {
1826 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1827 orderByComparator);
1828
1829 if (!list.isEmpty()) {
1830 return list.get(0);
1831 }
1832
1833 return null;
1834 }
1835
1836
1845 public AssetCategory findByGroupId_Last(long groupId,
1846 OrderByComparator orderByComparator)
1847 throws NoSuchCategoryException, SystemException {
1848 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1849 orderByComparator);
1850
1851 if (assetCategory != null) {
1852 return assetCategory;
1853 }
1854
1855 StringBundler msg = new StringBundler(4);
1856
1857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1858
1859 msg.append("groupId=");
1860 msg.append(groupId);
1861
1862 msg.append(StringPool.CLOSE_CURLY_BRACE);
1863
1864 throw new NoSuchCategoryException(msg.toString());
1865 }
1866
1867
1875 public AssetCategory fetchByGroupId_Last(long groupId,
1876 OrderByComparator orderByComparator) throws SystemException {
1877 int count = countByGroupId(groupId);
1878
1879 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1880 orderByComparator);
1881
1882 if (!list.isEmpty()) {
1883 return list.get(0);
1884 }
1885
1886 return null;
1887 }
1888
1889
1899 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1900 long groupId, OrderByComparator orderByComparator)
1901 throws NoSuchCategoryException, SystemException {
1902 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1903
1904 Session session = null;
1905
1906 try {
1907 session = openSession();
1908
1909 AssetCategory[] array = new AssetCategoryImpl[3];
1910
1911 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1912 groupId, orderByComparator, true);
1913
1914 array[1] = assetCategory;
1915
1916 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1917 groupId, orderByComparator, false);
1918
1919 return array;
1920 }
1921 catch (Exception e) {
1922 throw processException(e);
1923 }
1924 finally {
1925 closeSession(session);
1926 }
1927 }
1928
1929 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1930 AssetCategory assetCategory, long groupId,
1931 OrderByComparator orderByComparator, boolean previous) {
1932 StringBundler query = null;
1933
1934 if (orderByComparator != null) {
1935 query = new StringBundler(6 +
1936 (orderByComparator.getOrderByFields().length * 6));
1937 }
1938 else {
1939 query = new StringBundler(3);
1940 }
1941
1942 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1943
1944 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1945
1946 if (orderByComparator != null) {
1947 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1948
1949 if (orderByConditionFields.length > 0) {
1950 query.append(WHERE_AND);
1951 }
1952
1953 for (int i = 0; i < orderByConditionFields.length; i++) {
1954 query.append(_ORDER_BY_ENTITY_ALIAS);
1955 query.append(orderByConditionFields[i]);
1956
1957 if ((i + 1) < orderByConditionFields.length) {
1958 if (orderByComparator.isAscending() ^ previous) {
1959 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1960 }
1961 else {
1962 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1963 }
1964 }
1965 else {
1966 if (orderByComparator.isAscending() ^ previous) {
1967 query.append(WHERE_GREATER_THAN);
1968 }
1969 else {
1970 query.append(WHERE_LESSER_THAN);
1971 }
1972 }
1973 }
1974
1975 query.append(ORDER_BY_CLAUSE);
1976
1977 String[] orderByFields = orderByComparator.getOrderByFields();
1978
1979 for (int i = 0; i < orderByFields.length; i++) {
1980 query.append(_ORDER_BY_ENTITY_ALIAS);
1981 query.append(orderByFields[i]);
1982
1983 if ((i + 1) < orderByFields.length) {
1984 if (orderByComparator.isAscending() ^ previous) {
1985 query.append(ORDER_BY_ASC_HAS_NEXT);
1986 }
1987 else {
1988 query.append(ORDER_BY_DESC_HAS_NEXT);
1989 }
1990 }
1991 else {
1992 if (orderByComparator.isAscending() ^ previous) {
1993 query.append(ORDER_BY_ASC);
1994 }
1995 else {
1996 query.append(ORDER_BY_DESC);
1997 }
1998 }
1999 }
2000 }
2001
2002 else {
2003 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2004 }
2005
2006 String sql = query.toString();
2007
2008 Query q = session.createQuery(sql);
2009
2010 q.setFirstResult(0);
2011 q.setMaxResults(2);
2012
2013 QueryPos qPos = QueryPos.getInstance(q);
2014
2015 qPos.add(groupId);
2016
2017 if (orderByComparator != null) {
2018 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2019
2020 for (Object value : values) {
2021 qPos.add(value);
2022 }
2023 }
2024
2025 List<AssetCategory> list = q.list();
2026
2027 if (list.size() == 2) {
2028 return list.get(1);
2029 }
2030 else {
2031 return null;
2032 }
2033 }
2034
2035
2042 public List<AssetCategory> filterFindByGroupId(long groupId)
2043 throws SystemException {
2044 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2045 QueryUtil.ALL_POS, null);
2046 }
2047
2048
2061 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2062 int end) throws SystemException {
2063 return filterFindByGroupId(groupId, start, end, null);
2064 }
2065
2066
2080 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2081 int end, OrderByComparator orderByComparator) throws SystemException {
2082 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2083 return findByGroupId(groupId, start, end, orderByComparator);
2084 }
2085
2086 StringBundler query = null;
2087
2088 if (orderByComparator != null) {
2089 query = new StringBundler(3 +
2090 (orderByComparator.getOrderByFields().length * 3));
2091 }
2092 else {
2093 query = new StringBundler(3);
2094 }
2095
2096 if (getDB().isSupportsInlineDistinct()) {
2097 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2098 }
2099 else {
2100 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2101 }
2102
2103 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2104
2105 if (!getDB().isSupportsInlineDistinct()) {
2106 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2107 }
2108
2109 if (orderByComparator != null) {
2110 if (getDB().isSupportsInlineDistinct()) {
2111 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2112 orderByComparator);
2113 }
2114 else {
2115 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2116 orderByComparator);
2117 }
2118 }
2119
2120 else {
2121 if (getDB().isSupportsInlineDistinct()) {
2122 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2123 }
2124 else {
2125 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2126 }
2127 }
2128
2129 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2130 AssetCategory.class.getName(),
2131 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2132
2133 Session session = null;
2134
2135 try {
2136 session = openSession();
2137
2138 SQLQuery q = session.createSQLQuery(sql);
2139
2140 if (getDB().isSupportsInlineDistinct()) {
2141 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2142 }
2143 else {
2144 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2145 }
2146
2147 QueryPos qPos = QueryPos.getInstance(q);
2148
2149 qPos.add(groupId);
2150
2151 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2152 end);
2153 }
2154 catch (Exception e) {
2155 throw processException(e);
2156 }
2157 finally {
2158 closeSession(session);
2159 }
2160 }
2161
2162
2172 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2173 long groupId, OrderByComparator orderByComparator)
2174 throws NoSuchCategoryException, SystemException {
2175 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2176 return findByGroupId_PrevAndNext(categoryId, groupId,
2177 orderByComparator);
2178 }
2179
2180 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2181
2182 Session session = null;
2183
2184 try {
2185 session = openSession();
2186
2187 AssetCategory[] array = new AssetCategoryImpl[3];
2188
2189 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2190 groupId, orderByComparator, true);
2191
2192 array[1] = assetCategory;
2193
2194 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2195 groupId, orderByComparator, false);
2196
2197 return array;
2198 }
2199 catch (Exception e) {
2200 throw processException(e);
2201 }
2202 finally {
2203 closeSession(session);
2204 }
2205 }
2206
2207 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2208 AssetCategory assetCategory, long groupId,
2209 OrderByComparator orderByComparator, boolean previous) {
2210 StringBundler query = null;
2211
2212 if (orderByComparator != null) {
2213 query = new StringBundler(6 +
2214 (orderByComparator.getOrderByFields().length * 6));
2215 }
2216 else {
2217 query = new StringBundler(3);
2218 }
2219
2220 if (getDB().isSupportsInlineDistinct()) {
2221 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2222 }
2223 else {
2224 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2225 }
2226
2227 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2228
2229 if (!getDB().isSupportsInlineDistinct()) {
2230 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2231 }
2232
2233 if (orderByComparator != null) {
2234 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2235
2236 if (orderByConditionFields.length > 0) {
2237 query.append(WHERE_AND);
2238 }
2239
2240 for (int i = 0; i < orderByConditionFields.length; i++) {
2241 if (getDB().isSupportsInlineDistinct()) {
2242 query.append(_ORDER_BY_ENTITY_ALIAS);
2243 }
2244 else {
2245 query.append(_ORDER_BY_ENTITY_TABLE);
2246 }
2247
2248 query.append(orderByConditionFields[i]);
2249
2250 if ((i + 1) < orderByConditionFields.length) {
2251 if (orderByComparator.isAscending() ^ previous) {
2252 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2253 }
2254 else {
2255 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2256 }
2257 }
2258 else {
2259 if (orderByComparator.isAscending() ^ previous) {
2260 query.append(WHERE_GREATER_THAN);
2261 }
2262 else {
2263 query.append(WHERE_LESSER_THAN);
2264 }
2265 }
2266 }
2267
2268 query.append(ORDER_BY_CLAUSE);
2269
2270 String[] orderByFields = orderByComparator.getOrderByFields();
2271
2272 for (int i = 0; i < orderByFields.length; i++) {
2273 if (getDB().isSupportsInlineDistinct()) {
2274 query.append(_ORDER_BY_ENTITY_ALIAS);
2275 }
2276 else {
2277 query.append(_ORDER_BY_ENTITY_TABLE);
2278 }
2279
2280 query.append(orderByFields[i]);
2281
2282 if ((i + 1) < orderByFields.length) {
2283 if (orderByComparator.isAscending() ^ previous) {
2284 query.append(ORDER_BY_ASC_HAS_NEXT);
2285 }
2286 else {
2287 query.append(ORDER_BY_DESC_HAS_NEXT);
2288 }
2289 }
2290 else {
2291 if (orderByComparator.isAscending() ^ previous) {
2292 query.append(ORDER_BY_ASC);
2293 }
2294 else {
2295 query.append(ORDER_BY_DESC);
2296 }
2297 }
2298 }
2299 }
2300
2301 else {
2302 if (getDB().isSupportsInlineDistinct()) {
2303 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2304 }
2305 else {
2306 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2307 }
2308 }
2309
2310 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2311 AssetCategory.class.getName(),
2312 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2313
2314 SQLQuery q = session.createSQLQuery(sql);
2315
2316 q.setFirstResult(0);
2317 q.setMaxResults(2);
2318
2319 if (getDB().isSupportsInlineDistinct()) {
2320 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2321 }
2322 else {
2323 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2324 }
2325
2326 QueryPos qPos = QueryPos.getInstance(q);
2327
2328 qPos.add(groupId);
2329
2330 if (orderByComparator != null) {
2331 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2332
2333 for (Object value : values) {
2334 qPos.add(value);
2335 }
2336 }
2337
2338 List<AssetCategory> list = q.list();
2339
2340 if (list.size() == 2) {
2341 return list.get(1);
2342 }
2343 else {
2344 return null;
2345 }
2346 }
2347
2348
2355 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2356 throws SystemException {
2357 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2358 QueryUtil.ALL_POS, null);
2359 }
2360
2361
2374 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2375 int start, int end) throws SystemException {
2376 return findByParentCategoryId(parentCategoryId, start, end, null);
2377 }
2378
2379
2393 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2394 int start, int end, OrderByComparator orderByComparator)
2395 throws SystemException {
2396 FinderPath finderPath = null;
2397 Object[] finderArgs = null;
2398
2399 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2400 (orderByComparator == null)) {
2401 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2402 finderArgs = new Object[] { parentCategoryId };
2403 }
2404 else {
2405 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2406 finderArgs = new Object[] {
2407 parentCategoryId,
2408
2409 start, end, orderByComparator
2410 };
2411 }
2412
2413 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2414 finderArgs, this);
2415
2416 if ((list != null) && !list.isEmpty()) {
2417 for (AssetCategory assetCategory : list) {
2418 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2419 list = null;
2420
2421 break;
2422 }
2423 }
2424 }
2425
2426 if (list == null) {
2427 StringBundler query = null;
2428
2429 if (orderByComparator != null) {
2430 query = new StringBundler(3 +
2431 (orderByComparator.getOrderByFields().length * 3));
2432 }
2433 else {
2434 query = new StringBundler(3);
2435 }
2436
2437 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2438
2439 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2440
2441 if (orderByComparator != null) {
2442 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2443 orderByComparator);
2444 }
2445
2446 else {
2447 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2448 }
2449
2450 String sql = query.toString();
2451
2452 Session session = null;
2453
2454 try {
2455 session = openSession();
2456
2457 Query q = session.createQuery(sql);
2458
2459 QueryPos qPos = QueryPos.getInstance(q);
2460
2461 qPos.add(parentCategoryId);
2462
2463 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2464 start, end);
2465 }
2466 catch (Exception e) {
2467 throw processException(e);
2468 }
2469 finally {
2470 if (list == null) {
2471 FinderCacheUtil.removeResult(finderPath, finderArgs);
2472 }
2473 else {
2474 cacheResult(list);
2475
2476 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2477 }
2478
2479 closeSession(session);
2480 }
2481 }
2482
2483 return list;
2484 }
2485
2486
2495 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2496 OrderByComparator orderByComparator)
2497 throws NoSuchCategoryException, SystemException {
2498 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2499 orderByComparator);
2500
2501 if (assetCategory != null) {
2502 return assetCategory;
2503 }
2504
2505 StringBundler msg = new StringBundler(4);
2506
2507 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2508
2509 msg.append("parentCategoryId=");
2510 msg.append(parentCategoryId);
2511
2512 msg.append(StringPool.CLOSE_CURLY_BRACE);
2513
2514 throw new NoSuchCategoryException(msg.toString());
2515 }
2516
2517
2525 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2526 OrderByComparator orderByComparator) throws SystemException {
2527 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2528 1, orderByComparator);
2529
2530 if (!list.isEmpty()) {
2531 return list.get(0);
2532 }
2533
2534 return null;
2535 }
2536
2537
2546 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2547 OrderByComparator orderByComparator)
2548 throws NoSuchCategoryException, SystemException {
2549 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2550 orderByComparator);
2551
2552 if (assetCategory != null) {
2553 return assetCategory;
2554 }
2555
2556 StringBundler msg = new StringBundler(4);
2557
2558 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2559
2560 msg.append("parentCategoryId=");
2561 msg.append(parentCategoryId);
2562
2563 msg.append(StringPool.CLOSE_CURLY_BRACE);
2564
2565 throw new NoSuchCategoryException(msg.toString());
2566 }
2567
2568
2576 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2577 OrderByComparator orderByComparator) throws SystemException {
2578 int count = countByParentCategoryId(parentCategoryId);
2579
2580 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2581 count - 1, count, orderByComparator);
2582
2583 if (!list.isEmpty()) {
2584 return list.get(0);
2585 }
2586
2587 return null;
2588 }
2589
2590
2600 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2601 long parentCategoryId, OrderByComparator orderByComparator)
2602 throws NoSuchCategoryException, SystemException {
2603 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2604
2605 Session session = null;
2606
2607 try {
2608 session = openSession();
2609
2610 AssetCategory[] array = new AssetCategoryImpl[3];
2611
2612 array[0] = getByParentCategoryId_PrevAndNext(session,
2613 assetCategory, parentCategoryId, orderByComparator, true);
2614
2615 array[1] = assetCategory;
2616
2617 array[2] = getByParentCategoryId_PrevAndNext(session,
2618 assetCategory, parentCategoryId, orderByComparator, false);
2619
2620 return array;
2621 }
2622 catch (Exception e) {
2623 throw processException(e);
2624 }
2625 finally {
2626 closeSession(session);
2627 }
2628 }
2629
2630 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2631 AssetCategory assetCategory, long parentCategoryId,
2632 OrderByComparator orderByComparator, boolean previous) {
2633 StringBundler query = null;
2634
2635 if (orderByComparator != null) {
2636 query = new StringBundler(6 +
2637 (orderByComparator.getOrderByFields().length * 6));
2638 }
2639 else {
2640 query = new StringBundler(3);
2641 }
2642
2643 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2644
2645 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2646
2647 if (orderByComparator != null) {
2648 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2649
2650 if (orderByConditionFields.length > 0) {
2651 query.append(WHERE_AND);
2652 }
2653
2654 for (int i = 0; i < orderByConditionFields.length; i++) {
2655 query.append(_ORDER_BY_ENTITY_ALIAS);
2656 query.append(orderByConditionFields[i]);
2657
2658 if ((i + 1) < orderByConditionFields.length) {
2659 if (orderByComparator.isAscending() ^ previous) {
2660 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2661 }
2662 else {
2663 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2664 }
2665 }
2666 else {
2667 if (orderByComparator.isAscending() ^ previous) {
2668 query.append(WHERE_GREATER_THAN);
2669 }
2670 else {
2671 query.append(WHERE_LESSER_THAN);
2672 }
2673 }
2674 }
2675
2676 query.append(ORDER_BY_CLAUSE);
2677
2678 String[] orderByFields = orderByComparator.getOrderByFields();
2679
2680 for (int i = 0; i < orderByFields.length; i++) {
2681 query.append(_ORDER_BY_ENTITY_ALIAS);
2682 query.append(orderByFields[i]);
2683
2684 if ((i + 1) < orderByFields.length) {
2685 if (orderByComparator.isAscending() ^ previous) {
2686 query.append(ORDER_BY_ASC_HAS_NEXT);
2687 }
2688 else {
2689 query.append(ORDER_BY_DESC_HAS_NEXT);
2690 }
2691 }
2692 else {
2693 if (orderByComparator.isAscending() ^ previous) {
2694 query.append(ORDER_BY_ASC);
2695 }
2696 else {
2697 query.append(ORDER_BY_DESC);
2698 }
2699 }
2700 }
2701 }
2702
2703 else {
2704 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2705 }
2706
2707 String sql = query.toString();
2708
2709 Query q = session.createQuery(sql);
2710
2711 q.setFirstResult(0);
2712 q.setMaxResults(2);
2713
2714 QueryPos qPos = QueryPos.getInstance(q);
2715
2716 qPos.add(parentCategoryId);
2717
2718 if (orderByComparator != null) {
2719 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2720
2721 for (Object value : values) {
2722 qPos.add(value);
2723 }
2724 }
2725
2726 List<AssetCategory> list = q.list();
2727
2728 if (list.size() == 2) {
2729 return list.get(1);
2730 }
2731 else {
2732 return null;
2733 }
2734 }
2735
2736
2743 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2744 throws SystemException {
2745 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2746 QueryUtil.ALL_POS, null);
2747 }
2748
2749
2762 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2763 int end) throws SystemException {
2764 return findByVocabularyId(vocabularyId, start, end, null);
2765 }
2766
2767
2781 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2782 int end, OrderByComparator orderByComparator) throws SystemException {
2783 FinderPath finderPath = null;
2784 Object[] finderArgs = null;
2785
2786 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2787 (orderByComparator == null)) {
2788 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2789 finderArgs = new Object[] { vocabularyId };
2790 }
2791 else {
2792 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2793 finderArgs = new Object[] {
2794 vocabularyId,
2795
2796 start, end, orderByComparator
2797 };
2798 }
2799
2800 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2801 finderArgs, this);
2802
2803 if ((list != null) && !list.isEmpty()) {
2804 for (AssetCategory assetCategory : list) {
2805 if ((vocabularyId != assetCategory.getVocabularyId())) {
2806 list = null;
2807
2808 break;
2809 }
2810 }
2811 }
2812
2813 if (list == null) {
2814 StringBundler query = null;
2815
2816 if (orderByComparator != null) {
2817 query = new StringBundler(3 +
2818 (orderByComparator.getOrderByFields().length * 3));
2819 }
2820 else {
2821 query = new StringBundler(3);
2822 }
2823
2824 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2825
2826 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2827
2828 if (orderByComparator != null) {
2829 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2830 orderByComparator);
2831 }
2832
2833 else {
2834 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2835 }
2836
2837 String sql = query.toString();
2838
2839 Session session = null;
2840
2841 try {
2842 session = openSession();
2843
2844 Query q = session.createQuery(sql);
2845
2846 QueryPos qPos = QueryPos.getInstance(q);
2847
2848 qPos.add(vocabularyId);
2849
2850 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2851 start, end);
2852 }
2853 catch (Exception e) {
2854 throw processException(e);
2855 }
2856 finally {
2857 if (list == null) {
2858 FinderCacheUtil.removeResult(finderPath, finderArgs);
2859 }
2860 else {
2861 cacheResult(list);
2862
2863 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2864 }
2865
2866 closeSession(session);
2867 }
2868 }
2869
2870 return list;
2871 }
2872
2873
2882 public AssetCategory findByVocabularyId_First(long vocabularyId,
2883 OrderByComparator orderByComparator)
2884 throws NoSuchCategoryException, SystemException {
2885 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
2886 orderByComparator);
2887
2888 if (assetCategory != null) {
2889 return assetCategory;
2890 }
2891
2892 StringBundler msg = new StringBundler(4);
2893
2894 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2895
2896 msg.append("vocabularyId=");
2897 msg.append(vocabularyId);
2898
2899 msg.append(StringPool.CLOSE_CURLY_BRACE);
2900
2901 throw new NoSuchCategoryException(msg.toString());
2902 }
2903
2904
2912 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
2913 OrderByComparator orderByComparator) throws SystemException {
2914 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2915 orderByComparator);
2916
2917 if (!list.isEmpty()) {
2918 return list.get(0);
2919 }
2920
2921 return null;
2922 }
2923
2924
2933 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2934 OrderByComparator orderByComparator)
2935 throws NoSuchCategoryException, SystemException {
2936 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
2937 orderByComparator);
2938
2939 if (assetCategory != null) {
2940 return assetCategory;
2941 }
2942
2943 StringBundler msg = new StringBundler(4);
2944
2945 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2946
2947 msg.append("vocabularyId=");
2948 msg.append(vocabularyId);
2949
2950 msg.append(StringPool.CLOSE_CURLY_BRACE);
2951
2952 throw new NoSuchCategoryException(msg.toString());
2953 }
2954
2955
2963 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
2964 OrderByComparator orderByComparator) throws SystemException {
2965 int count = countByVocabularyId(vocabularyId);
2966
2967 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2968 count, orderByComparator);
2969
2970 if (!list.isEmpty()) {
2971 return list.get(0);
2972 }
2973
2974 return null;
2975 }
2976
2977
2987 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2988 long vocabularyId, OrderByComparator orderByComparator)
2989 throws NoSuchCategoryException, SystemException {
2990 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2991
2992 Session session = null;
2993
2994 try {
2995 session = openSession();
2996
2997 AssetCategory[] array = new AssetCategoryImpl[3];
2998
2999 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3000 vocabularyId, orderByComparator, true);
3001
3002 array[1] = assetCategory;
3003
3004 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3005 vocabularyId, orderByComparator, false);
3006
3007 return array;
3008 }
3009 catch (Exception e) {
3010 throw processException(e);
3011 }
3012 finally {
3013 closeSession(session);
3014 }
3015 }
3016
3017 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3018 AssetCategory assetCategory, long vocabularyId,
3019 OrderByComparator orderByComparator, boolean previous) {
3020 StringBundler query = null;
3021
3022 if (orderByComparator != null) {
3023 query = new StringBundler(6 +
3024 (orderByComparator.getOrderByFields().length * 6));
3025 }
3026 else {
3027 query = new StringBundler(3);
3028 }
3029
3030 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3031
3032 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3033
3034 if (orderByComparator != null) {
3035 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3036
3037 if (orderByConditionFields.length > 0) {
3038 query.append(WHERE_AND);
3039 }
3040
3041 for (int i = 0; i < orderByConditionFields.length; i++) {
3042 query.append(_ORDER_BY_ENTITY_ALIAS);
3043 query.append(orderByConditionFields[i]);
3044
3045 if ((i + 1) < orderByConditionFields.length) {
3046 if (orderByComparator.isAscending() ^ previous) {
3047 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3048 }
3049 else {
3050 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3051 }
3052 }
3053 else {
3054 if (orderByComparator.isAscending() ^ previous) {
3055 query.append(WHERE_GREATER_THAN);
3056 }
3057 else {
3058 query.append(WHERE_LESSER_THAN);
3059 }
3060 }
3061 }
3062
3063 query.append(ORDER_BY_CLAUSE);
3064
3065 String[] orderByFields = orderByComparator.getOrderByFields();
3066
3067 for (int i = 0; i < orderByFields.length; i++) {
3068 query.append(_ORDER_BY_ENTITY_ALIAS);
3069 query.append(orderByFields[i]);
3070
3071 if ((i + 1) < orderByFields.length) {
3072 if (orderByComparator.isAscending() ^ previous) {
3073 query.append(ORDER_BY_ASC_HAS_NEXT);
3074 }
3075 else {
3076 query.append(ORDER_BY_DESC_HAS_NEXT);
3077 }
3078 }
3079 else {
3080 if (orderByComparator.isAscending() ^ previous) {
3081 query.append(ORDER_BY_ASC);
3082 }
3083 else {
3084 query.append(ORDER_BY_DESC);
3085 }
3086 }
3087 }
3088 }
3089
3090 else {
3091 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3092 }
3093
3094 String sql = query.toString();
3095
3096 Query q = session.createQuery(sql);
3097
3098 q.setFirstResult(0);
3099 q.setMaxResults(2);
3100
3101 QueryPos qPos = QueryPos.getInstance(q);
3102
3103 qPos.add(vocabularyId);
3104
3105 if (orderByComparator != null) {
3106 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3107
3108 for (Object value : values) {
3109 qPos.add(value);
3110 }
3111 }
3112
3113 List<AssetCategory> list = q.list();
3114
3115 if (list.size() == 2) {
3116 return list.get(1);
3117 }
3118 else {
3119 return null;
3120 }
3121 }
3122
3123
3131 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3132 throws SystemException {
3133 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3134 QueryUtil.ALL_POS, null);
3135 }
3136
3137
3151 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3152 int start, int end) throws SystemException {
3153 return findByG_V(groupId, vocabularyId, start, end, null);
3154 }
3155
3156
3171 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3172 int start, int end, OrderByComparator orderByComparator)
3173 throws SystemException {
3174 FinderPath finderPath = null;
3175 Object[] finderArgs = null;
3176
3177 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3178 (orderByComparator == null)) {
3179 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3180 finderArgs = new Object[] { groupId, vocabularyId };
3181 }
3182 else {
3183 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3184 finderArgs = new Object[] {
3185 groupId, vocabularyId,
3186
3187 start, end, orderByComparator
3188 };
3189 }
3190
3191 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3192 finderArgs, this);
3193
3194 if ((list != null) && !list.isEmpty()) {
3195 for (AssetCategory assetCategory : list) {
3196 if ((groupId != assetCategory.getGroupId()) ||
3197 (vocabularyId != assetCategory.getVocabularyId())) {
3198 list = null;
3199
3200 break;
3201 }
3202 }
3203 }
3204
3205 if (list == null) {
3206 StringBundler query = null;
3207
3208 if (orderByComparator != null) {
3209 query = new StringBundler(4 +
3210 (orderByComparator.getOrderByFields().length * 3));
3211 }
3212 else {
3213 query = new StringBundler(4);
3214 }
3215
3216 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3217
3218 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3219
3220 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3221
3222 if (orderByComparator != null) {
3223 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3224 orderByComparator);
3225 }
3226
3227 else {
3228 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3229 }
3230
3231 String sql = query.toString();
3232
3233 Session session = null;
3234
3235 try {
3236 session = openSession();
3237
3238 Query q = session.createQuery(sql);
3239
3240 QueryPos qPos = QueryPos.getInstance(q);
3241
3242 qPos.add(groupId);
3243
3244 qPos.add(vocabularyId);
3245
3246 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3247 start, end);
3248 }
3249 catch (Exception e) {
3250 throw processException(e);
3251 }
3252 finally {
3253 if (list == null) {
3254 FinderCacheUtil.removeResult(finderPath, finderArgs);
3255 }
3256 else {
3257 cacheResult(list);
3258
3259 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3260 }
3261
3262 closeSession(session);
3263 }
3264 }
3265
3266 return list;
3267 }
3268
3269
3279 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3280 OrderByComparator orderByComparator)
3281 throws NoSuchCategoryException, SystemException {
3282 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3283 orderByComparator);
3284
3285 if (assetCategory != null) {
3286 return assetCategory;
3287 }
3288
3289 StringBundler msg = new StringBundler(6);
3290
3291 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3292
3293 msg.append("groupId=");
3294 msg.append(groupId);
3295
3296 msg.append(", vocabularyId=");
3297 msg.append(vocabularyId);
3298
3299 msg.append(StringPool.CLOSE_CURLY_BRACE);
3300
3301 throw new NoSuchCategoryException(msg.toString());
3302 }
3303
3304
3313 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3314 OrderByComparator orderByComparator) throws SystemException {
3315 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3316 orderByComparator);
3317
3318 if (!list.isEmpty()) {
3319 return list.get(0);
3320 }
3321
3322 return null;
3323 }
3324
3325
3335 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3336 OrderByComparator orderByComparator)
3337 throws NoSuchCategoryException, SystemException {
3338 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3339 orderByComparator);
3340
3341 if (assetCategory != null) {
3342 return assetCategory;
3343 }
3344
3345 StringBundler msg = new StringBundler(6);
3346
3347 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3348
3349 msg.append("groupId=");
3350 msg.append(groupId);
3351
3352 msg.append(", vocabularyId=");
3353 msg.append(vocabularyId);
3354
3355 msg.append(StringPool.CLOSE_CURLY_BRACE);
3356
3357 throw new NoSuchCategoryException(msg.toString());
3358 }
3359
3360
3369 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3370 OrderByComparator orderByComparator) throws SystemException {
3371 int count = countByG_V(groupId, vocabularyId);
3372
3373 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3374 count, orderByComparator);
3375
3376 if (!list.isEmpty()) {
3377 return list.get(0);
3378 }
3379
3380 return null;
3381 }
3382
3383
3394 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3395 long vocabularyId, OrderByComparator orderByComparator)
3396 throws NoSuchCategoryException, SystemException {
3397 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3398
3399 Session session = null;
3400
3401 try {
3402 session = openSession();
3403
3404 AssetCategory[] array = new AssetCategoryImpl[3];
3405
3406 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3407 vocabularyId, orderByComparator, true);
3408
3409 array[1] = assetCategory;
3410
3411 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3412 vocabularyId, orderByComparator, false);
3413
3414 return array;
3415 }
3416 catch (Exception e) {
3417 throw processException(e);
3418 }
3419 finally {
3420 closeSession(session);
3421 }
3422 }
3423
3424 protected AssetCategory getByG_V_PrevAndNext(Session session,
3425 AssetCategory assetCategory, long groupId, long vocabularyId,
3426 OrderByComparator orderByComparator, boolean previous) {
3427 StringBundler query = null;
3428
3429 if (orderByComparator != null) {
3430 query = new StringBundler(6 +
3431 (orderByComparator.getOrderByFields().length * 6));
3432 }
3433 else {
3434 query = new StringBundler(3);
3435 }
3436
3437 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3438
3439 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3440
3441 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3442
3443 if (orderByComparator != null) {
3444 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3445
3446 if (orderByConditionFields.length > 0) {
3447 query.append(WHERE_AND);
3448 }
3449
3450 for (int i = 0; i < orderByConditionFields.length; i++) {
3451 query.append(_ORDER_BY_ENTITY_ALIAS);
3452 query.append(orderByConditionFields[i]);
3453
3454 if ((i + 1) < orderByConditionFields.length) {
3455 if (orderByComparator.isAscending() ^ previous) {
3456 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3457 }
3458 else {
3459 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3460 }
3461 }
3462 else {
3463 if (orderByComparator.isAscending() ^ previous) {
3464 query.append(WHERE_GREATER_THAN);
3465 }
3466 else {
3467 query.append(WHERE_LESSER_THAN);
3468 }
3469 }
3470 }
3471
3472 query.append(ORDER_BY_CLAUSE);
3473
3474 String[] orderByFields = orderByComparator.getOrderByFields();
3475
3476 for (int i = 0; i < orderByFields.length; i++) {
3477 query.append(_ORDER_BY_ENTITY_ALIAS);
3478 query.append(orderByFields[i]);
3479
3480 if ((i + 1) < orderByFields.length) {
3481 if (orderByComparator.isAscending() ^ previous) {
3482 query.append(ORDER_BY_ASC_HAS_NEXT);
3483 }
3484 else {
3485 query.append(ORDER_BY_DESC_HAS_NEXT);
3486 }
3487 }
3488 else {
3489 if (orderByComparator.isAscending() ^ previous) {
3490 query.append(ORDER_BY_ASC);
3491 }
3492 else {
3493 query.append(ORDER_BY_DESC);
3494 }
3495 }
3496 }
3497 }
3498
3499 else {
3500 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3501 }
3502
3503 String sql = query.toString();
3504
3505 Query q = session.createQuery(sql);
3506
3507 q.setFirstResult(0);
3508 q.setMaxResults(2);
3509
3510 QueryPos qPos = QueryPos.getInstance(q);
3511
3512 qPos.add(groupId);
3513
3514 qPos.add(vocabularyId);
3515
3516 if (orderByComparator != null) {
3517 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3518
3519 for (Object value : values) {
3520 qPos.add(value);
3521 }
3522 }
3523
3524 List<AssetCategory> list = q.list();
3525
3526 if (list.size() == 2) {
3527 return list.get(1);
3528 }
3529 else {
3530 return null;
3531 }
3532 }
3533
3534
3546 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
3547 throws SystemException {
3548 return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
3549 QueryUtil.ALL_POS, null);
3550 }
3551
3552
3566 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
3567 int start, int end) throws SystemException {
3568 return findByG_V(groupId, vocabularyIds, start, end, null);
3569 }
3570
3571
3586 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
3587 int start, int end, OrderByComparator orderByComparator)
3588 throws SystemException {
3589 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3590 Object[] finderArgs = null;
3591
3592 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3593 (orderByComparator == null)) {
3594 finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
3595 }
3596 else {
3597 finderArgs = new Object[] {
3598 groupId, StringUtil.merge(vocabularyIds),
3599
3600 start, end, orderByComparator
3601 };
3602 }
3603
3604 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3605 finderArgs, this);
3606
3607 if ((list != null) && !list.isEmpty()) {
3608 for (AssetCategory assetCategory : list) {
3609 if ((groupId != assetCategory.getGroupId()) ||
3610 !ArrayUtil.contains(vocabularyIds,
3611 assetCategory.getVocabularyId())) {
3612 list = null;
3613
3614 break;
3615 }
3616 }
3617 }
3618
3619 if (list == null) {
3620 StringBundler query = new StringBundler();
3621
3622 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3623
3624 boolean conjunctionable = false;
3625
3626 if (conjunctionable) {
3627 query.append(WHERE_AND);
3628 }
3629
3630 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
3631
3632 conjunctionable = true;
3633
3634 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
3635 if (conjunctionable) {
3636 query.append(WHERE_AND);
3637 }
3638
3639 query.append(StringPool.OPEN_PARENTHESIS);
3640
3641 for (int i = 0; i < vocabularyIds.length; i++) {
3642 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
3643
3644 if ((i + 1) < vocabularyIds.length) {
3645 query.append(WHERE_OR);
3646 }
3647 }
3648
3649 query.append(StringPool.CLOSE_PARENTHESIS);
3650
3651 conjunctionable = true;
3652 }
3653
3654 if (orderByComparator != null) {
3655 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3656 orderByComparator);
3657 }
3658
3659 else {
3660 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3661 }
3662
3663 String sql = query.toString();
3664
3665 Session session = null;
3666
3667 try {
3668 session = openSession();
3669
3670 Query q = session.createQuery(sql);
3671
3672 QueryPos qPos = QueryPos.getInstance(q);
3673
3674 qPos.add(groupId);
3675
3676 if (vocabularyIds != null) {
3677 qPos.add(vocabularyIds);
3678 }
3679
3680 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3681 start, end);
3682 }
3683 catch (Exception e) {
3684 throw processException(e);
3685 }
3686 finally {
3687 if (list == null) {
3688 FinderCacheUtil.removeResult(finderPath, finderArgs);
3689 }
3690 else {
3691 cacheResult(list);
3692
3693 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3694 }
3695
3696 closeSession(session);
3697 }
3698 }
3699
3700 return list;
3701 }
3702
3703
3711 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3712 throws SystemException {
3713 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3714 QueryUtil.ALL_POS, null);
3715 }
3716
3717
3731 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3732 int start, int end) throws SystemException {
3733 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3734 }
3735
3736
3751 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3752 int start, int end, OrderByComparator orderByComparator)
3753 throws SystemException {
3754 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3755 return findByG_V(groupId, vocabularyId, start, end,
3756 orderByComparator);
3757 }
3758
3759 StringBundler query = null;
3760
3761 if (orderByComparator != null) {
3762 query = new StringBundler(4 +
3763 (orderByComparator.getOrderByFields().length * 3));
3764 }
3765 else {
3766 query = new StringBundler(4);
3767 }
3768
3769 if (getDB().isSupportsInlineDistinct()) {
3770 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3771 }
3772 else {
3773 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3774 }
3775
3776 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3777
3778 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3779
3780 if (!getDB().isSupportsInlineDistinct()) {
3781 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3782 }
3783
3784 if (orderByComparator != null) {
3785 if (getDB().isSupportsInlineDistinct()) {
3786 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3787 orderByComparator);
3788 }
3789 else {
3790 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3791 orderByComparator);
3792 }
3793 }
3794
3795 else {
3796 if (getDB().isSupportsInlineDistinct()) {
3797 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3798 }
3799 else {
3800 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3801 }
3802 }
3803
3804 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3805 AssetCategory.class.getName(),
3806 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3807
3808 Session session = null;
3809
3810 try {
3811 session = openSession();
3812
3813 SQLQuery q = session.createSQLQuery(sql);
3814
3815 if (getDB().isSupportsInlineDistinct()) {
3816 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3817 }
3818 else {
3819 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3820 }
3821
3822 QueryPos qPos = QueryPos.getInstance(q);
3823
3824 qPos.add(groupId);
3825
3826 qPos.add(vocabularyId);
3827
3828 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3829 end);
3830 }
3831 catch (Exception e) {
3832 throw processException(e);
3833 }
3834 finally {
3835 closeSession(session);
3836 }
3837 }
3838
3839
3850 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3851 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3852 throws NoSuchCategoryException, SystemException {
3853 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3854 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3855 orderByComparator);
3856 }
3857
3858 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3859
3860 Session session = null;
3861
3862 try {
3863 session = openSession();
3864
3865 AssetCategory[] array = new AssetCategoryImpl[3];
3866
3867 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3868 groupId, vocabularyId, orderByComparator, true);
3869
3870 array[1] = assetCategory;
3871
3872 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3873 groupId, vocabularyId, orderByComparator, false);
3874
3875 return array;
3876 }
3877 catch (Exception e) {
3878 throw processException(e);
3879 }
3880 finally {
3881 closeSession(session);
3882 }
3883 }
3884
3885 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3886 AssetCategory assetCategory, long groupId, long vocabularyId,
3887 OrderByComparator orderByComparator, boolean previous) {
3888 StringBundler query = null;
3889
3890 if (orderByComparator != null) {
3891 query = new StringBundler(6 +
3892 (orderByComparator.getOrderByFields().length * 6));
3893 }
3894 else {
3895 query = new StringBundler(3);
3896 }
3897
3898 if (getDB().isSupportsInlineDistinct()) {
3899 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3900 }
3901 else {
3902 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3903 }
3904
3905 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3906
3907 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3908
3909 if (!getDB().isSupportsInlineDistinct()) {
3910 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3911 }
3912
3913 if (orderByComparator != null) {
3914 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3915
3916 if (orderByConditionFields.length > 0) {
3917 query.append(WHERE_AND);
3918 }
3919
3920 for (int i = 0; i < orderByConditionFields.length; i++) {
3921 if (getDB().isSupportsInlineDistinct()) {
3922 query.append(_ORDER_BY_ENTITY_ALIAS);
3923 }
3924 else {
3925 query.append(_ORDER_BY_ENTITY_TABLE);
3926 }
3927
3928 query.append(orderByConditionFields[i]);
3929
3930 if ((i + 1) < orderByConditionFields.length) {
3931 if (orderByComparator.isAscending() ^ previous) {
3932 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3933 }
3934 else {
3935 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3936 }
3937 }
3938 else {
3939 if (orderByComparator.isAscending() ^ previous) {
3940 query.append(WHERE_GREATER_THAN);
3941 }
3942 else {
3943 query.append(WHERE_LESSER_THAN);
3944 }
3945 }
3946 }
3947
3948 query.append(ORDER_BY_CLAUSE);
3949
3950 String[] orderByFields = orderByComparator.getOrderByFields();
3951
3952 for (int i = 0; i < orderByFields.length; i++) {
3953 if (getDB().isSupportsInlineDistinct()) {
3954 query.append(_ORDER_BY_ENTITY_ALIAS);
3955 }
3956 else {
3957 query.append(_ORDER_BY_ENTITY_TABLE);
3958 }
3959
3960 query.append(orderByFields[i]);
3961
3962 if ((i + 1) < orderByFields.length) {
3963 if (orderByComparator.isAscending() ^ previous) {
3964 query.append(ORDER_BY_ASC_HAS_NEXT);
3965 }
3966 else {
3967 query.append(ORDER_BY_DESC_HAS_NEXT);
3968 }
3969 }
3970 else {
3971 if (orderByComparator.isAscending() ^ previous) {
3972 query.append(ORDER_BY_ASC);
3973 }
3974 else {
3975 query.append(ORDER_BY_DESC);
3976 }
3977 }
3978 }
3979 }
3980
3981 else {
3982 if (getDB().isSupportsInlineDistinct()) {
3983 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3984 }
3985 else {
3986 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3987 }
3988 }
3989
3990 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3991 AssetCategory.class.getName(),
3992 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3993
3994 SQLQuery q = session.createSQLQuery(sql);
3995
3996 q.setFirstResult(0);
3997 q.setMaxResults(2);
3998
3999 if (getDB().isSupportsInlineDistinct()) {
4000 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4001 }
4002 else {
4003 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4004 }
4005
4006 QueryPos qPos = QueryPos.getInstance(q);
4007
4008 qPos.add(groupId);
4009
4010 qPos.add(vocabularyId);
4011
4012 if (orderByComparator != null) {
4013 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4014
4015 for (Object value : values) {
4016 qPos.add(value);
4017 }
4018 }
4019
4020 List<AssetCategory> list = q.list();
4021
4022 if (list.size() == 2) {
4023 return list.get(1);
4024 }
4025 else {
4026 return null;
4027 }
4028 }
4029
4030
4038 public List<AssetCategory> filterFindByG_V(long groupId,
4039 long[] vocabularyIds) throws SystemException {
4040 return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4041 QueryUtil.ALL_POS, null);
4042 }
4043
4044
4058 public List<AssetCategory> filterFindByG_V(long groupId,
4059 long[] vocabularyIds, int start, int end) throws SystemException {
4060 return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4061 }
4062
4063
4078 public List<AssetCategory> filterFindByG_V(long groupId,
4079 long[] vocabularyIds, int start, int end,
4080 OrderByComparator orderByComparator) throws SystemException {
4081 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4082 return findByG_V(groupId, vocabularyIds, start, end,
4083 orderByComparator);
4084 }
4085
4086 StringBundler query = new StringBundler();
4087
4088 if (getDB().isSupportsInlineDistinct()) {
4089 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4090 }
4091 else {
4092 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4093 }
4094
4095 boolean conjunctionable = false;
4096
4097 if (conjunctionable) {
4098 query.append(WHERE_AND);
4099 }
4100
4101 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4102
4103 conjunctionable = true;
4104
4105 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4106 if (conjunctionable) {
4107 query.append(WHERE_AND);
4108 }
4109
4110 query.append(StringPool.OPEN_PARENTHESIS);
4111
4112 for (int i = 0; i < vocabularyIds.length; i++) {
4113 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4114
4115 if ((i + 1) < vocabularyIds.length) {
4116 query.append(WHERE_OR);
4117 }
4118 }
4119
4120 query.append(StringPool.CLOSE_PARENTHESIS);
4121
4122 conjunctionable = true;
4123 }
4124
4125 if (!getDB().isSupportsInlineDistinct()) {
4126 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4127 }
4128
4129 if (orderByComparator != null) {
4130 if (getDB().isSupportsInlineDistinct()) {
4131 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4132 orderByComparator);
4133 }
4134 else {
4135 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4136 orderByComparator);
4137 }
4138 }
4139
4140 else {
4141 if (getDB().isSupportsInlineDistinct()) {
4142 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4143 }
4144 else {
4145 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4146 }
4147 }
4148
4149 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4150 AssetCategory.class.getName(),
4151 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4152
4153 Session session = null;
4154
4155 try {
4156 session = openSession();
4157
4158 SQLQuery q = session.createSQLQuery(sql);
4159
4160 if (getDB().isSupportsInlineDistinct()) {
4161 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4162 }
4163 else {
4164 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4165 }
4166
4167 QueryPos qPos = QueryPos.getInstance(q);
4168
4169 qPos.add(groupId);
4170
4171 if (vocabularyIds != null) {
4172 qPos.add(vocabularyIds);
4173 }
4174
4175 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4176 end);
4177 }
4178 catch (Exception e) {
4179 throw processException(e);
4180 }
4181 finally {
4182 closeSession(session);
4183 }
4184 }
4185
4186
4194 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4195 throws SystemException {
4196 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4197 QueryUtil.ALL_POS, null);
4198 }
4199
4200
4214 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4215 int start, int end) throws SystemException {
4216 return findByP_N(parentCategoryId, name, start, end, null);
4217 }
4218
4219
4234 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4235 int start, int end, OrderByComparator orderByComparator)
4236 throws SystemException {
4237 FinderPath finderPath = null;
4238 Object[] finderArgs = null;
4239
4240 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4241 (orderByComparator == null)) {
4242 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4243 finderArgs = new Object[] { parentCategoryId, name };
4244 }
4245 else {
4246 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4247 finderArgs = new Object[] {
4248 parentCategoryId, name,
4249
4250 start, end, orderByComparator
4251 };
4252 }
4253
4254 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4255 finderArgs, this);
4256
4257 if ((list != null) && !list.isEmpty()) {
4258 for (AssetCategory assetCategory : list) {
4259 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4260 !Validator.equals(name, assetCategory.getName())) {
4261 list = null;
4262
4263 break;
4264 }
4265 }
4266 }
4267
4268 if (list == null) {
4269 StringBundler query = null;
4270
4271 if (orderByComparator != null) {
4272 query = new StringBundler(4 +
4273 (orderByComparator.getOrderByFields().length * 3));
4274 }
4275 else {
4276 query = new StringBundler(4);
4277 }
4278
4279 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4280
4281 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4282
4283 if (name == null) {
4284 query.append(_FINDER_COLUMN_P_N_NAME_1);
4285 }
4286 else {
4287 if (name.equals(StringPool.BLANK)) {
4288 query.append(_FINDER_COLUMN_P_N_NAME_3);
4289 }
4290 else {
4291 query.append(_FINDER_COLUMN_P_N_NAME_2);
4292 }
4293 }
4294
4295 if (orderByComparator != null) {
4296 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4297 orderByComparator);
4298 }
4299
4300 else {
4301 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4302 }
4303
4304 String sql = query.toString();
4305
4306 Session session = null;
4307
4308 try {
4309 session = openSession();
4310
4311 Query q = session.createQuery(sql);
4312
4313 QueryPos qPos = QueryPos.getInstance(q);
4314
4315 qPos.add(parentCategoryId);
4316
4317 if (name != null) {
4318 qPos.add(name);
4319 }
4320
4321 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4322 start, end);
4323 }
4324 catch (Exception e) {
4325 throw processException(e);
4326 }
4327 finally {
4328 if (list == null) {
4329 FinderCacheUtil.removeResult(finderPath, finderArgs);
4330 }
4331 else {
4332 cacheResult(list);
4333
4334 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4335 }
4336
4337 closeSession(session);
4338 }
4339 }
4340
4341 return list;
4342 }
4343
4344
4354 public AssetCategory findByP_N_First(long parentCategoryId, String name,
4355 OrderByComparator orderByComparator)
4356 throws NoSuchCategoryException, SystemException {
4357 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4358 orderByComparator);
4359
4360 if (assetCategory != null) {
4361 return assetCategory;
4362 }
4363
4364 StringBundler msg = new StringBundler(6);
4365
4366 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4367
4368 msg.append("parentCategoryId=");
4369 msg.append(parentCategoryId);
4370
4371 msg.append(", name=");
4372 msg.append(name);
4373
4374 msg.append(StringPool.CLOSE_CURLY_BRACE);
4375
4376 throw new NoSuchCategoryException(msg.toString());
4377 }
4378
4379
4388 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
4389 OrderByComparator orderByComparator) throws SystemException {
4390 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
4391 orderByComparator);
4392
4393 if (!list.isEmpty()) {
4394 return list.get(0);
4395 }
4396
4397 return null;
4398 }
4399
4400
4410 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
4411 OrderByComparator orderByComparator)
4412 throws NoSuchCategoryException, SystemException {
4413 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
4414 orderByComparator);
4415
4416 if (assetCategory != null) {
4417 return assetCategory;
4418 }
4419
4420 StringBundler msg = new StringBundler(6);
4421
4422 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4423
4424 msg.append("parentCategoryId=");
4425 msg.append(parentCategoryId);
4426
4427 msg.append(", name=");
4428 msg.append(name);
4429
4430 msg.append(StringPool.CLOSE_CURLY_BRACE);
4431
4432 throw new NoSuchCategoryException(msg.toString());
4433 }
4434
4435
4444 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4445 OrderByComparator orderByComparator) throws SystemException {
4446 int count = countByP_N(parentCategoryId, name);
4447
4448 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4449 count, orderByComparator);
4450
4451 if (!list.isEmpty()) {
4452 return list.get(0);
4453 }
4454
4455 return null;
4456 }
4457
4458
4469 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4470 long parentCategoryId, String name, OrderByComparator orderByComparator)
4471 throws NoSuchCategoryException, SystemException {
4472 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4473
4474 Session session = null;
4475
4476 try {
4477 session = openSession();
4478
4479 AssetCategory[] array = new AssetCategoryImpl[3];
4480
4481 array[0] = getByP_N_PrevAndNext(session, assetCategory,
4482 parentCategoryId, name, orderByComparator, true);
4483
4484 array[1] = assetCategory;
4485
4486 array[2] = getByP_N_PrevAndNext(session, assetCategory,
4487 parentCategoryId, name, orderByComparator, false);
4488
4489 return array;
4490 }
4491 catch (Exception e) {
4492 throw processException(e);
4493 }
4494 finally {
4495 closeSession(session);
4496 }
4497 }
4498
4499 protected AssetCategory getByP_N_PrevAndNext(Session session,
4500 AssetCategory assetCategory, long parentCategoryId, String name,
4501 OrderByComparator orderByComparator, boolean previous) {
4502 StringBundler query = null;
4503
4504 if (orderByComparator != null) {
4505 query = new StringBundler(6 +
4506 (orderByComparator.getOrderByFields().length * 6));
4507 }
4508 else {
4509 query = new StringBundler(3);
4510 }
4511
4512 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4513
4514 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4515
4516 if (name == null) {
4517 query.append(_FINDER_COLUMN_P_N_NAME_1);
4518 }
4519 else {
4520 if (name.equals(StringPool.BLANK)) {
4521 query.append(_FINDER_COLUMN_P_N_NAME_3);
4522 }
4523 else {
4524 query.append(_FINDER_COLUMN_P_N_NAME_2);
4525 }
4526 }
4527
4528 if (orderByComparator != null) {
4529 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4530
4531 if (orderByConditionFields.length > 0) {
4532 query.append(WHERE_AND);
4533 }
4534
4535 for (int i = 0; i < orderByConditionFields.length; i++) {
4536 query.append(_ORDER_BY_ENTITY_ALIAS);
4537 query.append(orderByConditionFields[i]);
4538
4539 if ((i + 1) < orderByConditionFields.length) {
4540 if (orderByComparator.isAscending() ^ previous) {
4541 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4542 }
4543 else {
4544 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4545 }
4546 }
4547 else {
4548 if (orderByComparator.isAscending() ^ previous) {
4549 query.append(WHERE_GREATER_THAN);
4550 }
4551 else {
4552 query.append(WHERE_LESSER_THAN);
4553 }
4554 }
4555 }
4556
4557 query.append(ORDER_BY_CLAUSE);
4558
4559 String[] orderByFields = orderByComparator.getOrderByFields();
4560
4561 for (int i = 0; i < orderByFields.length; i++) {
4562 query.append(_ORDER_BY_ENTITY_ALIAS);
4563 query.append(orderByFields[i]);
4564
4565 if ((i + 1) < orderByFields.length) {
4566 if (orderByComparator.isAscending() ^ previous) {
4567 query.append(ORDER_BY_ASC_HAS_NEXT);
4568 }
4569 else {
4570 query.append(ORDER_BY_DESC_HAS_NEXT);
4571 }
4572 }
4573 else {
4574 if (orderByComparator.isAscending() ^ previous) {
4575 query.append(ORDER_BY_ASC);
4576 }
4577 else {
4578 query.append(ORDER_BY_DESC);
4579 }
4580 }
4581 }
4582 }
4583
4584 else {
4585 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4586 }
4587
4588 String sql = query.toString();
4589
4590 Query q = session.createQuery(sql);
4591
4592 q.setFirstResult(0);
4593 q.setMaxResults(2);
4594
4595 QueryPos qPos = QueryPos.getInstance(q);
4596
4597 qPos.add(parentCategoryId);
4598
4599 if (name != null) {
4600 qPos.add(name);
4601 }
4602
4603 if (orderByComparator != null) {
4604 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4605
4606 for (Object value : values) {
4607 qPos.add(value);
4608 }
4609 }
4610
4611 List<AssetCategory> list = q.list();
4612
4613 if (list.size() == 2) {
4614 return list.get(1);
4615 }
4616 else {
4617 return null;
4618 }
4619 }
4620
4621
4629 public List<AssetCategory> findByP_V(long parentCategoryId,
4630 long vocabularyId) throws SystemException {
4631 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
4632 QueryUtil.ALL_POS, null);
4633 }
4634
4635
4649 public List<AssetCategory> findByP_V(long parentCategoryId,
4650 long vocabularyId, int start, int end) throws SystemException {
4651 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
4652 }
4653
4654
4669 public List<AssetCategory> findByP_V(long parentCategoryId,
4670 long vocabularyId, int start, int end,
4671 OrderByComparator orderByComparator) throws SystemException {
4672 FinderPath finderPath = null;
4673 Object[] finderArgs = null;
4674
4675 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4676 (orderByComparator == null)) {
4677 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
4678 finderArgs = new Object[] { parentCategoryId, vocabularyId };
4679 }
4680 else {
4681 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
4682 finderArgs = new Object[] {
4683 parentCategoryId, vocabularyId,
4684
4685 start, end, orderByComparator
4686 };
4687 }
4688
4689 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4690 finderArgs, this);
4691
4692 if ((list != null) && !list.isEmpty()) {
4693 for (AssetCategory assetCategory : list) {
4694 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4695 (vocabularyId != assetCategory.getVocabularyId())) {
4696 list = null;
4697
4698 break;
4699 }
4700 }
4701 }
4702
4703 if (list == null) {
4704 StringBundler query = null;
4705
4706 if (orderByComparator != null) {
4707 query = new StringBundler(4 +
4708 (orderByComparator.getOrderByFields().length * 3));
4709 }
4710 else {
4711 query = new StringBundler(4);
4712 }
4713
4714 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4715
4716 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4717
4718 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4719
4720 if (orderByComparator != null) {
4721 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4722 orderByComparator);
4723 }
4724
4725 else {
4726 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4727 }
4728
4729 String sql = query.toString();
4730
4731 Session session = null;
4732
4733 try {
4734 session = openSession();
4735
4736 Query q = session.createQuery(sql);
4737
4738 QueryPos qPos = QueryPos.getInstance(q);
4739
4740 qPos.add(parentCategoryId);
4741
4742 qPos.add(vocabularyId);
4743
4744 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4745 start, end);
4746 }
4747 catch (Exception e) {
4748 throw processException(e);
4749 }
4750 finally {
4751 if (list == null) {
4752 FinderCacheUtil.removeResult(finderPath, finderArgs);
4753 }
4754 else {
4755 cacheResult(list);
4756
4757 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4758 }
4759
4760 closeSession(session);
4761 }
4762 }
4763
4764 return list;
4765 }
4766
4767
4777 public AssetCategory findByP_V_First(long parentCategoryId,
4778 long vocabularyId, OrderByComparator orderByComparator)
4779 throws NoSuchCategoryException, SystemException {
4780 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
4781 vocabularyId, orderByComparator);
4782
4783 if (assetCategory != null) {
4784 return assetCategory;
4785 }
4786
4787 StringBundler msg = new StringBundler(6);
4788
4789 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4790
4791 msg.append("parentCategoryId=");
4792 msg.append(parentCategoryId);
4793
4794 msg.append(", vocabularyId=");
4795 msg.append(vocabularyId);
4796
4797 msg.append(StringPool.CLOSE_CURLY_BRACE);
4798
4799 throw new NoSuchCategoryException(msg.toString());
4800 }
4801
4802
4811 public AssetCategory fetchByP_V_First(long parentCategoryId,
4812 long vocabularyId, OrderByComparator orderByComparator)
4813 throws SystemException {
4814 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4815 1, orderByComparator);
4816
4817 if (!list.isEmpty()) {
4818 return list.get(0);
4819 }
4820
4821 return null;
4822 }
4823
4824
4834 public AssetCategory findByP_V_Last(long parentCategoryId,
4835 long vocabularyId, OrderByComparator orderByComparator)
4836 throws NoSuchCategoryException, SystemException {
4837 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
4838 vocabularyId, orderByComparator);
4839
4840 if (assetCategory != null) {
4841 return assetCategory;
4842 }
4843
4844 StringBundler msg = new StringBundler(6);
4845
4846 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4847
4848 msg.append("parentCategoryId=");
4849 msg.append(parentCategoryId);
4850
4851 msg.append(", vocabularyId=");
4852 msg.append(vocabularyId);
4853
4854 msg.append(StringPool.CLOSE_CURLY_BRACE);
4855
4856 throw new NoSuchCategoryException(msg.toString());
4857 }
4858
4859
4868 public AssetCategory fetchByP_V_Last(long parentCategoryId,
4869 long vocabularyId, OrderByComparator orderByComparator)
4870 throws SystemException {
4871 int count = countByP_V(parentCategoryId, vocabularyId);
4872
4873 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4874 count - 1, count, orderByComparator);
4875
4876 if (!list.isEmpty()) {
4877 return list.get(0);
4878 }
4879
4880 return null;
4881 }
4882
4883
4894 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4895 long parentCategoryId, long vocabularyId,
4896 OrderByComparator orderByComparator)
4897 throws NoSuchCategoryException, SystemException {
4898 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4899
4900 Session session = null;
4901
4902 try {
4903 session = openSession();
4904
4905 AssetCategory[] array = new AssetCategoryImpl[3];
4906
4907 array[0] = getByP_V_PrevAndNext(session, assetCategory,
4908 parentCategoryId, vocabularyId, orderByComparator, true);
4909
4910 array[1] = assetCategory;
4911
4912 array[2] = getByP_V_PrevAndNext(session, assetCategory,
4913 parentCategoryId, vocabularyId, orderByComparator, false);
4914
4915 return array;
4916 }
4917 catch (Exception e) {
4918 throw processException(e);
4919 }
4920 finally {
4921 closeSession(session);
4922 }
4923 }
4924
4925 protected AssetCategory getByP_V_PrevAndNext(Session session,
4926 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4927 OrderByComparator orderByComparator, boolean previous) {
4928 StringBundler query = null;
4929
4930 if (orderByComparator != null) {
4931 query = new StringBundler(6 +
4932 (orderByComparator.getOrderByFields().length * 6));
4933 }
4934 else {
4935 query = new StringBundler(3);
4936 }
4937
4938 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4939
4940 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4941
4942 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4943
4944 if (orderByComparator != null) {
4945 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4946
4947 if (orderByConditionFields.length > 0) {
4948 query.append(WHERE_AND);
4949 }
4950
4951 for (int i = 0; i < orderByConditionFields.length; i++) {
4952 query.append(_ORDER_BY_ENTITY_ALIAS);
4953 query.append(orderByConditionFields[i]);
4954
4955 if ((i + 1) < orderByConditionFields.length) {
4956 if (orderByComparator.isAscending() ^ previous) {
4957 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4958 }
4959 else {
4960 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4961 }
4962 }
4963 else {
4964 if (orderByComparator.isAscending() ^ previous) {
4965 query.append(WHERE_GREATER_THAN);
4966 }
4967 else {
4968 query.append(WHERE_LESSER_THAN);
4969 }
4970 }
4971 }
4972
4973 query.append(ORDER_BY_CLAUSE);
4974
4975 String[] orderByFields = orderByComparator.getOrderByFields();
4976
4977 for (int i = 0; i < orderByFields.length; i++) {
4978 query.append(_ORDER_BY_ENTITY_ALIAS);
4979 query.append(orderByFields[i]);
4980
4981 if ((i + 1) < orderByFields.length) {
4982 if (orderByComparator.isAscending() ^ previous) {
4983 query.append(ORDER_BY_ASC_HAS_NEXT);
4984 }
4985 else {
4986 query.append(ORDER_BY_DESC_HAS_NEXT);
4987 }
4988 }
4989 else {
4990 if (orderByComparator.isAscending() ^ previous) {
4991 query.append(ORDER_BY_ASC);
4992 }
4993 else {
4994 query.append(ORDER_BY_DESC);
4995 }
4996 }
4997 }
4998 }
4999
5000 else {
5001 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5002 }
5003
5004 String sql = query.toString();
5005
5006 Query q = session.createQuery(sql);
5007
5008 q.setFirstResult(0);
5009 q.setMaxResults(2);
5010
5011 QueryPos qPos = QueryPos.getInstance(q);
5012
5013 qPos.add(parentCategoryId);
5014
5015 qPos.add(vocabularyId);
5016
5017 if (orderByComparator != null) {
5018 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5019
5020 for (Object value : values) {
5021 qPos.add(value);
5022 }
5023 }
5024
5025 List<AssetCategory> list = q.list();
5026
5027 if (list.size() == 2) {
5028 return list.get(1);
5029 }
5030 else {
5031 return null;
5032 }
5033 }
5034
5035
5043 public List<AssetCategory> findByN_V(String name, long vocabularyId)
5044 throws SystemException {
5045 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5046 QueryUtil.ALL_POS, null);
5047 }
5048
5049
5063 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5064 int start, int end) throws SystemException {
5065 return findByN_V(name, vocabularyId, start, end, null);
5066 }
5067
5068
5083 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5084 int start, int end, OrderByComparator orderByComparator)
5085 throws SystemException {
5086 FinderPath finderPath = null;
5087 Object[] finderArgs = null;
5088
5089 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5090 (orderByComparator == null)) {
5091 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5092 finderArgs = new Object[] { name, vocabularyId };
5093 }
5094 else {
5095 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5096 finderArgs = new Object[] {
5097 name, vocabularyId,
5098
5099 start, end, orderByComparator
5100 };
5101 }
5102
5103 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5104 finderArgs, this);
5105
5106 if ((list != null) && !list.isEmpty()) {
5107 for (AssetCategory assetCategory : list) {
5108 if (!Validator.equals(name, assetCategory.getName()) ||
5109 (vocabularyId != assetCategory.getVocabularyId())) {
5110 list = null;
5111
5112 break;
5113 }
5114 }
5115 }
5116
5117 if (list == null) {
5118 StringBundler query = null;
5119
5120 if (orderByComparator != null) {
5121 query = new StringBundler(4 +
5122 (orderByComparator.getOrderByFields().length * 3));
5123 }
5124 else {
5125 query = new StringBundler(4);
5126 }
5127
5128 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5129
5130 if (name == null) {
5131 query.append(_FINDER_COLUMN_N_V_NAME_1);
5132 }
5133 else {
5134 if (name.equals(StringPool.BLANK)) {
5135 query.append(_FINDER_COLUMN_N_V_NAME_3);
5136 }
5137 else {
5138 query.append(_FINDER_COLUMN_N_V_NAME_2);
5139 }
5140 }
5141
5142 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5143
5144 if (orderByComparator != null) {
5145 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5146 orderByComparator);
5147 }
5148
5149 else {
5150 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5151 }
5152
5153 String sql = query.toString();
5154
5155 Session session = null;
5156
5157 try {
5158 session = openSession();
5159
5160 Query q = session.createQuery(sql);
5161
5162 QueryPos qPos = QueryPos.getInstance(q);
5163
5164 if (name != null) {
5165 qPos.add(name);
5166 }
5167
5168 qPos.add(vocabularyId);
5169
5170 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5171 start, end);
5172 }
5173 catch (Exception e) {
5174 throw processException(e);
5175 }
5176 finally {
5177 if (list == null) {
5178 FinderCacheUtil.removeResult(finderPath, finderArgs);
5179 }
5180 else {
5181 cacheResult(list);
5182
5183 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5184 }
5185
5186 closeSession(session);
5187 }
5188 }
5189
5190 return list;
5191 }
5192
5193
5203 public AssetCategory findByN_V_First(String name, long vocabularyId,
5204 OrderByComparator orderByComparator)
5205 throws NoSuchCategoryException, SystemException {
5206 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
5207 orderByComparator);
5208
5209 if (assetCategory != null) {
5210 return assetCategory;
5211 }
5212
5213 StringBundler msg = new StringBundler(6);
5214
5215 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5216
5217 msg.append("name=");
5218 msg.append(name);
5219
5220 msg.append(", vocabularyId=");
5221 msg.append(vocabularyId);
5222
5223 msg.append(StringPool.CLOSE_CURLY_BRACE);
5224
5225 throw new NoSuchCategoryException(msg.toString());
5226 }
5227
5228
5237 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
5238 OrderByComparator orderByComparator) throws SystemException {
5239 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
5240 orderByComparator);
5241
5242 if (!list.isEmpty()) {
5243 return list.get(0);
5244 }
5245
5246 return null;
5247 }
5248
5249
5259 public AssetCategory findByN_V_Last(String name, long vocabularyId,
5260 OrderByComparator orderByComparator)
5261 throws NoSuchCategoryException, SystemException {
5262 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
5263 orderByComparator);
5264
5265 if (assetCategory != null) {
5266 return assetCategory;
5267 }
5268
5269 StringBundler msg = new StringBundler(6);
5270
5271 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5272
5273 msg.append("name=");
5274 msg.append(name);
5275
5276 msg.append(", vocabularyId=");
5277 msg.append(vocabularyId);
5278
5279 msg.append(StringPool.CLOSE_CURLY_BRACE);
5280
5281 throw new NoSuchCategoryException(msg.toString());
5282 }
5283
5284
5293 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
5294 OrderByComparator orderByComparator) throws SystemException {
5295 int count = countByN_V(name, vocabularyId);
5296
5297 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
5298 count, orderByComparator);
5299
5300 if (!list.isEmpty()) {
5301 return list.get(0);
5302 }
5303
5304 return null;
5305 }
5306
5307
5318 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
5319 long vocabularyId, OrderByComparator orderByComparator)
5320 throws NoSuchCategoryException, SystemException {
5321 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5322
5323 Session session = null;
5324
5325 try {
5326 session = openSession();
5327
5328 AssetCategory[] array = new AssetCategoryImpl[3];
5329
5330 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
5331 vocabularyId, orderByComparator, true);
5332
5333 array[1] = assetCategory;
5334
5335 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
5336 vocabularyId, orderByComparator, false);
5337
5338 return array;
5339 }
5340 catch (Exception e) {
5341 throw processException(e);
5342 }
5343 finally {
5344 closeSession(session);
5345 }
5346 }
5347
5348 protected AssetCategory getByN_V_PrevAndNext(Session session,
5349 AssetCategory assetCategory, String name, long vocabularyId,
5350 OrderByComparator orderByComparator, boolean previous) {
5351 StringBundler query = null;
5352
5353 if (orderByComparator != null) {
5354 query = new StringBundler(6 +
5355 (orderByComparator.getOrderByFields().length * 6));
5356 }
5357 else {
5358 query = new StringBundler(3);
5359 }
5360
5361 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5362
5363 if (name == null) {
5364 query.append(_FINDER_COLUMN_N_V_NAME_1);
5365 }
5366 else {
5367 if (name.equals(StringPool.BLANK)) {
5368 query.append(_FINDER_COLUMN_N_V_NAME_3);
5369 }
5370 else {
5371 query.append(_FINDER_COLUMN_N_V_NAME_2);
5372 }
5373 }
5374
5375 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5376
5377 if (orderByComparator != null) {
5378 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5379
5380 if (orderByConditionFields.length > 0) {
5381 query.append(WHERE_AND);
5382 }
5383
5384 for (int i = 0; i < orderByConditionFields.length; i++) {
5385 query.append(_ORDER_BY_ENTITY_ALIAS);
5386 query.append(orderByConditionFields[i]);
5387
5388 if ((i + 1) < orderByConditionFields.length) {
5389 if (orderByComparator.isAscending() ^ previous) {
5390 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5391 }
5392 else {
5393 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5394 }
5395 }
5396 else {
5397 if (orderByComparator.isAscending() ^ previous) {
5398 query.append(WHERE_GREATER_THAN);
5399 }
5400 else {
5401 query.append(WHERE_LESSER_THAN);
5402 }
5403 }
5404 }
5405
5406 query.append(ORDER_BY_CLAUSE);
5407
5408 String[] orderByFields = orderByComparator.getOrderByFields();
5409
5410 for (int i = 0; i < orderByFields.length; i++) {
5411 query.append(_ORDER_BY_ENTITY_ALIAS);
5412 query.append(orderByFields[i]);
5413
5414 if ((i + 1) < orderByFields.length) {
5415 if (orderByComparator.isAscending() ^ previous) {
5416 query.append(ORDER_BY_ASC_HAS_NEXT);
5417 }
5418 else {
5419 query.append(ORDER_BY_DESC_HAS_NEXT);
5420 }
5421 }
5422 else {
5423 if (orderByComparator.isAscending() ^ previous) {
5424 query.append(ORDER_BY_ASC);
5425 }
5426 else {
5427 query.append(ORDER_BY_DESC);
5428 }
5429 }
5430 }
5431 }
5432
5433 else {
5434 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5435 }
5436
5437 String sql = query.toString();
5438
5439 Query q = session.createQuery(sql);
5440
5441 q.setFirstResult(0);
5442 q.setMaxResults(2);
5443
5444 QueryPos qPos = QueryPos.getInstance(q);
5445
5446 if (name != null) {
5447 qPos.add(name);
5448 }
5449
5450 qPos.add(vocabularyId);
5451
5452 if (orderByComparator != null) {
5453 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5454
5455 for (Object value : values) {
5456 qPos.add(value);
5457 }
5458 }
5459
5460 List<AssetCategory> list = q.list();
5461
5462 if (list.size() == 2) {
5463 return list.get(1);
5464 }
5465 else {
5466 return null;
5467 }
5468 }
5469
5470
5479 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5480 long vocabularyId) throws SystemException {
5481 return findByG_P_V(groupId, parentCategoryId, vocabularyId,
5482 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5483 }
5484
5485
5500 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5501 long vocabularyId, int start, int end) throws SystemException {
5502 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
5503 null);
5504 }
5505
5506
5522 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5523 long vocabularyId, int start, int end,
5524 OrderByComparator orderByComparator) throws SystemException {
5525 FinderPath finderPath = null;
5526 Object[] finderArgs = null;
5527
5528 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5529 (orderByComparator == null)) {
5530 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
5531 finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
5532 }
5533 else {
5534 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
5535 finderArgs = new Object[] {
5536 groupId, parentCategoryId, vocabularyId,
5537
5538 start, end, orderByComparator
5539 };
5540 }
5541
5542 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5543 finderArgs, this);
5544
5545 if ((list != null) && !list.isEmpty()) {
5546 for (AssetCategory assetCategory : list) {
5547 if ((groupId != assetCategory.getGroupId()) ||
5548 (parentCategoryId != assetCategory.getParentCategoryId()) ||
5549 (vocabularyId != assetCategory.getVocabularyId())) {
5550 list = null;
5551
5552 break;
5553 }
5554 }
5555 }
5556
5557 if (list == null) {
5558 StringBundler query = null;
5559
5560 if (orderByComparator != null) {
5561 query = new StringBundler(5 +
5562 (orderByComparator.getOrderByFields().length * 3));
5563 }
5564 else {
5565 query = new StringBundler(5);
5566 }
5567
5568 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5569
5570 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5571
5572 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5573
5574 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5575
5576 if (orderByComparator != null) {
5577 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5578 orderByComparator);
5579 }
5580
5581 else {
5582 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5583 }
5584
5585 String sql = query.toString();
5586
5587 Session session = null;
5588
5589 try {
5590 session = openSession();
5591
5592 Query q = session.createQuery(sql);
5593
5594 QueryPos qPos = QueryPos.getInstance(q);
5595
5596 qPos.add(groupId);
5597
5598 qPos.add(parentCategoryId);
5599
5600 qPos.add(vocabularyId);
5601
5602 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5603 start, end);
5604 }
5605 catch (Exception e) {
5606 throw processException(e);
5607 }
5608 finally {
5609 if (list == null) {
5610 FinderCacheUtil.removeResult(finderPath, finderArgs);
5611 }
5612 else {
5613 cacheResult(list);
5614
5615 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5616 }
5617
5618 closeSession(session);
5619 }
5620 }
5621
5622 return list;
5623 }
5624
5625
5636 public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
5637 long vocabularyId, OrderByComparator orderByComparator)
5638 throws NoSuchCategoryException, SystemException {
5639 AssetCategory assetCategory = fetchByG_P_V_First(groupId,
5640 parentCategoryId, vocabularyId, orderByComparator);
5641
5642 if (assetCategory != null) {
5643 return assetCategory;
5644 }
5645
5646 StringBundler msg = new StringBundler(8);
5647
5648 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5649
5650 msg.append("groupId=");
5651 msg.append(groupId);
5652
5653 msg.append(", parentCategoryId=");
5654 msg.append(parentCategoryId);
5655
5656 msg.append(", vocabularyId=");
5657 msg.append(vocabularyId);
5658
5659 msg.append(StringPool.CLOSE_CURLY_BRACE);
5660
5661 throw new NoSuchCategoryException(msg.toString());
5662 }
5663
5664
5674 public AssetCategory fetchByG_P_V_First(long groupId,
5675 long parentCategoryId, long vocabularyId,
5676 OrderByComparator orderByComparator) throws SystemException {
5677 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
5678 vocabularyId, 0, 1, orderByComparator);
5679
5680 if (!list.isEmpty()) {
5681 return list.get(0);
5682 }
5683
5684 return null;
5685 }
5686
5687
5698 public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
5699 long vocabularyId, OrderByComparator orderByComparator)
5700 throws NoSuchCategoryException, SystemException {
5701 AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
5702 parentCategoryId, vocabularyId, orderByComparator);
5703
5704 if (assetCategory != null) {
5705 return assetCategory;
5706 }
5707
5708 StringBundler msg = new StringBundler(8);
5709
5710 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5711
5712 msg.append("groupId=");
5713 msg.append(groupId);
5714
5715 msg.append(", parentCategoryId=");
5716 msg.append(parentCategoryId);
5717
5718 msg.append(", vocabularyId=");
5719 msg.append(vocabularyId);
5720
5721 msg.append(StringPool.CLOSE_CURLY_BRACE);
5722
5723 throw new NoSuchCategoryException(msg.toString());
5724 }
5725
5726
5736 public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
5737 long vocabularyId, OrderByComparator orderByComparator)
5738 throws SystemException {
5739 int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
5740
5741 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
5742 vocabularyId, count - 1, count, orderByComparator);
5743
5744 if (!list.isEmpty()) {
5745 return list.get(0);
5746 }
5747
5748 return null;
5749 }
5750
5751
5763 public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
5764 long groupId, long parentCategoryId, long vocabularyId,
5765 OrderByComparator orderByComparator)
5766 throws NoSuchCategoryException, SystemException {
5767 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5768
5769 Session session = null;
5770
5771 try {
5772 session = openSession();
5773
5774 AssetCategory[] array = new AssetCategoryImpl[3];
5775
5776 array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
5777 parentCategoryId, vocabularyId, orderByComparator, true);
5778
5779 array[1] = assetCategory;
5780
5781 array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
5782 parentCategoryId, vocabularyId, orderByComparator, false);
5783
5784 return array;
5785 }
5786 catch (Exception e) {
5787 throw processException(e);
5788 }
5789 finally {
5790 closeSession(session);
5791 }
5792 }
5793
5794 protected AssetCategory getByG_P_V_PrevAndNext(Session session,
5795 AssetCategory assetCategory, long groupId, long parentCategoryId,
5796 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
5797 StringBundler query = null;
5798
5799 if (orderByComparator != null) {
5800 query = new StringBundler(6 +
5801 (orderByComparator.getOrderByFields().length * 6));
5802 }
5803 else {
5804 query = new StringBundler(3);
5805 }
5806
5807 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5808
5809 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5810
5811 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5812
5813 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5814
5815 if (orderByComparator != null) {
5816 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5817
5818 if (orderByConditionFields.length > 0) {
5819 query.append(WHERE_AND);
5820 }
5821
5822 for (int i = 0; i < orderByConditionFields.length; i++) {
5823 query.append(_ORDER_BY_ENTITY_ALIAS);
5824 query.append(orderByConditionFields[i]);
5825
5826 if ((i + 1) < orderByConditionFields.length) {
5827 if (orderByComparator.isAscending() ^ previous) {
5828 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5829 }
5830 else {
5831 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5832 }
5833 }
5834 else {
5835 if (orderByComparator.isAscending() ^ previous) {
5836 query.append(WHERE_GREATER_THAN);
5837 }
5838 else {
5839 query.append(WHERE_LESSER_THAN);
5840 }
5841 }
5842 }
5843
5844 query.append(ORDER_BY_CLAUSE);
5845
5846 String[] orderByFields = orderByComparator.getOrderByFields();
5847
5848 for (int i = 0; i < orderByFields.length; i++) {
5849 query.append(_ORDER_BY_ENTITY_ALIAS);
5850 query.append(orderByFields[i]);
5851
5852 if ((i + 1) < orderByFields.length) {
5853 if (orderByComparator.isAscending() ^ previous) {
5854 query.append(ORDER_BY_ASC_HAS_NEXT);
5855 }
5856 else {
5857 query.append(ORDER_BY_DESC_HAS_NEXT);
5858 }
5859 }
5860 else {
5861 if (orderByComparator.isAscending() ^ previous) {
5862 query.append(ORDER_BY_ASC);
5863 }
5864 else {
5865 query.append(ORDER_BY_DESC);
5866 }
5867 }
5868 }
5869 }
5870
5871 else {
5872 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5873 }
5874
5875 String sql = query.toString();
5876
5877 Query q = session.createQuery(sql);
5878
5879 q.setFirstResult(0);
5880 q.setMaxResults(2);
5881
5882 QueryPos qPos = QueryPos.getInstance(q);
5883
5884 qPos.add(groupId);
5885
5886 qPos.add(parentCategoryId);
5887
5888 qPos.add(vocabularyId);
5889
5890 if (orderByComparator != null) {
5891 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5892
5893 for (Object value : values) {
5894 qPos.add(value);
5895 }
5896 }
5897
5898 List<AssetCategory> list = q.list();
5899
5900 if (list.size() == 2) {
5901 return list.get(1);
5902 }
5903 else {
5904 return null;
5905 }
5906 }
5907
5908
5917 public List<AssetCategory> filterFindByG_P_V(long groupId,
5918 long parentCategoryId, long vocabularyId) throws SystemException {
5919 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
5920 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5921 }
5922
5923
5938 public List<AssetCategory> filterFindByG_P_V(long groupId,
5939 long parentCategoryId, long vocabularyId, int start, int end)
5940 throws SystemException {
5941 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
5942 start, end, null);
5943 }
5944
5945
5961 public List<AssetCategory> filterFindByG_P_V(long groupId,
5962 long parentCategoryId, long vocabularyId, int start, int end,
5963 OrderByComparator orderByComparator) throws SystemException {
5964 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5965 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
5966 end, orderByComparator);
5967 }
5968
5969 StringBundler query = null;
5970
5971 if (orderByComparator != null) {
5972 query = new StringBundler(5 +
5973 (orderByComparator.getOrderByFields().length * 3));
5974 }
5975 else {
5976 query = new StringBundler(5);
5977 }
5978
5979 if (getDB().isSupportsInlineDistinct()) {
5980 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
5981 }
5982 else {
5983 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
5984 }
5985
5986 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5987
5988 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5989
5990 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5991
5992 if (!getDB().isSupportsInlineDistinct()) {
5993 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
5994 }
5995
5996 if (orderByComparator != null) {
5997 if (getDB().isSupportsInlineDistinct()) {
5998 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5999 orderByComparator);
6000 }
6001 else {
6002 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6003 orderByComparator);
6004 }
6005 }
6006
6007 else {
6008 if (getDB().isSupportsInlineDistinct()) {
6009 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6010 }
6011 else {
6012 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6013 }
6014 }
6015
6016 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6017 AssetCategory.class.getName(),
6018 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6019
6020 Session session = null;
6021
6022 try {
6023 session = openSession();
6024
6025 SQLQuery q = session.createSQLQuery(sql);
6026
6027 if (getDB().isSupportsInlineDistinct()) {
6028 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6029 }
6030 else {
6031 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6032 }
6033
6034 QueryPos qPos = QueryPos.getInstance(q);
6035
6036 qPos.add(groupId);
6037
6038 qPos.add(parentCategoryId);
6039
6040 qPos.add(vocabularyId);
6041
6042 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
6043 end);
6044 }
6045 catch (Exception e) {
6046 throw processException(e);
6047 }
6048 finally {
6049 closeSession(session);
6050 }
6051 }
6052
6053
6065 public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
6066 long groupId, long parentCategoryId, long vocabularyId,
6067 OrderByComparator orderByComparator)
6068 throws NoSuchCategoryException, SystemException {
6069 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6070 return findByG_P_V_PrevAndNext(categoryId, groupId,
6071 parentCategoryId, vocabularyId, orderByComparator);
6072 }
6073
6074 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6075
6076 Session session = null;
6077
6078 try {
6079 session = openSession();
6080
6081 AssetCategory[] array = new AssetCategoryImpl[3];
6082
6083 array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6084 groupId, parentCategoryId, vocabularyId, orderByComparator,
6085 true);
6086
6087 array[1] = assetCategory;
6088
6089 array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6090 groupId, parentCategoryId, vocabularyId, orderByComparator,
6091 false);
6092
6093 return array;
6094 }
6095 catch (Exception e) {
6096 throw processException(e);
6097 }
6098 finally {
6099 closeSession(session);
6100 }
6101 }
6102
6103 protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
6104 AssetCategory assetCategory, long groupId, long parentCategoryId,
6105 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6106 StringBundler query = null;
6107
6108 if (orderByComparator != null) {
6109 query = new StringBundler(6 +
6110 (orderByComparator.getOrderByFields().length * 6));
6111 }
6112 else {
6113 query = new StringBundler(3);
6114 }
6115
6116 if (getDB().isSupportsInlineDistinct()) {
6117 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6118 }
6119 else {
6120 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6121 }
6122
6123 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6124
6125 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6126
6127 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6128
6129 if (!getDB().isSupportsInlineDistinct()) {
6130 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6131 }
6132
6133 if (orderByComparator != null) {
6134 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6135
6136 if (orderByConditionFields.length > 0) {
6137 query.append(WHERE_AND);
6138 }
6139
6140 for (int i = 0; i < orderByConditionFields.length; i++) {
6141 if (getDB().isSupportsInlineDistinct()) {
6142 query.append(_ORDER_BY_ENTITY_ALIAS);
6143 }
6144 else {
6145 query.append(_ORDER_BY_ENTITY_TABLE);
6146 }
6147
6148 query.append(orderByConditionFields[i]);
6149
6150 if ((i + 1) < orderByConditionFields.length) {
6151 if (orderByComparator.isAscending() ^ previous) {
6152 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6153 }
6154 else {
6155 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6156 }
6157 }
6158 else {
6159 if (orderByComparator.isAscending() ^ previous) {
6160 query.append(WHERE_GREATER_THAN);
6161 }
6162 else {
6163 query.append(WHERE_LESSER_THAN);
6164 }
6165 }
6166 }
6167
6168 query.append(ORDER_BY_CLAUSE);
6169
6170 String[] orderByFields = orderByComparator.getOrderByFields();
6171
6172 for (int i = 0; i < orderByFields.length; i++) {
6173 if (getDB().isSupportsInlineDistinct()) {
6174 query.append(_ORDER_BY_ENTITY_ALIAS);
6175 }
6176 else {
6177 query.append(_ORDER_BY_ENTITY_TABLE);
6178 }
6179
6180 query.append(orderByFields[i]);
6181
6182 if ((i + 1) < orderByFields.length) {
6183 if (orderByComparator.isAscending() ^ previous) {
6184 query.append(ORDER_BY_ASC_HAS_NEXT);
6185 }
6186 else {
6187 query.append(ORDER_BY_DESC_HAS_NEXT);
6188 }
6189 }
6190 else {
6191 if (orderByComparator.isAscending() ^ previous) {
6192 query.append(ORDER_BY_ASC);
6193 }
6194 else {
6195 query.append(ORDER_BY_DESC);
6196 }
6197 }
6198 }
6199 }
6200
6201 else {
6202 if (getDB().isSupportsInlineDistinct()) {
6203 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6204 }
6205 else {
6206 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6207 }
6208 }
6209
6210 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6211 AssetCategory.class.getName(),
6212 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6213
6214 SQLQuery q = session.createSQLQuery(sql);
6215
6216 q.setFirstResult(0);
6217 q.setMaxResults(2);
6218
6219 if (getDB().isSupportsInlineDistinct()) {
6220 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6221 }
6222 else {
6223 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6224 }
6225
6226 QueryPos qPos = QueryPos.getInstance(q);
6227
6228 qPos.add(groupId);
6229
6230 qPos.add(parentCategoryId);
6231
6232 qPos.add(vocabularyId);
6233
6234 if (orderByComparator != null) {
6235 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6236
6237 for (Object value : values) {
6238 qPos.add(value);
6239 }
6240 }
6241
6242 List<AssetCategory> list = q.list();
6243
6244 if (list.size() == 2) {
6245 return list.get(1);
6246 }
6247 else {
6248 return null;
6249 }
6250 }
6251
6252
6261 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6262 long vocabularyId) throws SystemException {
6263 return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
6264 QueryUtil.ALL_POS, null);
6265 }
6266
6267
6282 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6283 long vocabularyId, int start, int end) throws SystemException {
6284 return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
6285 }
6286
6287
6303 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6304 long vocabularyId, int start, int end,
6305 OrderByComparator orderByComparator) throws SystemException {
6306 FinderPath finderPath = null;
6307 Object[] finderArgs = null;
6308
6309 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
6310 finderArgs = new Object[] {
6311 groupId, name, vocabularyId,
6312
6313 start, end, orderByComparator
6314 };
6315
6316 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6317 finderArgs, this);
6318
6319 if ((list != null) && !list.isEmpty()) {
6320 for (AssetCategory assetCategory : list) {
6321 if ((groupId != assetCategory.getGroupId()) ||
6322 !Validator.equals(name, assetCategory.getName()) ||
6323 (vocabularyId != assetCategory.getVocabularyId())) {
6324 list = null;
6325
6326 break;
6327 }
6328 }
6329 }
6330
6331 if (list == null) {
6332 StringBundler query = null;
6333
6334 if (orderByComparator != null) {
6335 query = new StringBundler(5 +
6336 (orderByComparator.getOrderByFields().length * 3));
6337 }
6338 else {
6339 query = new StringBundler(5);
6340 }
6341
6342 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6343
6344 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6345
6346 if (name == null) {
6347 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6348 }
6349 else {
6350 if (name.equals(StringPool.BLANK)) {
6351 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6352 }
6353 else {
6354 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6355 }
6356 }
6357
6358 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6359
6360 if (orderByComparator != null) {
6361 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6362 orderByComparator);
6363 }
6364
6365 else {
6366 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6367 }
6368
6369 String sql = query.toString();
6370
6371 Session session = null;
6372
6373 try {
6374 session = openSession();
6375
6376 Query q = session.createQuery(sql);
6377
6378 QueryPos qPos = QueryPos.getInstance(q);
6379
6380 qPos.add(groupId);
6381
6382 if (name != null) {
6383 qPos.add(name);
6384 }
6385
6386 qPos.add(vocabularyId);
6387
6388 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6389 start, end);
6390 }
6391 catch (Exception e) {
6392 throw processException(e);
6393 }
6394 finally {
6395 if (list == null) {
6396 FinderCacheUtil.removeResult(finderPath, finderArgs);
6397 }
6398 else {
6399 cacheResult(list);
6400
6401 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6402 }
6403
6404 closeSession(session);
6405 }
6406 }
6407
6408 return list;
6409 }
6410
6411
6422 public AssetCategory findByG_LikeN_V_First(long groupId, String name,
6423 long vocabularyId, OrderByComparator orderByComparator)
6424 throws NoSuchCategoryException, SystemException {
6425 AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
6426 vocabularyId, orderByComparator);
6427
6428 if (assetCategory != null) {
6429 return assetCategory;
6430 }
6431
6432 StringBundler msg = new StringBundler(8);
6433
6434 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6435
6436 msg.append("groupId=");
6437 msg.append(groupId);
6438
6439 msg.append(", name=");
6440 msg.append(name);
6441
6442 msg.append(", vocabularyId=");
6443 msg.append(vocabularyId);
6444
6445 msg.append(StringPool.CLOSE_CURLY_BRACE);
6446
6447 throw new NoSuchCategoryException(msg.toString());
6448 }
6449
6450
6460 public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
6461 long vocabularyId, OrderByComparator orderByComparator)
6462 throws SystemException {
6463 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
6464 0, 1, orderByComparator);
6465
6466 if (!list.isEmpty()) {
6467 return list.get(0);
6468 }
6469
6470 return null;
6471 }
6472
6473
6484 public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
6485 long vocabularyId, OrderByComparator orderByComparator)
6486 throws NoSuchCategoryException, SystemException {
6487 AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
6488 vocabularyId, orderByComparator);
6489
6490 if (assetCategory != null) {
6491 return assetCategory;
6492 }
6493
6494 StringBundler msg = new StringBundler(8);
6495
6496 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6497
6498 msg.append("groupId=");
6499 msg.append(groupId);
6500
6501 msg.append(", name=");
6502 msg.append(name);
6503
6504 msg.append(", vocabularyId=");
6505 msg.append(vocabularyId);
6506
6507 msg.append(StringPool.CLOSE_CURLY_BRACE);
6508
6509 throw new NoSuchCategoryException(msg.toString());
6510 }
6511
6512
6522 public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
6523 long vocabularyId, OrderByComparator orderByComparator)
6524 throws SystemException {
6525 int count = countByG_LikeN_V(groupId, name, vocabularyId);
6526
6527 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
6528 count - 1, count, orderByComparator);
6529
6530 if (!list.isEmpty()) {
6531 return list.get(0);
6532 }
6533
6534 return null;
6535 }
6536
6537
6549 public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
6550 long groupId, String name, long vocabularyId,
6551 OrderByComparator orderByComparator)
6552 throws NoSuchCategoryException, SystemException {
6553 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6554
6555 Session session = null;
6556
6557 try {
6558 session = openSession();
6559
6560 AssetCategory[] array = new AssetCategoryImpl[3];
6561
6562 array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
6563 groupId, name, vocabularyId, orderByComparator, true);
6564
6565 array[1] = assetCategory;
6566
6567 array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
6568 groupId, name, vocabularyId, orderByComparator, false);
6569
6570 return array;
6571 }
6572 catch (Exception e) {
6573 throw processException(e);
6574 }
6575 finally {
6576 closeSession(session);
6577 }
6578 }
6579
6580 protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
6581 AssetCategory assetCategory, long groupId, String name,
6582 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6583 StringBundler query = null;
6584
6585 if (orderByComparator != null) {
6586 query = new StringBundler(6 +
6587 (orderByComparator.getOrderByFields().length * 6));
6588 }
6589 else {
6590 query = new StringBundler(3);
6591 }
6592
6593 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6594
6595 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6596
6597 if (name == null) {
6598 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6599 }
6600 else {
6601 if (name.equals(StringPool.BLANK)) {
6602 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6603 }
6604 else {
6605 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6606 }
6607 }
6608
6609 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6610
6611 if (orderByComparator != null) {
6612 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6613
6614 if (orderByConditionFields.length > 0) {
6615 query.append(WHERE_AND);
6616 }
6617
6618 for (int i = 0; i < orderByConditionFields.length; i++) {
6619 query.append(_ORDER_BY_ENTITY_ALIAS);
6620 query.append(orderByConditionFields[i]);
6621
6622 if ((i + 1) < orderByConditionFields.length) {
6623 if (orderByComparator.isAscending() ^ previous) {
6624 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6625 }
6626 else {
6627 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6628 }
6629 }
6630 else {
6631 if (orderByComparator.isAscending() ^ previous) {
6632 query.append(WHERE_GREATER_THAN);
6633 }
6634 else {
6635 query.append(WHERE_LESSER_THAN);
6636 }
6637 }
6638 }
6639
6640 query.append(ORDER_BY_CLAUSE);
6641
6642 String[] orderByFields = orderByComparator.getOrderByFields();
6643
6644 for (int i = 0; i < orderByFields.length; i++) {
6645 query.append(_ORDER_BY_ENTITY_ALIAS);
6646 query.append(orderByFields[i]);
6647
6648 if ((i + 1) < orderByFields.length) {
6649 if (orderByComparator.isAscending() ^ previous) {
6650 query.append(ORDER_BY_ASC_HAS_NEXT);
6651 }
6652 else {
6653 query.append(ORDER_BY_DESC_HAS_NEXT);
6654 }
6655 }
6656 else {
6657 if (orderByComparator.isAscending() ^ previous) {
6658 query.append(ORDER_BY_ASC);
6659 }
6660 else {
6661 query.append(ORDER_BY_DESC);
6662 }
6663 }
6664 }
6665 }
6666
6667 else {
6668 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6669 }
6670
6671 String sql = query.toString();
6672
6673 Query q = session.createQuery(sql);
6674
6675 q.setFirstResult(0);
6676 q.setMaxResults(2);
6677
6678 QueryPos qPos = QueryPos.getInstance(q);
6679
6680 qPos.add(groupId);
6681
6682 if (name != null) {
6683 qPos.add(name);
6684 }
6685
6686 qPos.add(vocabularyId);
6687
6688 if (orderByComparator != null) {
6689 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6690
6691 for (Object value : values) {
6692 qPos.add(value);
6693 }
6694 }
6695
6696 List<AssetCategory> list = q.list();
6697
6698 if (list.size() == 2) {
6699 return list.get(1);
6700 }
6701 else {
6702 return null;
6703 }
6704 }
6705
6706
6719 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6720 long[] vocabularyIds) throws SystemException {
6721 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
6722 QueryUtil.ALL_POS, null);
6723 }
6724
6725
6740 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6741 long[] vocabularyIds, int start, int end) throws SystemException {
6742 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
6743 }
6744
6745
6761 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6762 long[] vocabularyIds, int start, int end,
6763 OrderByComparator orderByComparator) throws SystemException {
6764 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
6765 Object[] finderArgs = null;
6766
6767 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6768 (orderByComparator == null)) {
6769 finderArgs = new Object[] {
6770 groupId, name, StringUtil.merge(vocabularyIds)
6771 };
6772 }
6773 else {
6774 finderArgs = new Object[] {
6775 groupId, name, StringUtil.merge(vocabularyIds),
6776
6777 start, end, orderByComparator
6778 };
6779 }
6780
6781 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6782 finderArgs, this);
6783
6784 if ((list != null) && !list.isEmpty()) {
6785 for (AssetCategory assetCategory : list) {
6786 if ((groupId != assetCategory.getGroupId()) ||
6787 !Validator.equals(name, assetCategory.getName()) ||
6788 !ArrayUtil.contains(vocabularyIds,
6789 assetCategory.getVocabularyId())) {
6790 list = null;
6791
6792 break;
6793 }
6794 }
6795 }
6796
6797 if (list == null) {
6798 StringBundler query = new StringBundler();
6799
6800 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6801
6802 boolean conjunctionable = false;
6803
6804 if (conjunctionable) {
6805 query.append(WHERE_AND);
6806 }
6807
6808 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
6809
6810 conjunctionable = true;
6811
6812 if (conjunctionable) {
6813 query.append(WHERE_AND);
6814 }
6815
6816 if (name == null) {
6817 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
6818 }
6819 else {
6820 if (name.equals(StringPool.BLANK)) {
6821 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
6822 }
6823 else {
6824 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
6825 }
6826 }
6827
6828 conjunctionable = true;
6829
6830 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
6831 if (conjunctionable) {
6832 query.append(WHERE_AND);
6833 }
6834
6835 query.append(StringPool.OPEN_PARENTHESIS);
6836
6837 for (int i = 0; i < vocabularyIds.length; i++) {
6838 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
6839
6840 if ((i + 1) < vocabularyIds.length) {
6841 query.append(WHERE_OR);
6842 }
6843 }
6844
6845 query.append(StringPool.CLOSE_PARENTHESIS);
6846
6847 conjunctionable = true;
6848 }
6849
6850 if (orderByComparator != null) {
6851 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6852 orderByComparator);
6853 }
6854
6855 else {
6856 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6857 }
6858
6859 String sql = query.toString();
6860
6861 Session session = null;
6862
6863 try {
6864 session = openSession();
6865
6866 Query q = session.createQuery(sql);
6867
6868 QueryPos qPos = QueryPos.getInstance(q);
6869
6870 qPos.add(groupId);
6871
6872 if (name != null) {
6873 qPos.add(name);
6874 }
6875
6876 if (vocabularyIds != null) {
6877 qPos.add(vocabularyIds);
6878 }
6879
6880 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6881 start, end);
6882 }
6883 catch (Exception e) {
6884 throw processException(e);
6885 }
6886 finally {
6887 if (list == null) {
6888 FinderCacheUtil.removeResult(finderPath, finderArgs);
6889 }
6890 else {
6891 cacheResult(list);
6892
6893 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6894 }
6895
6896 closeSession(session);
6897 }
6898 }
6899
6900 return list;
6901 }
6902
6903
6912 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6913 long vocabularyId) throws SystemException {
6914 return filterFindByG_LikeN_V(groupId, name, vocabularyId,
6915 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6916 }
6917
6918
6933 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6934 long vocabularyId, int start, int end) throws SystemException {
6935 return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
6936 null);
6937 }
6938
6939
6955 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6956 long vocabularyId, int start, int end,
6957 OrderByComparator orderByComparator) throws SystemException {
6958 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6959 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
6960 orderByComparator);
6961 }
6962
6963 StringBundler query = null;
6964
6965 if (orderByComparator != null) {
6966 query = new StringBundler(5 +
6967 (orderByComparator.getOrderByFields().length * 3));
6968 }
6969 else {
6970 query = new StringBundler(5);
6971 }
6972
6973 if (getDB().isSupportsInlineDistinct()) {
6974 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6975 }
6976 else {
6977 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6978 }
6979
6980 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6981
6982 if (name == null) {
6983 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6984 }
6985 else {
6986 if (name.equals(StringPool.BLANK)) {
6987 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6988 }
6989 else {
6990 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6991 }
6992 }
6993
6994 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6995
6996 if (!getDB().isSupportsInlineDistinct()) {
6997 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6998 }
6999
7000 if (orderByComparator != null) {
7001 if (getDB().isSupportsInlineDistinct()) {
7002 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7003 orderByComparator);
7004 }
7005 else {
7006 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7007 orderByComparator);
7008 }
7009 }
7010
7011 else {
7012 if (getDB().isSupportsInlineDistinct()) {
7013 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7014 }
7015 else {
7016 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7017 }
7018 }
7019
7020 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7021 AssetCategory.class.getName(),
7022 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7023
7024 Session session = null;
7025
7026 try {
7027 session = openSession();
7028
7029 SQLQuery q = session.createSQLQuery(sql);
7030
7031 if (getDB().isSupportsInlineDistinct()) {
7032 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7033 }
7034 else {
7035 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7036 }
7037
7038 QueryPos qPos = QueryPos.getInstance(q);
7039
7040 qPos.add(groupId);
7041
7042 if (name != null) {
7043 qPos.add(name);
7044 }
7045
7046 qPos.add(vocabularyId);
7047
7048 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7049 end);
7050 }
7051 catch (Exception e) {
7052 throw processException(e);
7053 }
7054 finally {
7055 closeSession(session);
7056 }
7057 }
7058
7059
7071 public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
7072 long groupId, String name, long vocabularyId,
7073 OrderByComparator orderByComparator)
7074 throws NoSuchCategoryException, SystemException {
7075 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7076 return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
7077 vocabularyId, orderByComparator);
7078 }
7079
7080 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7081
7082 Session session = null;
7083
7084 try {
7085 session = openSession();
7086
7087 AssetCategory[] array = new AssetCategoryImpl[3];
7088
7089 array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7090 groupId, name, vocabularyId, orderByComparator, true);
7091
7092 array[1] = assetCategory;
7093
7094 array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7095 groupId, name, vocabularyId, orderByComparator, false);
7096
7097 return array;
7098 }
7099 catch (Exception e) {
7100 throw processException(e);
7101 }
7102 finally {
7103 closeSession(session);
7104 }
7105 }
7106
7107 protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
7108 AssetCategory assetCategory, long groupId, String name,
7109 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7110 StringBundler query = null;
7111
7112 if (orderByComparator != null) {
7113 query = new StringBundler(6 +
7114 (orderByComparator.getOrderByFields().length * 6));
7115 }
7116 else {
7117 query = new StringBundler(3);
7118 }
7119
7120 if (getDB().isSupportsInlineDistinct()) {
7121 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7122 }
7123 else {
7124 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7125 }
7126
7127 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7128
7129 if (name == null) {
7130 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7131 }
7132 else {
7133 if (name.equals(StringPool.BLANK)) {
7134 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7135 }
7136 else {
7137 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7138 }
7139 }
7140
7141 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7142
7143 if (!getDB().isSupportsInlineDistinct()) {
7144 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7145 }
7146
7147 if (orderByComparator != null) {
7148 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7149
7150 if (orderByConditionFields.length > 0) {
7151 query.append(WHERE_AND);
7152 }
7153
7154 for (int i = 0; i < orderByConditionFields.length; i++) {
7155 if (getDB().isSupportsInlineDistinct()) {
7156 query.append(_ORDER_BY_ENTITY_ALIAS);
7157 }
7158 else {
7159 query.append(_ORDER_BY_ENTITY_TABLE);
7160 }
7161
7162 query.append(orderByConditionFields[i]);
7163
7164 if ((i + 1) < orderByConditionFields.length) {
7165 if (orderByComparator.isAscending() ^ previous) {
7166 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7167 }
7168 else {
7169 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7170 }
7171 }
7172 else {
7173 if (orderByComparator.isAscending() ^ previous) {
7174 query.append(WHERE_GREATER_THAN);
7175 }
7176 else {
7177 query.append(WHERE_LESSER_THAN);
7178 }
7179 }
7180 }
7181
7182 query.append(ORDER_BY_CLAUSE);
7183
7184 String[] orderByFields = orderByComparator.getOrderByFields();
7185
7186 for (int i = 0; i < orderByFields.length; i++) {
7187 if (getDB().isSupportsInlineDistinct()) {
7188 query.append(_ORDER_BY_ENTITY_ALIAS);
7189 }
7190 else {
7191 query.append(_ORDER_BY_ENTITY_TABLE);
7192 }
7193
7194 query.append(orderByFields[i]);
7195
7196 if ((i + 1) < orderByFields.length) {
7197 if (orderByComparator.isAscending() ^ previous) {
7198 query.append(ORDER_BY_ASC_HAS_NEXT);
7199 }
7200 else {
7201 query.append(ORDER_BY_DESC_HAS_NEXT);
7202 }
7203 }
7204 else {
7205 if (orderByComparator.isAscending() ^ previous) {
7206 query.append(ORDER_BY_ASC);
7207 }
7208 else {
7209 query.append(ORDER_BY_DESC);
7210 }
7211 }
7212 }
7213 }
7214
7215 else {
7216 if (getDB().isSupportsInlineDistinct()) {
7217 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7218 }
7219 else {
7220 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7221 }
7222 }
7223
7224 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7225 AssetCategory.class.getName(),
7226 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7227
7228 SQLQuery q = session.createSQLQuery(sql);
7229
7230 q.setFirstResult(0);
7231 q.setMaxResults(2);
7232
7233 if (getDB().isSupportsInlineDistinct()) {
7234 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7235 }
7236 else {
7237 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7238 }
7239
7240 QueryPos qPos = QueryPos.getInstance(q);
7241
7242 qPos.add(groupId);
7243
7244 if (name != null) {
7245 qPos.add(name);
7246 }
7247
7248 qPos.add(vocabularyId);
7249
7250 if (orderByComparator != null) {
7251 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7252
7253 for (Object value : values) {
7254 qPos.add(value);
7255 }
7256 }
7257
7258 List<AssetCategory> list = q.list();
7259
7260 if (list.size() == 2) {
7261 return list.get(1);
7262 }
7263 else {
7264 return null;
7265 }
7266 }
7267
7268
7277 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7278 long[] vocabularyIds) throws SystemException {
7279 return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
7280 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7281 }
7282
7283
7298 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7299 long[] vocabularyIds, int start, int end) throws SystemException {
7300 return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
7301 null);
7302 }
7303
7304
7320 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7321 long[] vocabularyIds, int start, int end,
7322 OrderByComparator orderByComparator) throws SystemException {
7323 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7324 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
7325 orderByComparator);
7326 }
7327
7328 StringBundler query = new StringBundler();
7329
7330 if (getDB().isSupportsInlineDistinct()) {
7331 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7332 }
7333 else {
7334 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7335 }
7336
7337 boolean conjunctionable = false;
7338
7339 if (conjunctionable) {
7340 query.append(WHERE_AND);
7341 }
7342
7343 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
7344
7345 conjunctionable = true;
7346
7347 if (conjunctionable) {
7348 query.append(WHERE_AND);
7349 }
7350
7351 if (name == null) {
7352 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
7353 }
7354 else {
7355 if (name.equals(StringPool.BLANK)) {
7356 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
7357 }
7358 else {
7359 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
7360 }
7361 }
7362
7363 conjunctionable = true;
7364
7365 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
7366 if (conjunctionable) {
7367 query.append(WHERE_AND);
7368 }
7369
7370 query.append(StringPool.OPEN_PARENTHESIS);
7371
7372 for (int i = 0; i < vocabularyIds.length; i++) {
7373 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
7374
7375 if ((i + 1) < vocabularyIds.length) {
7376 query.append(WHERE_OR);
7377 }
7378 }
7379
7380 query.append(StringPool.CLOSE_PARENTHESIS);
7381
7382 conjunctionable = true;
7383 }
7384
7385 if (!getDB().isSupportsInlineDistinct()) {
7386 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7387 }
7388
7389 if (orderByComparator != null) {
7390 if (getDB().isSupportsInlineDistinct()) {
7391 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7392 orderByComparator);
7393 }
7394 else {
7395 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7396 orderByComparator);
7397 }
7398 }
7399
7400 else {
7401 if (getDB().isSupportsInlineDistinct()) {
7402 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7403 }
7404 else {
7405 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7406 }
7407 }
7408
7409 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7410 AssetCategory.class.getName(),
7411 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7412
7413 Session session = null;
7414
7415 try {
7416 session = openSession();
7417
7418 SQLQuery q = session.createSQLQuery(sql);
7419
7420 if (getDB().isSupportsInlineDistinct()) {
7421 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7422 }
7423 else {
7424 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7425 }
7426
7427 QueryPos qPos = QueryPos.getInstance(q);
7428
7429 qPos.add(groupId);
7430
7431 if (name != null) {
7432 qPos.add(name);
7433 }
7434
7435 if (vocabularyIds != null) {
7436 qPos.add(vocabularyIds);
7437 }
7438
7439 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7440 end);
7441 }
7442 catch (Exception e) {
7443 throw processException(e);
7444 }
7445 finally {
7446 closeSession(session);
7447 }
7448 }
7449
7450
7460 public AssetCategory findByP_N_V(long parentCategoryId, String name,
7461 long vocabularyId) throws NoSuchCategoryException, SystemException {
7462 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
7463 vocabularyId);
7464
7465 if (assetCategory == null) {
7466 StringBundler msg = new StringBundler(8);
7467
7468 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7469
7470 msg.append("parentCategoryId=");
7471 msg.append(parentCategoryId);
7472
7473 msg.append(", name=");
7474 msg.append(name);
7475
7476 msg.append(", vocabularyId=");
7477 msg.append(vocabularyId);
7478
7479 msg.append(StringPool.CLOSE_CURLY_BRACE);
7480
7481 if (_log.isWarnEnabled()) {
7482 _log.warn(msg.toString());
7483 }
7484
7485 throw new NoSuchCategoryException(msg.toString());
7486 }
7487
7488 return assetCategory;
7489 }
7490
7491
7500 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
7501 long vocabularyId) throws SystemException {
7502 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
7503 }
7504
7505
7515 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
7516 long vocabularyId, boolean retrieveFromCache) throws SystemException {
7517 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
7518
7519 Object result = null;
7520
7521 if (retrieveFromCache) {
7522 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
7523 finderArgs, this);
7524 }
7525
7526 if (result instanceof AssetCategory) {
7527 AssetCategory assetCategory = (AssetCategory)result;
7528
7529 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
7530 !Validator.equals(name, assetCategory.getName()) ||
7531 (vocabularyId != assetCategory.getVocabularyId())) {
7532 result = null;
7533 }
7534 }
7535
7536 if (result == null) {
7537 StringBundler query = new StringBundler(5);
7538
7539 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7540
7541 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
7542
7543 if (name == null) {
7544 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
7545 }
7546 else {
7547 if (name.equals(StringPool.BLANK)) {
7548 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
7549 }
7550 else {
7551 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
7552 }
7553 }
7554
7555 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
7556
7557 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7558
7559 String sql = query.toString();
7560
7561 Session session = null;
7562
7563 try {
7564 session = openSession();
7565
7566 Query q = session.createQuery(sql);
7567
7568 QueryPos qPos = QueryPos.getInstance(q);
7569
7570 qPos.add(parentCategoryId);
7571
7572 if (name != null) {
7573 qPos.add(name);
7574 }
7575
7576 qPos.add(vocabularyId);
7577
7578 List<AssetCategory> list = q.list();
7579
7580 result = list;
7581
7582 AssetCategory assetCategory = null;
7583
7584 if (list.isEmpty()) {
7585 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
7586 finderArgs, list);
7587 }
7588 else {
7589 assetCategory = list.get(0);
7590
7591 cacheResult(assetCategory);
7592
7593 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
7594 (assetCategory.getName() == null) ||
7595 !assetCategory.getName().equals(name) ||
7596 (assetCategory.getVocabularyId() != vocabularyId)) {
7597 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
7598 finderArgs, assetCategory);
7599 }
7600 }
7601
7602 return assetCategory;
7603 }
7604 catch (Exception e) {
7605 throw processException(e);
7606 }
7607 finally {
7608 if (result == null) {
7609 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
7610 finderArgs);
7611 }
7612
7613 closeSession(session);
7614 }
7615 }
7616 else {
7617 if (result instanceof List<?>) {
7618 return null;
7619 }
7620 else {
7621 return (AssetCategory)result;
7622 }
7623 }
7624 }
7625
7626
7636 public List<AssetCategory> findByG_P_N_V(long groupId,
7637 long parentCategoryId, String name, long vocabularyId)
7638 throws SystemException {
7639 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
7640 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7641 }
7642
7643
7659 public List<AssetCategory> findByG_P_N_V(long groupId,
7660 long parentCategoryId, String name, long vocabularyId, int start,
7661 int end) throws SystemException {
7662 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
7663 start, end, null);
7664 }
7665
7666
7683 public List<AssetCategory> findByG_P_N_V(long groupId,
7684 long parentCategoryId, String name, long vocabularyId, int start,
7685 int end, OrderByComparator orderByComparator) throws SystemException {
7686 FinderPath finderPath = null;
7687 Object[] finderArgs = null;
7688
7689 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7690 (orderByComparator == null)) {
7691 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
7692 finderArgs = new Object[] {
7693 groupId, parentCategoryId, name, vocabularyId
7694 };
7695 }
7696 else {
7697 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
7698 finderArgs = new Object[] {
7699 groupId, parentCategoryId, name, vocabularyId,
7700
7701 start, end, orderByComparator
7702 };
7703 }
7704
7705 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7706 finderArgs, this);
7707
7708 if ((list != null) && !list.isEmpty()) {
7709 for (AssetCategory assetCategory : list) {
7710 if ((groupId != assetCategory.getGroupId()) ||
7711 (parentCategoryId != assetCategory.getParentCategoryId()) ||
7712 !Validator.equals(name, assetCategory.getName()) ||
7713 (vocabularyId != assetCategory.getVocabularyId())) {
7714 list = null;
7715
7716 break;
7717 }
7718 }
7719 }
7720
7721 if (list == null) {
7722 StringBundler query = null;
7723
7724 if (orderByComparator != null) {
7725 query = new StringBundler(6 +
7726 (orderByComparator.getOrderByFields().length * 3));
7727 }
7728 else {
7729 query = new StringBundler(6);
7730 }
7731
7732 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7733
7734 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
7735
7736 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
7737
7738 if (name == null) {
7739 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
7740 }
7741 else {
7742 if (name.equals(StringPool.BLANK)) {
7743 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
7744 }
7745 else {
7746 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
7747 }
7748 }
7749
7750 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
7751
7752 if (orderByComparator != null) {
7753 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7754 orderByComparator);
7755 }
7756
7757 else {
7758 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7759 }
7760
7761 String sql = query.toString();
7762
7763 Session session = null;
7764
7765 try {
7766 session = openSession();
7767
7768 Query q = session.createQuery(sql);
7769
7770 QueryPos qPos = QueryPos.getInstance(q);
7771
7772 qPos.add(groupId);
7773
7774 qPos.add(parentCategoryId);
7775
7776 if (name != null) {
7777 qPos.add(name);
7778 }
7779
7780 qPos.add(vocabularyId);
7781
7782 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7783 start, end);
7784 }
7785 catch (Exception e) {
7786 throw processException(e);
7787 }
7788 finally {
7789 if (list == null) {
7790 FinderCacheUtil.removeResult(finderPath, finderArgs);
7791 }
7792 else {
7793 cacheResult(list);
7794
7795 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7796 }
7797
7798 closeSession(session);
7799 }
7800 }
7801
7802 return list;
7803 }
7804
7805
7817 public AssetCategory findByG_P_N_V_First(long groupId,
7818 long parentCategoryId, String name, long vocabularyId,
7819 OrderByComparator orderByComparator)
7820 throws NoSuchCategoryException, SystemException {
7821 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
7822 parentCategoryId, name, vocabularyId, orderByComparator);
7823
7824 if (assetCategory != null) {
7825 return assetCategory;
7826 }
7827
7828 StringBundler msg = new StringBundler(10);
7829
7830 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7831
7832 msg.append("groupId=");
7833 msg.append(groupId);
7834
7835 msg.append(", parentCategoryId=");
7836 msg.append(parentCategoryId);
7837
7838 msg.append(", name=");
7839 msg.append(name);
7840
7841 msg.append(", vocabularyId=");
7842 msg.append(vocabularyId);
7843
7844 msg.append(StringPool.CLOSE_CURLY_BRACE);
7845
7846 throw new NoSuchCategoryException(msg.toString());
7847 }
7848
7849
7860 public AssetCategory fetchByG_P_N_V_First(long groupId,
7861 long parentCategoryId, String name, long vocabularyId,
7862 OrderByComparator orderByComparator) throws SystemException {
7863 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
7864 name, vocabularyId, 0, 1, orderByComparator);
7865
7866 if (!list.isEmpty()) {
7867 return list.get(0);
7868 }
7869
7870 return null;
7871 }
7872
7873
7885 public AssetCategory findByG_P_N_V_Last(long groupId,
7886 long parentCategoryId, String name, long vocabularyId,
7887 OrderByComparator orderByComparator)
7888 throws NoSuchCategoryException, SystemException {
7889 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
7890 parentCategoryId, name, vocabularyId, orderByComparator);
7891
7892 if (assetCategory != null) {
7893 return assetCategory;
7894 }
7895
7896 StringBundler msg = new StringBundler(10);
7897
7898 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7899
7900 msg.append("groupId=");
7901 msg.append(groupId);
7902
7903 msg.append(", parentCategoryId=");
7904 msg.append(parentCategoryId);
7905
7906 msg.append(", name=");
7907 msg.append(name);
7908
7909 msg.append(", vocabularyId=");
7910 msg.append(vocabularyId);
7911
7912 msg.append(StringPool.CLOSE_CURLY_BRACE);
7913
7914 throw new NoSuchCategoryException(msg.toString());
7915 }
7916
7917
7928 public AssetCategory fetchByG_P_N_V_Last(long groupId,
7929 long parentCategoryId, String name, long vocabularyId,
7930 OrderByComparator orderByComparator) throws SystemException {
7931 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
7932
7933 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
7934 name, vocabularyId, count - 1, count, orderByComparator);
7935
7936 if (!list.isEmpty()) {
7937 return list.get(0);
7938 }
7939
7940 return null;
7941 }
7942
7943
7956 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
7957 long groupId, long parentCategoryId, String name, long vocabularyId,
7958 OrderByComparator orderByComparator)
7959 throws NoSuchCategoryException, SystemException {
7960 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7961
7962 Session session = null;
7963
7964 try {
7965 session = openSession();
7966
7967 AssetCategory[] array = new AssetCategoryImpl[3];
7968
7969 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
7970 groupId, parentCategoryId, name, vocabularyId,
7971 orderByComparator, true);
7972
7973 array[1] = assetCategory;
7974
7975 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
7976 groupId, parentCategoryId, name, vocabularyId,
7977 orderByComparator, false);
7978
7979 return array;
7980 }
7981 catch (Exception e) {
7982 throw processException(e);
7983 }
7984 finally {
7985 closeSession(session);
7986 }
7987 }
7988
7989 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
7990 AssetCategory assetCategory, long groupId, long parentCategoryId,
7991 String name, long vocabularyId, OrderByComparator orderByComparator,
7992 boolean previous) {
7993 StringBundler query = null;
7994
7995 if (orderByComparator != null) {
7996 query = new StringBundler(6 +
7997 (orderByComparator.getOrderByFields().length * 6));
7998 }
7999 else {
8000 query = new StringBundler(3);
8001 }
8002
8003 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8004
8005 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8006
8007 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8008
8009 if (name == null) {
8010 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8011 }
8012 else {
8013 if (name.equals(StringPool.BLANK)) {
8014 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8015 }
8016 else {
8017 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8018 }
8019 }
8020
8021 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8022
8023 if (orderByComparator != null) {
8024 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8025
8026 if (orderByConditionFields.length > 0) {
8027 query.append(WHERE_AND);
8028 }
8029
8030 for (int i = 0; i < orderByConditionFields.length; i++) {
8031 query.append(_ORDER_BY_ENTITY_ALIAS);
8032 query.append(orderByConditionFields[i]);
8033
8034 if ((i + 1) < orderByConditionFields.length) {
8035 if (orderByComparator.isAscending() ^ previous) {
8036 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8037 }
8038 else {
8039 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8040 }
8041 }
8042 else {
8043 if (orderByComparator.isAscending() ^ previous) {
8044 query.append(WHERE_GREATER_THAN);
8045 }
8046 else {
8047 query.append(WHERE_LESSER_THAN);
8048 }
8049 }
8050 }
8051
8052 query.append(ORDER_BY_CLAUSE);
8053
8054 String[] orderByFields = orderByComparator.getOrderByFields();
8055
8056 for (int i = 0; i < orderByFields.length; i++) {
8057 query.append(_ORDER_BY_ENTITY_ALIAS);
8058 query.append(orderByFields[i]);
8059
8060 if ((i + 1) < orderByFields.length) {
8061 if (orderByComparator.isAscending() ^ previous) {
8062 query.append(ORDER_BY_ASC_HAS_NEXT);
8063 }
8064 else {
8065 query.append(ORDER_BY_DESC_HAS_NEXT);
8066 }
8067 }
8068 else {
8069 if (orderByComparator.isAscending() ^ previous) {
8070 query.append(ORDER_BY_ASC);
8071 }
8072 else {
8073 query.append(ORDER_BY_DESC);
8074 }
8075 }
8076 }
8077 }
8078
8079 else {
8080 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8081 }
8082
8083 String sql = query.toString();
8084
8085 Query q = session.createQuery(sql);
8086
8087 q.setFirstResult(0);
8088 q.setMaxResults(2);
8089
8090 QueryPos qPos = QueryPos.getInstance(q);
8091
8092 qPos.add(groupId);
8093
8094 qPos.add(parentCategoryId);
8095
8096 if (name != null) {
8097 qPos.add(name);
8098 }
8099
8100 qPos.add(vocabularyId);
8101
8102 if (orderByComparator != null) {
8103 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8104
8105 for (Object value : values) {
8106 qPos.add(value);
8107 }
8108 }
8109
8110 List<AssetCategory> list = q.list();
8111
8112 if (list.size() == 2) {
8113 return list.get(1);
8114 }
8115 else {
8116 return null;
8117 }
8118 }
8119
8120
8130 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8131 long parentCategoryId, String name, long vocabularyId)
8132 throws SystemException {
8133 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
8134 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8135 }
8136
8137
8153 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8154 long parentCategoryId, String name, long vocabularyId, int start,
8155 int end) throws SystemException {
8156 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
8157 vocabularyId, start, end, null);
8158 }
8159
8160
8177 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8178 long parentCategoryId, String name, long vocabularyId, int start,
8179 int end, OrderByComparator orderByComparator) throws SystemException {
8180 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8181 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
8182 start, end, orderByComparator);
8183 }
8184
8185 StringBundler query = null;
8186
8187 if (orderByComparator != null) {
8188 query = new StringBundler(6 +
8189 (orderByComparator.getOrderByFields().length * 3));
8190 }
8191 else {
8192 query = new StringBundler(6);
8193 }
8194
8195 if (getDB().isSupportsInlineDistinct()) {
8196 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8197 }
8198 else {
8199 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8200 }
8201
8202 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8203
8204 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8205
8206 if (name == null) {
8207 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8208 }
8209 else {
8210 if (name.equals(StringPool.BLANK)) {
8211 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8212 }
8213 else {
8214 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8215 }
8216 }
8217
8218 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8219
8220 if (!getDB().isSupportsInlineDistinct()) {
8221 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8222 }
8223
8224 if (orderByComparator != null) {
8225 if (getDB().isSupportsInlineDistinct()) {
8226 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8227 orderByComparator);
8228 }
8229 else {
8230 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8231 orderByComparator);
8232 }
8233 }
8234
8235 else {
8236 if (getDB().isSupportsInlineDistinct()) {
8237 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8238 }
8239 else {
8240 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8241 }
8242 }
8243
8244 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8245 AssetCategory.class.getName(),
8246 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8247
8248 Session session = null;
8249
8250 try {
8251 session = openSession();
8252
8253 SQLQuery q = session.createSQLQuery(sql);
8254
8255 if (getDB().isSupportsInlineDistinct()) {
8256 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8257 }
8258 else {
8259 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8260 }
8261
8262 QueryPos qPos = QueryPos.getInstance(q);
8263
8264 qPos.add(groupId);
8265
8266 qPos.add(parentCategoryId);
8267
8268 if (name != null) {
8269 qPos.add(name);
8270 }
8271
8272 qPos.add(vocabularyId);
8273
8274 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8275 end);
8276 }
8277 catch (Exception e) {
8278 throw processException(e);
8279 }
8280 finally {
8281 closeSession(session);
8282 }
8283 }
8284
8285
8298 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
8299 long groupId, long parentCategoryId, String name, long vocabularyId,
8300 OrderByComparator orderByComparator)
8301 throws NoSuchCategoryException, SystemException {
8302 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8303 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
8304 parentCategoryId, name, vocabularyId, orderByComparator);
8305 }
8306
8307 AssetCategory assetCategory = findByPrimaryKey(categoryId);
8308
8309 Session session = null;
8310
8311 try {
8312 session = openSession();
8313
8314 AssetCategory[] array = new AssetCategoryImpl[3];
8315
8316 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
8317 groupId, parentCategoryId, name, vocabularyId,
8318 orderByComparator, true);
8319
8320 array[1] = assetCategory;
8321
8322 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
8323 groupId, parentCategoryId, name, vocabularyId,
8324 orderByComparator, false);
8325
8326 return array;
8327 }
8328 catch (Exception e) {
8329 throw processException(e);
8330 }
8331 finally {
8332 closeSession(session);
8333 }
8334 }
8335
8336 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
8337 AssetCategory assetCategory, long groupId, long parentCategoryId,
8338 String name, long vocabularyId, OrderByComparator orderByComparator,
8339 boolean previous) {
8340 StringBundler query = null;
8341
8342 if (orderByComparator != null) {
8343 query = new StringBundler(6 +
8344 (orderByComparator.getOrderByFields().length * 6));
8345 }
8346 else {
8347 query = new StringBundler(3);
8348 }
8349
8350 if (getDB().isSupportsInlineDistinct()) {
8351 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8352 }
8353 else {
8354 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8355 }
8356
8357 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8358
8359 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8360
8361 if (name == null) {
8362 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8363 }
8364 else {
8365 if (name.equals(StringPool.BLANK)) {
8366 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8367 }
8368 else {
8369 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8370 }
8371 }
8372
8373 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8374
8375 if (!getDB().isSupportsInlineDistinct()) {
8376 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8377 }
8378
8379 if (orderByComparator != null) {
8380 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8381
8382 if (orderByConditionFields.length > 0) {
8383 query.append(WHERE_AND);
8384 }
8385
8386 for (int i = 0; i < orderByConditionFields.length; i++) {
8387 if (getDB().isSupportsInlineDistinct()) {
8388 query.append(_ORDER_BY_ENTITY_ALIAS);
8389 }
8390 else {
8391 query.append(_ORDER_BY_ENTITY_TABLE);
8392 }
8393
8394 query.append(orderByConditionFields[i]);
8395
8396 if ((i + 1) < orderByConditionFields.length) {
8397 if (orderByComparator.isAscending() ^ previous) {
8398 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8399 }
8400 else {
8401 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8402 }
8403 }
8404 else {
8405 if (orderByComparator.isAscending() ^ previous) {
8406 query.append(WHERE_GREATER_THAN);
8407 }
8408 else {
8409 query.append(WHERE_LESSER_THAN);
8410 }
8411 }
8412 }
8413
8414 query.append(ORDER_BY_CLAUSE);
8415
8416 String[] orderByFields = orderByComparator.getOrderByFields();
8417
8418 for (int i = 0; i < orderByFields.length; i++) {
8419 if (getDB().isSupportsInlineDistinct()) {
8420 query.append(_ORDER_BY_ENTITY_ALIAS);
8421 }
8422 else {
8423 query.append(_ORDER_BY_ENTITY_TABLE);
8424 }
8425
8426 query.append(orderByFields[i]);
8427
8428 if ((i + 1) < orderByFields.length) {
8429 if (orderByComparator.isAscending() ^ previous) {
8430 query.append(ORDER_BY_ASC_HAS_NEXT);
8431 }
8432 else {
8433 query.append(ORDER_BY_DESC_HAS_NEXT);
8434 }
8435 }
8436 else {
8437 if (orderByComparator.isAscending() ^ previous) {
8438 query.append(ORDER_BY_ASC);
8439 }
8440 else {
8441 query.append(ORDER_BY_DESC);
8442 }
8443 }
8444 }
8445 }
8446
8447 else {
8448 if (getDB().isSupportsInlineDistinct()) {
8449 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8450 }
8451 else {
8452 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8453 }
8454 }
8455
8456 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8457 AssetCategory.class.getName(),
8458 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8459
8460 SQLQuery q = session.createSQLQuery(sql);
8461
8462 q.setFirstResult(0);
8463 q.setMaxResults(2);
8464
8465 if (getDB().isSupportsInlineDistinct()) {
8466 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8467 }
8468 else {
8469 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8470 }
8471
8472 QueryPos qPos = QueryPos.getInstance(q);
8473
8474 qPos.add(groupId);
8475
8476 qPos.add(parentCategoryId);
8477
8478 if (name != null) {
8479 qPos.add(name);
8480 }
8481
8482 qPos.add(vocabularyId);
8483
8484 if (orderByComparator != null) {
8485 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8486
8487 for (Object value : values) {
8488 qPos.add(value);
8489 }
8490 }
8491
8492 List<AssetCategory> list = q.list();
8493
8494 if (list.size() == 2) {
8495 return list.get(1);
8496 }
8497 else {
8498 return null;
8499 }
8500 }
8501
8502
8508 public List<AssetCategory> findAll() throws SystemException {
8509 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8510 }
8511
8512
8524 public List<AssetCategory> findAll(int start, int end)
8525 throws SystemException {
8526 return findAll(start, end, null);
8527 }
8528
8529
8542 public List<AssetCategory> findAll(int start, int end,
8543 OrderByComparator orderByComparator) throws SystemException {
8544 FinderPath finderPath = null;
8545 Object[] finderArgs = new Object[] { start, end, orderByComparator };
8546
8547 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8548 (orderByComparator == null)) {
8549 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
8550 finderArgs = FINDER_ARGS_EMPTY;
8551 }
8552 else {
8553 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
8554 finderArgs = new Object[] { start, end, orderByComparator };
8555 }
8556
8557 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
8558 finderArgs, this);
8559
8560 if (list == null) {
8561 StringBundler query = null;
8562 String sql = null;
8563
8564 if (orderByComparator != null) {
8565 query = new StringBundler(2 +
8566 (orderByComparator.getOrderByFields().length * 3));
8567
8568 query.append(_SQL_SELECT_ASSETCATEGORY);
8569
8570 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8571 orderByComparator);
8572
8573 sql = query.toString();
8574 }
8575 else {
8576 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
8577 }
8578
8579 Session session = null;
8580
8581 try {
8582 session = openSession();
8583
8584 Query q = session.createQuery(sql);
8585
8586 if (orderByComparator == null) {
8587 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8588 start, end, false);
8589
8590 Collections.sort(list);
8591 }
8592 else {
8593 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8594 start, end);
8595 }
8596 }
8597 catch (Exception e) {
8598 throw processException(e);
8599 }
8600 finally {
8601 if (list == null) {
8602 FinderCacheUtil.removeResult(finderPath, finderArgs);
8603 }
8604 else {
8605 cacheResult(list);
8606
8607 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8608 }
8609
8610 closeSession(session);
8611 }
8612 }
8613
8614 return list;
8615 }
8616
8617
8623 public void removeByUuid(String uuid) throws SystemException {
8624 for (AssetCategory assetCategory : findByUuid(uuid)) {
8625 remove(assetCategory);
8626 }
8627 }
8628
8629
8637 public AssetCategory removeByUUID_G(String uuid, long groupId)
8638 throws NoSuchCategoryException, SystemException {
8639 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
8640
8641 return remove(assetCategory);
8642 }
8643
8644
8650 public void removeByGroupId(long groupId) throws SystemException {
8651 for (AssetCategory assetCategory : findByGroupId(groupId)) {
8652 remove(assetCategory);
8653 }
8654 }
8655
8656
8662 public void removeByParentCategoryId(long parentCategoryId)
8663 throws SystemException {
8664 for (AssetCategory assetCategory : findByParentCategoryId(
8665 parentCategoryId)) {
8666 remove(assetCategory);
8667 }
8668 }
8669
8670
8676 public void removeByVocabularyId(long vocabularyId)
8677 throws SystemException {
8678 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
8679 remove(assetCategory);
8680 }
8681 }
8682
8683
8690 public void removeByG_V(long groupId, long vocabularyId)
8691 throws SystemException {
8692 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
8693 remove(assetCategory);
8694 }
8695 }
8696
8697
8704 public void removeByP_N(long parentCategoryId, String name)
8705 throws SystemException {
8706 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
8707 remove(assetCategory);
8708 }
8709 }
8710
8711
8718 public void removeByP_V(long parentCategoryId, long vocabularyId)
8719 throws SystemException {
8720 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
8721 vocabularyId)) {
8722 remove(assetCategory);
8723 }
8724 }
8725
8726
8733 public void removeByN_V(String name, long vocabularyId)
8734 throws SystemException {
8735 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
8736 remove(assetCategory);
8737 }
8738 }
8739
8740
8748 public void removeByG_P_V(long groupId, long parentCategoryId,
8749 long vocabularyId) throws SystemException {
8750 for (AssetCategory assetCategory : findByG_P_V(groupId,
8751 parentCategoryId, vocabularyId)) {
8752 remove(assetCategory);
8753 }
8754 }
8755
8756
8764 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8765 throws SystemException {
8766 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8767 vocabularyId)) {
8768 remove(assetCategory);
8769 }
8770 }
8771
8772
8781 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
8782 long vocabularyId) throws NoSuchCategoryException, SystemException {
8783 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
8784 vocabularyId);
8785
8786 return remove(assetCategory);
8787 }
8788
8789
8798 public void removeByG_P_N_V(long groupId, long parentCategoryId,
8799 String name, long vocabularyId) throws SystemException {
8800 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
8801 parentCategoryId, name, vocabularyId)) {
8802 remove(assetCategory);
8803 }
8804 }
8805
8806
8811 public void removeAll() throws SystemException {
8812 for (AssetCategory assetCategory : findAll()) {
8813 remove(assetCategory);
8814 }
8815 }
8816
8817
8824 public int countByUuid(String uuid) throws SystemException {
8825 Object[] finderArgs = new Object[] { uuid };
8826
8827 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
8828 finderArgs, this);
8829
8830 if (count == null) {
8831 StringBundler query = new StringBundler(2);
8832
8833 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8834
8835 if (uuid == null) {
8836 query.append(_FINDER_COLUMN_UUID_UUID_1);
8837 }
8838 else {
8839 if (uuid.equals(StringPool.BLANK)) {
8840 query.append(_FINDER_COLUMN_UUID_UUID_3);
8841 }
8842 else {
8843 query.append(_FINDER_COLUMN_UUID_UUID_2);
8844 }
8845 }
8846
8847 String sql = query.toString();
8848
8849 Session session = null;
8850
8851 try {
8852 session = openSession();
8853
8854 Query q = session.createQuery(sql);
8855
8856 QueryPos qPos = QueryPos.getInstance(q);
8857
8858 if (uuid != null) {
8859 qPos.add(uuid);
8860 }
8861
8862 count = (Long)q.uniqueResult();
8863 }
8864 catch (Exception e) {
8865 throw processException(e);
8866 }
8867 finally {
8868 if (count == null) {
8869 count = Long.valueOf(0);
8870 }
8871
8872 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
8873 finderArgs, count);
8874
8875 closeSession(session);
8876 }
8877 }
8878
8879 return count.intValue();
8880 }
8881
8882
8890 public int countByUUID_G(String uuid, long groupId)
8891 throws SystemException {
8892 Object[] finderArgs = new Object[] { uuid, groupId };
8893
8894 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
8895 finderArgs, this);
8896
8897 if (count == null) {
8898 StringBundler query = new StringBundler(3);
8899
8900 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8901
8902 if (uuid == null) {
8903 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
8904 }
8905 else {
8906 if (uuid.equals(StringPool.BLANK)) {
8907 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
8908 }
8909 else {
8910 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
8911 }
8912 }
8913
8914 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
8915
8916 String sql = query.toString();
8917
8918 Session session = null;
8919
8920 try {
8921 session = openSession();
8922
8923 Query q = session.createQuery(sql);
8924
8925 QueryPos qPos = QueryPos.getInstance(q);
8926
8927 if (uuid != null) {
8928 qPos.add(uuid);
8929 }
8930
8931 qPos.add(groupId);
8932
8933 count = (Long)q.uniqueResult();
8934 }
8935 catch (Exception e) {
8936 throw processException(e);
8937 }
8938 finally {
8939 if (count == null) {
8940 count = Long.valueOf(0);
8941 }
8942
8943 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
8944 finderArgs, count);
8945
8946 closeSession(session);
8947 }
8948 }
8949
8950 return count.intValue();
8951 }
8952
8953
8960 public int countByGroupId(long groupId) throws SystemException {
8961 Object[] finderArgs = new Object[] { groupId };
8962
8963 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
8964 finderArgs, this);
8965
8966 if (count == null) {
8967 StringBundler query = new StringBundler(2);
8968
8969 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8970
8971 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
8972
8973 String sql = query.toString();
8974
8975 Session session = null;
8976
8977 try {
8978 session = openSession();
8979
8980 Query q = session.createQuery(sql);
8981
8982 QueryPos qPos = QueryPos.getInstance(q);
8983
8984 qPos.add(groupId);
8985
8986 count = (Long)q.uniqueResult();
8987 }
8988 catch (Exception e) {
8989 throw processException(e);
8990 }
8991 finally {
8992 if (count == null) {
8993 count = Long.valueOf(0);
8994 }
8995
8996 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
8997 finderArgs, count);
8998
8999 closeSession(session);
9000 }
9001 }
9002
9003 return count.intValue();
9004 }
9005
9006
9013 public int filterCountByGroupId(long groupId) throws SystemException {
9014 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9015 return countByGroupId(groupId);
9016 }
9017
9018 StringBundler query = new StringBundler(2);
9019
9020 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9021
9022 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
9023
9024 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9025 AssetCategory.class.getName(),
9026 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9027
9028 Session session = null;
9029
9030 try {
9031 session = openSession();
9032
9033 SQLQuery q = session.createSQLQuery(sql);
9034
9035 q.addScalar(COUNT_COLUMN_NAME,
9036 com.liferay.portal.kernel.dao.orm.Type.LONG);
9037
9038 QueryPos qPos = QueryPos.getInstance(q);
9039
9040 qPos.add(groupId);
9041
9042 Long count = (Long)q.uniqueResult();
9043
9044 return count.intValue();
9045 }
9046 catch (Exception e) {
9047 throw processException(e);
9048 }
9049 finally {
9050 closeSession(session);
9051 }
9052 }
9053
9054
9061 public int countByParentCategoryId(long parentCategoryId)
9062 throws SystemException {
9063 Object[] finderArgs = new Object[] { parentCategoryId };
9064
9065 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
9066 finderArgs, this);
9067
9068 if (count == null) {
9069 StringBundler query = new StringBundler(2);
9070
9071 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9072
9073 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
9074
9075 String sql = query.toString();
9076
9077 Session session = null;
9078
9079 try {
9080 session = openSession();
9081
9082 Query q = session.createQuery(sql);
9083
9084 QueryPos qPos = QueryPos.getInstance(q);
9085
9086 qPos.add(parentCategoryId);
9087
9088 count = (Long)q.uniqueResult();
9089 }
9090 catch (Exception e) {
9091 throw processException(e);
9092 }
9093 finally {
9094 if (count == null) {
9095 count = Long.valueOf(0);
9096 }
9097
9098 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
9099 finderArgs, count);
9100
9101 closeSession(session);
9102 }
9103 }
9104
9105 return count.intValue();
9106 }
9107
9108
9115 public int countByVocabularyId(long vocabularyId) throws SystemException {
9116 Object[] finderArgs = new Object[] { vocabularyId };
9117
9118 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
9119 finderArgs, this);
9120
9121 if (count == null) {
9122 StringBundler query = new StringBundler(2);
9123
9124 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9125
9126 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
9127
9128 String sql = query.toString();
9129
9130 Session session = null;
9131
9132 try {
9133 session = openSession();
9134
9135 Query q = session.createQuery(sql);
9136
9137 QueryPos qPos = QueryPos.getInstance(q);
9138
9139 qPos.add(vocabularyId);
9140
9141 count = (Long)q.uniqueResult();
9142 }
9143 catch (Exception e) {
9144 throw processException(e);
9145 }
9146 finally {
9147 if (count == null) {
9148 count = Long.valueOf(0);
9149 }
9150
9151 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
9152 finderArgs, count);
9153
9154 closeSession(session);
9155 }
9156 }
9157
9158 return count.intValue();
9159 }
9160
9161
9169 public int countByG_V(long groupId, long vocabularyId)
9170 throws SystemException {
9171 Object[] finderArgs = new Object[] { groupId, vocabularyId };
9172
9173 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
9174 finderArgs, this);
9175
9176 if (count == null) {
9177 StringBundler query = new StringBundler(3);
9178
9179 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9180
9181 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
9182
9183 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
9184
9185 String sql = query.toString();
9186
9187 Session session = null;
9188
9189 try {
9190 session = openSession();
9191
9192 Query q = session.createQuery(sql);
9193
9194 QueryPos qPos = QueryPos.getInstance(q);
9195
9196 qPos.add(groupId);
9197
9198 qPos.add(vocabularyId);
9199
9200 count = (Long)q.uniqueResult();
9201 }
9202 catch (Exception e) {
9203 throw processException(e);
9204 }
9205 finally {
9206 if (count == null) {
9207 count = Long.valueOf(0);
9208 }
9209
9210 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
9211 count);
9212
9213 closeSession(session);
9214 }
9215 }
9216
9217 return count.intValue();
9218 }
9219
9220
9228 public int countByG_V(long groupId, long[] vocabularyIds)
9229 throws SystemException {
9230 Object[] finderArgs = new Object[] {
9231 groupId, StringUtil.merge(vocabularyIds)
9232 };
9233
9234 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
9235 finderArgs, this);
9236
9237 if (count == null) {
9238 StringBundler query = new StringBundler();
9239
9240 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9241
9242 boolean conjunctionable = false;
9243
9244 if (conjunctionable) {
9245 query.append(WHERE_AND);
9246 }
9247
9248 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
9249
9250 conjunctionable = true;
9251
9252 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9253 if (conjunctionable) {
9254 query.append(WHERE_AND);
9255 }
9256
9257 query.append(StringPool.OPEN_PARENTHESIS);
9258
9259 for (int i = 0; i < vocabularyIds.length; i++) {
9260 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
9261
9262 if ((i + 1) < vocabularyIds.length) {
9263 query.append(WHERE_OR);
9264 }
9265 }
9266
9267 query.append(StringPool.CLOSE_PARENTHESIS);
9268
9269 conjunctionable = true;
9270 }
9271
9272 String sql = query.toString();
9273
9274 Session session = null;
9275
9276 try {
9277 session = openSession();
9278
9279 Query q = session.createQuery(sql);
9280
9281 QueryPos qPos = QueryPos.getInstance(q);
9282
9283 qPos.add(groupId);
9284
9285 if (vocabularyIds != null) {
9286 qPos.add(vocabularyIds);
9287 }
9288
9289 count = (Long)q.uniqueResult();
9290 }
9291 catch (Exception e) {
9292 throw processException(e);
9293 }
9294 finally {
9295 if (count == null) {
9296 count = Long.valueOf(0);
9297 }
9298
9299 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
9300 finderArgs, count);
9301
9302 closeSession(session);
9303 }
9304 }
9305
9306 return count.intValue();
9307 }
9308
9309
9317 public int filterCountByG_V(long groupId, long vocabularyId)
9318 throws SystemException {
9319 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9320 return countByG_V(groupId, vocabularyId);
9321 }
9322
9323 StringBundler query = new StringBundler(3);
9324
9325 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9326
9327 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
9328
9329 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
9330
9331 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9332 AssetCategory.class.getName(),
9333 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9334
9335 Session session = null;
9336
9337 try {
9338 session = openSession();
9339
9340 SQLQuery q = session.createSQLQuery(sql);
9341
9342 q.addScalar(COUNT_COLUMN_NAME,
9343 com.liferay.portal.kernel.dao.orm.Type.LONG);
9344
9345 QueryPos qPos = QueryPos.getInstance(q);
9346
9347 qPos.add(groupId);
9348
9349 qPos.add(vocabularyId);
9350
9351 Long count = (Long)q.uniqueResult();
9352
9353 return count.intValue();
9354 }
9355 catch (Exception e) {
9356 throw processException(e);
9357 }
9358 finally {
9359 closeSession(session);
9360 }
9361 }
9362
9363
9371 public int filterCountByG_V(long groupId, long[] vocabularyIds)
9372 throws SystemException {
9373 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9374 return countByG_V(groupId, vocabularyIds);
9375 }
9376
9377 StringBundler query = new StringBundler();
9378
9379 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9380
9381 boolean conjunctionable = false;
9382
9383 if (conjunctionable) {
9384 query.append(WHERE_AND);
9385 }
9386
9387 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
9388
9389 conjunctionable = true;
9390
9391 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9392 if (conjunctionable) {
9393 query.append(WHERE_AND);
9394 }
9395
9396 query.append(StringPool.OPEN_PARENTHESIS);
9397
9398 for (int i = 0; i < vocabularyIds.length; i++) {
9399 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
9400
9401 if ((i + 1) < vocabularyIds.length) {
9402 query.append(WHERE_OR);
9403 }
9404 }
9405
9406 query.append(StringPool.CLOSE_PARENTHESIS);
9407
9408 conjunctionable = true;
9409 }
9410
9411 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9412 AssetCategory.class.getName(),
9413 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9414
9415 Session session = null;
9416
9417 try {
9418 session = openSession();
9419
9420 SQLQuery q = session.createSQLQuery(sql);
9421
9422 q.addScalar(COUNT_COLUMN_NAME,
9423 com.liferay.portal.kernel.dao.orm.Type.LONG);
9424
9425 QueryPos qPos = QueryPos.getInstance(q);
9426
9427 qPos.add(groupId);
9428
9429 if (vocabularyIds != null) {
9430 qPos.add(vocabularyIds);
9431 }
9432
9433 Long count = (Long)q.uniqueResult();
9434
9435 return count.intValue();
9436 }
9437 catch (Exception e) {
9438 throw processException(e);
9439 }
9440 finally {
9441 closeSession(session);
9442 }
9443 }
9444
9445
9453 public int countByP_N(long parentCategoryId, String name)
9454 throws SystemException {
9455 Object[] finderArgs = new Object[] { parentCategoryId, name };
9456
9457 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
9458 finderArgs, this);
9459
9460 if (count == null) {
9461 StringBundler query = new StringBundler(3);
9462
9463 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9464
9465 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
9466
9467 if (name == null) {
9468 query.append(_FINDER_COLUMN_P_N_NAME_1);
9469 }
9470 else {
9471 if (name.equals(StringPool.BLANK)) {
9472 query.append(_FINDER_COLUMN_P_N_NAME_3);
9473 }
9474 else {
9475 query.append(_FINDER_COLUMN_P_N_NAME_2);
9476 }
9477 }
9478
9479 String sql = query.toString();
9480
9481 Session session = null;
9482
9483 try {
9484 session = openSession();
9485
9486 Query q = session.createQuery(sql);
9487
9488 QueryPos qPos = QueryPos.getInstance(q);
9489
9490 qPos.add(parentCategoryId);
9491
9492 if (name != null) {
9493 qPos.add(name);
9494 }
9495
9496 count = (Long)q.uniqueResult();
9497 }
9498 catch (Exception e) {
9499 throw processException(e);
9500 }
9501 finally {
9502 if (count == null) {
9503 count = Long.valueOf(0);
9504 }
9505
9506 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
9507 count);
9508
9509 closeSession(session);
9510 }
9511 }
9512
9513 return count.intValue();
9514 }
9515
9516
9524 public int countByP_V(long parentCategoryId, long vocabularyId)
9525 throws SystemException {
9526 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
9527
9528 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
9529 finderArgs, this);
9530
9531 if (count == null) {
9532 StringBundler query = new StringBundler(3);
9533
9534 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9535
9536 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
9537
9538 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
9539
9540 String sql = query.toString();
9541
9542 Session session = null;
9543
9544 try {
9545 session = openSession();
9546
9547 Query q = session.createQuery(sql);
9548
9549 QueryPos qPos = QueryPos.getInstance(q);
9550
9551 qPos.add(parentCategoryId);
9552
9553 qPos.add(vocabularyId);
9554
9555 count = (Long)q.uniqueResult();
9556 }
9557 catch (Exception e) {
9558 throw processException(e);
9559 }
9560 finally {
9561 if (count == null) {
9562 count = Long.valueOf(0);
9563 }
9564
9565 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
9566 count);
9567
9568 closeSession(session);
9569 }
9570 }
9571
9572 return count.intValue();
9573 }
9574
9575
9583 public int countByN_V(String name, long vocabularyId)
9584 throws SystemException {
9585 Object[] finderArgs = new Object[] { name, vocabularyId };
9586
9587 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
9588 finderArgs, this);
9589
9590 if (count == null) {
9591 StringBundler query = new StringBundler(3);
9592
9593 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9594
9595 if (name == null) {
9596 query.append(_FINDER_COLUMN_N_V_NAME_1);
9597 }
9598 else {
9599 if (name.equals(StringPool.BLANK)) {
9600 query.append(_FINDER_COLUMN_N_V_NAME_3);
9601 }
9602 else {
9603 query.append(_FINDER_COLUMN_N_V_NAME_2);
9604 }
9605 }
9606
9607 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
9608
9609 String sql = query.toString();
9610
9611 Session session = null;
9612
9613 try {
9614 session = openSession();
9615
9616 Query q = session.createQuery(sql);
9617
9618 QueryPos qPos = QueryPos.getInstance(q);
9619
9620 if (name != null) {
9621 qPos.add(name);
9622 }
9623
9624 qPos.add(vocabularyId);
9625
9626 count = (Long)q.uniqueResult();
9627 }
9628 catch (Exception e) {
9629 throw processException(e);
9630 }
9631 finally {
9632 if (count == null) {
9633 count = Long.valueOf(0);
9634 }
9635
9636 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
9637 count);
9638
9639 closeSession(session);
9640 }
9641 }
9642
9643 return count.intValue();
9644 }
9645
9646
9655 public int countByG_P_V(long groupId, long parentCategoryId,
9656 long vocabularyId) throws SystemException {
9657 Object[] finderArgs = new Object[] {
9658 groupId, parentCategoryId, vocabularyId
9659 };
9660
9661 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_V,
9662 finderArgs, this);
9663
9664 if (count == null) {
9665 StringBundler query = new StringBundler(4);
9666
9667 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9668
9669 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
9670
9671 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
9672
9673 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
9674
9675 String sql = query.toString();
9676
9677 Session session = null;
9678
9679 try {
9680 session = openSession();
9681
9682 Query q = session.createQuery(sql);
9683
9684 QueryPos qPos = QueryPos.getInstance(q);
9685
9686 qPos.add(groupId);
9687
9688 qPos.add(parentCategoryId);
9689
9690 qPos.add(vocabularyId);
9691
9692 count = (Long)q.uniqueResult();
9693 }
9694 catch (Exception e) {
9695 throw processException(e);
9696 }
9697 finally {
9698 if (count == null) {
9699 count = Long.valueOf(0);
9700 }
9701
9702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_V,
9703 finderArgs, count);
9704
9705 closeSession(session);
9706 }
9707 }
9708
9709 return count.intValue();
9710 }
9711
9712
9721 public int filterCountByG_P_V(long groupId, long parentCategoryId,
9722 long vocabularyId) throws SystemException {
9723 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9724 return countByG_P_V(groupId, parentCategoryId, vocabularyId);
9725 }
9726
9727 StringBundler query = new StringBundler(4);
9728
9729 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9730
9731 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
9732
9733 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
9734
9735 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
9736
9737 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9738 AssetCategory.class.getName(),
9739 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9740
9741 Session session = null;
9742
9743 try {
9744 session = openSession();
9745
9746 SQLQuery q = session.createSQLQuery(sql);
9747
9748 q.addScalar(COUNT_COLUMN_NAME,
9749 com.liferay.portal.kernel.dao.orm.Type.LONG);
9750
9751 QueryPos qPos = QueryPos.getInstance(q);
9752
9753 qPos.add(groupId);
9754
9755 qPos.add(parentCategoryId);
9756
9757 qPos.add(vocabularyId);
9758
9759 Long count = (Long)q.uniqueResult();
9760
9761 return count.intValue();
9762 }
9763 catch (Exception e) {
9764 throw processException(e);
9765 }
9766 finally {
9767 closeSession(session);
9768 }
9769 }
9770
9771
9780 public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
9781 throws SystemException {
9782 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
9783
9784 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9785 finderArgs, this);
9786
9787 if (count == null) {
9788 StringBundler query = new StringBundler(4);
9789
9790 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9791
9792 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
9793
9794 if (name == null) {
9795 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
9796 }
9797 else {
9798 if (name.equals(StringPool.BLANK)) {
9799 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
9800 }
9801 else {
9802 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
9803 }
9804 }
9805
9806 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
9807
9808 String sql = query.toString();
9809
9810 Session session = null;
9811
9812 try {
9813 session = openSession();
9814
9815 Query q = session.createQuery(sql);
9816
9817 QueryPos qPos = QueryPos.getInstance(q);
9818
9819 qPos.add(groupId);
9820
9821 if (name != null) {
9822 qPos.add(name);
9823 }
9824
9825 qPos.add(vocabularyId);
9826
9827 count = (Long)q.uniqueResult();
9828 }
9829 catch (Exception e) {
9830 throw processException(e);
9831 }
9832 finally {
9833 if (count == null) {
9834 count = Long.valueOf(0);
9835 }
9836
9837 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9838 finderArgs, count);
9839
9840 closeSession(session);
9841 }
9842 }
9843
9844 return count.intValue();
9845 }
9846
9847<