1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchUserTrackerPathException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.dao.DynamicQuery;
28 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.model.UserTrackerPath;
33 import com.liferay.portal.model.impl.UserTrackerPathImpl;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37
38 import com.liferay.util.dao.hibernate.QueryUtil;
39
40 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42
43 import org.hibernate.Query;
44 import org.hibernate.Session;
45
46 import java.util.Collections;
47 import java.util.Iterator;
48 import java.util.List;
49
50
56 public class UserTrackerPathPersistenceImpl extends BasePersistence
57 implements UserTrackerPathPersistence {
58 public UserTrackerPath create(long userTrackerPathId) {
59 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
60 userTrackerPath.setNew(true);
61 userTrackerPath.setPrimaryKey(userTrackerPathId);
62
63 return userTrackerPath;
64 }
65
66 public UserTrackerPath remove(long userTrackerPathId)
67 throws NoSuchUserTrackerPathException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
74 new Long(userTrackerPathId));
75
76 if (userTrackerPath == null) {
77 if (_log.isWarnEnabled()) {
78 _log.warn("No UserTrackerPath exists with the primary key " +
79 userTrackerPathId);
80 }
81
82 throw new NoSuchUserTrackerPathException(
83 "No UserTrackerPath exists with the primary key " +
84 userTrackerPathId);
85 }
86
87 return remove(userTrackerPath);
88 }
89 catch (NoSuchUserTrackerPathException nsee) {
90 throw nsee;
91 }
92 catch (Exception e) {
93 throw HibernateUtil.processException(e);
94 }
95 finally {
96 closeSession(session);
97 }
98 }
99
100 public UserTrackerPath remove(UserTrackerPath userTrackerPath)
101 throws SystemException {
102 Session session = null;
103
104 try {
105 session = openSession();
106 session.delete(userTrackerPath);
107 session.flush();
108
109 return userTrackerPath;
110 }
111 catch (Exception e) {
112 throw HibernateUtil.processException(e);
113 }
114 finally {
115 closeSession(session);
116 FinderCache.clearCache(UserTrackerPath.class.getName());
117 }
118 }
119
120 public UserTrackerPath update(
121 com.liferay.portal.model.UserTrackerPath userTrackerPath)
122 throws SystemException {
123 return update(userTrackerPath, false);
124 }
125
126 public UserTrackerPath update(
127 com.liferay.portal.model.UserTrackerPath userTrackerPath, boolean merge)
128 throws SystemException {
129 Session session = null;
130
131 try {
132 session = openSession();
133
134 if (merge) {
135 session.merge(userTrackerPath);
136 }
137 else {
138 if (userTrackerPath.isNew()) {
139 session.save(userTrackerPath);
140 }
141 }
142
143 session.flush();
144 userTrackerPath.setNew(false);
145
146 return userTrackerPath;
147 }
148 catch (Exception e) {
149 throw HibernateUtil.processException(e);
150 }
151 finally {
152 closeSession(session);
153 FinderCache.clearCache(UserTrackerPath.class.getName());
154 }
155 }
156
157 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
158 throws NoSuchUserTrackerPathException, SystemException {
159 UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
160
161 if (userTrackerPath == null) {
162 if (_log.isWarnEnabled()) {
163 _log.warn("No UserTrackerPath exists with the primary key " +
164 userTrackerPathId);
165 }
166
167 throw new NoSuchUserTrackerPathException(
168 "No UserTrackerPath exists with the primary key " +
169 userTrackerPathId);
170 }
171
172 return userTrackerPath;
173 }
174
175 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
176 throws SystemException {
177 Session session = null;
178
179 try {
180 session = openSession();
181
182 return (UserTrackerPath)session.get(UserTrackerPathImpl.class,
183 new Long(userTrackerPathId));
184 }
185 catch (Exception e) {
186 throw HibernateUtil.processException(e);
187 }
188 finally {
189 closeSession(session);
190 }
191 }
192
193 public List findByUserTrackerId(long userTrackerId)
194 throws SystemException {
195 String finderClassName = UserTrackerPath.class.getName();
196 String finderMethodName = "findByUserTrackerId";
197 String[] finderParams = new String[] { Long.class.getName() };
198 Object[] finderArgs = new Object[] { new Long(userTrackerId) };
199 Object result = FinderCache.getResult(finderClassName,
200 finderMethodName, finderParams, finderArgs, getSessionFactory());
201
202 if (result == null) {
203 Session session = null;
204
205 try {
206 session = openSession();
207
208 StringMaker query = new StringMaker();
209 query.append(
210 "FROM com.liferay.portal.model.UserTrackerPath WHERE ");
211 query.append("userTrackerId = ?");
212 query.append(" ");
213
214 Query q = session.createQuery(query.toString());
215 int queryPos = 0;
216 q.setLong(queryPos++, userTrackerId);
217
218 List list = q.list();
219 FinderCache.putResult(finderClassName, finderMethodName,
220 finderParams, finderArgs, list);
221
222 return list;
223 }
224 catch (Exception e) {
225 throw HibernateUtil.processException(e);
226 }
227 finally {
228 closeSession(session);
229 }
230 }
231 else {
232 return (List)result;
233 }
234 }
235
236 public List findByUserTrackerId(long userTrackerId, int begin, int end)
237 throws SystemException {
238 return findByUserTrackerId(userTrackerId, begin, end, null);
239 }
240
241 public List findByUserTrackerId(long userTrackerId, int begin, int end,
242 OrderByComparator obc) throws SystemException {
243 String finderClassName = UserTrackerPath.class.getName();
244 String finderMethodName = "findByUserTrackerId";
245 String[] finderParams = new String[] {
246 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
247 "com.liferay.portal.kernel.util.OrderByComparator"
248 };
249 Object[] finderArgs = new Object[] {
250 new Long(userTrackerId), String.valueOf(begin),
251 String.valueOf(end), String.valueOf(obc)
252 };
253 Object result = FinderCache.getResult(finderClassName,
254 finderMethodName, finderParams, finderArgs, getSessionFactory());
255
256 if (result == null) {
257 Session session = null;
258
259 try {
260 session = openSession();
261
262 StringMaker query = new StringMaker();
263 query.append(
264 "FROM com.liferay.portal.model.UserTrackerPath WHERE ");
265 query.append("userTrackerId = ?");
266 query.append(" ");
267
268 if (obc != null) {
269 query.append("ORDER BY ");
270 query.append(obc.getOrderBy());
271 }
272
273 Query q = session.createQuery(query.toString());
274 int queryPos = 0;
275 q.setLong(queryPos++, userTrackerId);
276
277 List list = QueryUtil.list(q, getDialect(), begin, end);
278 FinderCache.putResult(finderClassName, finderMethodName,
279 finderParams, finderArgs, list);
280
281 return list;
282 }
283 catch (Exception e) {
284 throw HibernateUtil.processException(e);
285 }
286 finally {
287 closeSession(session);
288 }
289 }
290 else {
291 return (List)result;
292 }
293 }
294
295 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
296 OrderByComparator obc)
297 throws NoSuchUserTrackerPathException, SystemException {
298 List list = findByUserTrackerId(userTrackerId, 0, 1, obc);
299
300 if (list.size() == 0) {
301 StringMaker msg = new StringMaker();
302 msg.append("No UserTrackerPath exists with the key ");
303 msg.append(StringPool.OPEN_CURLY_BRACE);
304 msg.append("userTrackerId=");
305 msg.append(userTrackerId);
306 msg.append(StringPool.CLOSE_CURLY_BRACE);
307 throw new NoSuchUserTrackerPathException(msg.toString());
308 }
309 else {
310 return (UserTrackerPath)list.get(0);
311 }
312 }
313
314 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
315 OrderByComparator obc)
316 throws NoSuchUserTrackerPathException, SystemException {
317 int count = countByUserTrackerId(userTrackerId);
318 List list = findByUserTrackerId(userTrackerId, count - 1, count, obc);
319
320 if (list.size() == 0) {
321 StringMaker msg = new StringMaker();
322 msg.append("No UserTrackerPath exists with the key ");
323 msg.append(StringPool.OPEN_CURLY_BRACE);
324 msg.append("userTrackerId=");
325 msg.append(userTrackerId);
326 msg.append(StringPool.CLOSE_CURLY_BRACE);
327 throw new NoSuchUserTrackerPathException(msg.toString());
328 }
329 else {
330 return (UserTrackerPath)list.get(0);
331 }
332 }
333
334 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
335 long userTrackerPathId, long userTrackerId, OrderByComparator obc)
336 throws NoSuchUserTrackerPathException, SystemException {
337 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
338 int count = countByUserTrackerId(userTrackerId);
339 Session session = null;
340
341 try {
342 session = openSession();
343
344 StringMaker query = new StringMaker();
345 query.append("FROM com.liferay.portal.model.UserTrackerPath WHERE ");
346 query.append("userTrackerId = ?");
347 query.append(" ");
348
349 if (obc != null) {
350 query.append("ORDER BY ");
351 query.append(obc.getOrderBy());
352 }
353
354 Query q = session.createQuery(query.toString());
355 int queryPos = 0;
356 q.setLong(queryPos++, userTrackerId);
357
358 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
359 userTrackerPath);
360 UserTrackerPath[] array = new UserTrackerPathImpl[3];
361 array[0] = (UserTrackerPath)objArray[0];
362 array[1] = (UserTrackerPath)objArray[1];
363 array[2] = (UserTrackerPath)objArray[2];
364
365 return array;
366 }
367 catch (Exception e) {
368 throw HibernateUtil.processException(e);
369 }
370 finally {
371 closeSession(session);
372 }
373 }
374
375 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
376 throws SystemException {
377 Session session = null;
378
379 try {
380 session = openSession();
381
382 DynamicQuery query = queryInitializer.initialize(session);
383
384 return query.list();
385 }
386 catch (Exception e) {
387 throw HibernateUtil.processException(e);
388 }
389 finally {
390 closeSession(session);
391 }
392 }
393
394 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
395 int begin, int end) throws SystemException {
396 Session session = null;
397
398 try {
399 session = openSession();
400
401 DynamicQuery query = queryInitializer.initialize(session);
402 query.setLimit(begin, end);
403
404 return query.list();
405 }
406 catch (Exception e) {
407 throw HibernateUtil.processException(e);
408 }
409 finally {
410 closeSession(session);
411 }
412 }
413
414 public List findAll() throws SystemException {
415 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
416 }
417
418 public List findAll(int begin, int end) throws SystemException {
419 return findAll(begin, end, null);
420 }
421
422 public List findAll(int begin, int end, OrderByComparator obc)
423 throws SystemException {
424 String finderClassName = UserTrackerPath.class.getName();
425 String finderMethodName = "findAll";
426 String[] finderParams = new String[] {
427 "java.lang.Integer", "java.lang.Integer",
428 "com.liferay.portal.kernel.util.OrderByComparator"
429 };
430 Object[] finderArgs = new Object[] {
431 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
432 };
433 Object result = FinderCache.getResult(finderClassName,
434 finderMethodName, finderParams, finderArgs, getSessionFactory());
435
436 if (result == null) {
437 Session session = null;
438
439 try {
440 session = openSession();
441
442 StringMaker query = new StringMaker();
443 query.append("FROM com.liferay.portal.model.UserTrackerPath ");
444
445 if (obc != null) {
446 query.append("ORDER BY ");
447 query.append(obc.getOrderBy());
448 }
449
450 Query q = session.createQuery(query.toString());
451 List list = QueryUtil.list(q, getDialect(), begin, end);
452
453 if (obc == null) {
454 Collections.sort(list);
455 }
456
457 FinderCache.putResult(finderClassName, finderMethodName,
458 finderParams, finderArgs, list);
459
460 return list;
461 }
462 catch (Exception e) {
463 throw HibernateUtil.processException(e);
464 }
465 finally {
466 closeSession(session);
467 }
468 }
469 else {
470 return (List)result;
471 }
472 }
473
474 public void removeByUserTrackerId(long userTrackerId)
475 throws SystemException {
476 Iterator itr = findByUserTrackerId(userTrackerId).iterator();
477
478 while (itr.hasNext()) {
479 UserTrackerPath userTrackerPath = (UserTrackerPath)itr.next();
480 remove(userTrackerPath);
481 }
482 }
483
484 public void removeAll() throws SystemException {
485 Iterator itr = findAll().iterator();
486
487 while (itr.hasNext()) {
488 remove((UserTrackerPath)itr.next());
489 }
490 }
491
492 public int countByUserTrackerId(long userTrackerId)
493 throws SystemException {
494 String finderClassName = UserTrackerPath.class.getName();
495 String finderMethodName = "countByUserTrackerId";
496 String[] finderParams = new String[] { Long.class.getName() };
497 Object[] finderArgs = new Object[] { new Long(userTrackerId) };
498 Object result = FinderCache.getResult(finderClassName,
499 finderMethodName, finderParams, finderArgs, getSessionFactory());
500
501 if (result == null) {
502 Session session = null;
503
504 try {
505 session = openSession();
506
507 StringMaker query = new StringMaker();
508 query.append("SELECT COUNT(*) ");
509 query.append(
510 "FROM com.liferay.portal.model.UserTrackerPath WHERE ");
511 query.append("userTrackerId = ?");
512 query.append(" ");
513
514 Query q = session.createQuery(query.toString());
515 int queryPos = 0;
516 q.setLong(queryPos++, userTrackerId);
517
518 Long count = null;
519 Iterator itr = q.list().iterator();
520
521 if (itr.hasNext()) {
522 count = (Long)itr.next();
523 }
524
525 if (count == null) {
526 count = new Long(0);
527 }
528
529 FinderCache.putResult(finderClassName, finderMethodName,
530 finderParams, finderArgs, count);
531
532 return count.intValue();
533 }
534 catch (Exception e) {
535 throw HibernateUtil.processException(e);
536 }
537 finally {
538 closeSession(session);
539 }
540 }
541 else {
542 return ((Long)result).intValue();
543 }
544 }
545
546 public int countAll() throws SystemException {
547 String finderClassName = UserTrackerPath.class.getName();
548 String finderMethodName = "countAll";
549 String[] finderParams = new String[] { };
550 Object[] finderArgs = new Object[] { };
551 Object result = FinderCache.getResult(finderClassName,
552 finderMethodName, finderParams, finderArgs, getSessionFactory());
553
554 if (result == null) {
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 StringMaker query = new StringMaker();
561 query.append("SELECT COUNT(*) ");
562 query.append("FROM com.liferay.portal.model.UserTrackerPath");
563
564 Query q = session.createQuery(query.toString());
565 Long count = null;
566 Iterator itr = q.list().iterator();
567
568 if (itr.hasNext()) {
569 count = (Long)itr.next();
570 }
571
572 if (count == null) {
573 count = new Long(0);
574 }
575
576 FinderCache.putResult(finderClassName, finderMethodName,
577 finderParams, finderArgs, count);
578
579 return count.intValue();
580 }
581 catch (Exception e) {
582 throw HibernateUtil.processException(e);
583 }
584 finally {
585 closeSession(session);
586 }
587 }
588 else {
589 return ((Long)result).intValue();
590 }
591 }
592
593 protected void initDao() {
594 }
595
596 private static Log _log = LogFactory.getLog(UserTrackerPathPersistenceImpl.class);
597 }