BrightSide Workbench Full Report + Source Code
Dao.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.jpa;
19 
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.function.Consumer;
25 import java.util.regex.MatchResult;
26 import java.util.regex.Pattern;
27 import java.util.stream.Stream;
28 import javax.persistence.EntityManager;
29 import javax.persistence.EntityManagerFactory;
30 import javax.persistence.LockModeType;
31 import javax.persistence.NoResultException;
32 import javax.persistence.PersistenceUnitUtil;
33 import javax.persistence.Query;
34 import org.amic.util.string.MatchReplacer;
35 import org.turro.annotation.ElephantDao;
36 import org.turro.elephant.db.WhereClause;
37 import org.turro.jpa.entity.IDaoEntity;
38 import org.turro.jpa.query.AbstractJpaQuery;
39 import org.turro.jpa.query.JpaCriteriaDelete;
40 import org.turro.jpa.query.JpaCriteriaUpdate;
41 import org.turro.jpa.query.JpaQuery;
42 import org.turro.jpa.stream.DaoStream;
43 import org.turro.reflection.ClassNames;
44 import org.turro.reflection.Reflections;
45 import org.turro.sql.IDao;
46 import org.turro.sql.SqlClause;
47 
52 public abstract class Dao implements IDao {
53 
54  //private final EntityManager em;
55 
56  public Dao() {
57  //em = createEntityManager();
58  }
59 
60  @Deprecated
61  public Query createQuery(String query) {
62  return getEntityManager().createQuery(query);
63  }
64 
65  @Deprecated
66  public Query createNamedQuery(String name) {
67  return getEntityManager().createNamedQuery(name);
68  }
69 
70  @Deprecated
71  public void close() {
72 // if(em != null && em.isOpen()) {
73 // em.close();
74 // }
75  }
76 
77  @Deprecated
78  public Dao clear() {
79 // if(em != null) {
80 // em.clear();
81 // }
82  return this;
83  }
84 
85  public <T> T find(Class<T> javaClass, Object arg) {
86  T t = null;
87  if(arg != null) {
88  try(DaoManager manager = new DaoManager(this)) {
89  t = manager.find(javaClass, arg);
90  }
91  }
92  return t;
93  }
94 
95  public <T> T find(Class<T> javaClass, Object arg, DaoCallback callback) {
96  T t = null;
97  if(arg != null) {
98  try(DaoTransaction transaction = new DaoTransaction(this)) {
99  if(callback != null) {
100  callback.before(null);
101  }
102  t = transaction.find(javaClass, arg);
103  if(callback != null) {
104  callback.after(null, t);
105  }
106  }
107  }
108  return t;
109  }
110 
111  public <T> T saveObject(T obj) {
112  try(DaoTransaction transaction = new DaoTransaction(this)) {
113  return transaction.saveObject(obj);
114  }
115  }
116 
117  public <T extends IDaoEntity> T saveEntity(T entity) {
118  try(DaoTransaction transaction = new DaoTransaction(this)) {
119  if(!entity.isEmpty()) {
120  entity.prepareSave();
121  return transaction.saveObject(entity);
122  }
123  return entity;
124  }
125  }
126 
127  public void persistObject(Object obj) {
128  try(DaoTransaction transaction = new DaoTransaction(this)) {
129  transaction.persist(obj);
130  }
131  }
132 
133  public void saveEntities(Collection<? extends IDaoEntity> entities) {
134  try(DaoTransaction transaction = new DaoTransaction(this)) {
135  for(IDaoEntity entity : entities) {
136  if(!entity.isEmpty()) {
137  entity.prepareSave();
138  transaction.saveObject(entity);
139  }
140  }
141  }
142  }
143 
144  public void saveCollection(Collection objs) {
145  saveCollection(objs, null);
146  }
147 
148  public void saveCollection(Collection objs, DaoCallback callback) {
149  try(DaoTransaction transaction = new DaoTransaction(this)) {
150  for(Object obj : objs) {
151  if(callback != null) {
152  callback.before(obj);
153  }
154  Object newObj = transaction.saveObject(obj);
155  if(callback != null) {
156  callback.after(obj, newObj);
157  }
158  }
159  }
160  }
161 
162  public void deleteObject(Object obj) {
163  try(DaoTransaction transaction = new DaoTransaction(this)) {
164  transaction.remove(transaction.saveObject(obj));
165  }
166  }
167 
168  public void deleteEntity(IDaoEntity entity) {
169  try(DaoTransaction transaction = new DaoTransaction(this)) {
170  entity.prepareDelete();
171  transaction.remove(transaction.saveObject(entity));
172  }
173  }
174 
175  public void deleteCollection(Collection objs) {
176  deleteCollection(objs, null);
177  }
178 
179  public void deleteCollection(Collection objs, DaoCallback callback) {
180  try(DaoTransaction transaction = new DaoTransaction(this)) {
181  for(Object obj : objs) {
182  if(callback != null) {
183  callback.before(obj);
184  }
185  transaction.remove(transaction.saveObject(obj));
186  if(callback != null) {
187  callback.after(obj, null);
188  }
189  }
190  }
191  }
192 
193  public void deleteEntities(Collection<IDaoEntity> entities) {
194  try(DaoTransaction transaction = new DaoTransaction(this)) {
195  for(IDaoEntity entity : entities) {
196  entity.prepareDelete();
197  transaction.remove(transaction.saveObject(entity));
198  }
199  }
200  }
201 
202  public EntityManager getEntityManager() {
203  return null;
204  }
205 
206  @Deprecated
207  public EntityManager getCachedEntityManager() {
208  return createCachedEntityManager();
209  }
210 
211  public boolean isLoaded(Object o, String attribute) {
212  PersistenceUnitUtil puu = getFactory().getPersistenceUnitUtil();
213  return puu.isLoaded(o, attribute);
214  }
215 
216  public boolean isNotLoaded(Object o, String attribute) {
217  return !isLoaded(o, attribute);
218  }
219 
220  public boolean isLoaded(Object o) {
221  PersistenceUnitUtil puu = getFactory().getPersistenceUnitUtil();
222  return puu.isLoaded(o);
223  }
224 
225  public boolean isNotLoaded(Object o) {
226  return !isLoaded(o);
227  }
228 
229  public <T> List<T> getResultList(JpaQuery<T> jpaQuery) {
230  return getResultList(jpaQuery, -1, -1);
231  }
232 
233  public <T> List<T> getResultList(JpaQuery<T> jpaQuery, int max) {
234  return getResultList(jpaQuery, -1, max);
235  }
236 
237  public <T> List<T> getResultList(JpaQuery<T> jpaQuery, int start, int max) {
238  if(jpaQuery == null) return Collections.EMPTY_LIST;
239  try(DaoManager manager = new DaoManager(this)) {
240  Query q = manager.createQuery(jpaQuery.query());
241  q.setLockMode(LockModeType.NONE);
242  if(start > 0) q.setFirstResult(start);
243  if(max > 0) q.setMaxResults(max);
244  return q.getResultList();
245  }
246  }
247 
248  public <T> List<T> getResultList(Class<T> javaClass, String query) {
249  WhereClause wc = new WhereClause();
250  wc.addClause(query);
251  return getResultList(javaClass, wc, -1, -1);
252  }
253 
254  public <T> List<T> getResultList(Class<T> javaClass, String query, int max) {
255  WhereClause wc = new WhereClause();
256  wc.addClause(query);
257  return getResultList(javaClass, wc, -1, max);
258  }
259 
260  public <T> List<T> getResultList(Class<T> javaClass, String query, int start, int max) {
261  WhereClause wc = new WhereClause();
262  wc.addClause(query);
263  return getResultList(javaClass, wc, start, max);
264  }
265 
266  public <T> List<T> getResultList(Class<T> javaClass, WhereClause wc) {
267  return getResultList(javaClass, wc, -1, -1);
268  }
269 
270  public <T> List<T> getResultList(Class<T> javaClass, WhereClause wc, int max) {
271  return getResultList(javaClass, wc, -1, max);
272  }
273 
274  public <T> List<T> getResultList(Class<T> javaClass, WhereClause wc, int start, int max) {
275  if(wc == null) return Collections.EMPTY_LIST;
276  try(DaoManager manager = new DaoManager(this)) {
277  Query q = manager.createQuery(wc.getClause(), javaClass);
278  q.setLockMode(LockModeType.NONE);
279  wc.setNamedParameters(q);
280  if(start > 0) q.setFirstResult(start);
281  if(max > 0) q.setMaxResults(max);
282  return q.getResultList();
283  }
284  }
285 
286  @Override
287  public <T> List<T> getResultList(Class<T> javaClass, SqlClause sc) {
288  return getResultList(javaClass, sc, -1, -1);
289  }
290 
291  @Override
292  public <T> List<T> getResultList(Class<T> javaClass, SqlClause sc, int max) {
293  return getResultList(javaClass, sc, -1, max);
294  }
295 
296  @Override
297  public <T> List<T> getResultList(Class<T> javaClass, SqlClause sc, int start, int max) {
298  if(sc == null) return Collections.EMPTY_LIST;
299  try(DaoManager manager = new DaoManager(this)) {
300  Query q = manager.createQuery(sc.clause(), javaClass);
301  q.setLockMode(LockModeType.NONE);
302  manager.setNamedParameters(q, sc.getNamedValues());
303  if(start > 0) q.setFirstResult(start);
304  if(max > 0) q.setMaxResults(max);
305  return q.getResultList();
306  }
307  }
308 
309  public List getResultList(WhereClause wc) {
310  return getResultList(wc, -1, -1);
311  }
312 
313  public List getResultList(WhereClause wc, int max) {
314  return getResultList(wc, -1, max);
315  }
316 
317  public List getResultList(WhereClause wc, int start, int max) {
318  if(wc == null) return Collections.EMPTY_LIST;
319  try(DaoManager manager = new DaoManager(this)) {
320  Query q = wc.isUseNative() ?
321  manager.createNativeQuery(wc.getClause(), wc.getResultClass()) :
322  manager.createQuery(wc.getClause());
323  if(!wc.isUseNative()) q.setLockMode(LockModeType.NONE);
324  wc.setNamedParameters(q);
325  if(start > 0) q.setFirstResult(start);
326  if(max > 0) q.setMaxResults(max);
327  return q.getResultList();
328  }
329  }
330 
331  @Override
332  public List getResultList(SqlClause sc) {
333  return getResultList(sc, -1, -1);
334  }
335 
336  @Override
337  public List getResultList(SqlClause sc, int max) {
338  return getResultList(sc, -1, max);
339  }
340 
341  @Override
342  public List getResultList(SqlClause sc, int start, int max) {
343  if(sc == null) return Collections.EMPTY_LIST;
344  try(DaoManager manager = new DaoManager(this)) {
345  Query q = manager.createQuery(sc.clause());
346  q.setLockMode(LockModeType.NONE);
347  manager.setNamedParameters(q, sc.getNamedValues());
348  if(start > 0) q.setFirstResult(start);
349  if(max > 0) q.setMaxResults(max);
350  return q.getResultList();
351  }
352  }
353 
354  public List getResultList(String query) {
355  return getResultList(query, null);
356  }
357 
358  public List getResultList(String query, int max) {
359  return getResultList(query, null, max);
360  }
361 
362  public List getResultList(String query, Object[] pars) {
363  return getResultList(query, pars, -1);
364  }
365 
366  public List getResultList(String query, Object[] pars, int max) {
367  try(DaoManager manager = new DaoManager(this)) {
368  Query q = manager.createQuery(toJpaPositional(query));
369  q.setLockMode(LockModeType.NONE);
370  if(max > 0) q.setMaxResults(max);
371  if(pars != null) {
372  for(int i = 0; i < pars.length; i++) {
373  q.setParameter(i + 1, pars[i]);
374  }
375  }
376  return q.getResultList();
377  }
378  }
379 
380  public Object getSingleResult(WhereClause wc) {
381  try(DaoManager manager = new DaoManager(this)) {
382  Query q = wc.isUseNative() ?
383  manager.createNativeQuery(wc.getClause()) :
384  manager.createQuery(wc.getClause());
385  if(!wc.isUseNative()) q.setLockMode(LockModeType.NONE);
386  wc.setNamedParameters(q);
387  return q.getSingleResult();
388  }
389  }
390 
391  @Override
392  public Object getSingleResult(SqlClause sc) {
393  try(DaoManager manager = new DaoManager(this)) {
394  Query q = manager.createQuery(sc.clause());
395  q.setLockMode(LockModeType.NONE);
396  manager.setNamedParameters(q, sc.getNamedValues());
397  return q.getSingleResult();
398  }
399  }
400 
401  public Object getSingleResult(String query) {
402  return getSingleResult(query, null);
403  }
404 
405  public Object getSingleResult(String query, Object[] pars) {
406  try(DaoManager manager = new DaoManager(this)) {
407  Query q = manager.createQuery(toJpaPositional(query));
408  q.setLockMode(LockModeType.NONE);
409  if(pars != null) {
410  for(int i = 0; i < pars.length; i++) {
411  q.setParameter(i + 1, pars[i]);
412  }
413  }
414  return q.getSingleResult();
415  }
416  }
417 
418  @Override
419  public Object getSingleResultOrNull(SqlClause sc) {
420  try {
421  return getSingleResult(sc);
422  } catch(NoResultException ex) {
423  return null;
424  }
425  }
426 
427  public Object getSingleResultOrNull(WhereClause wc) {
428  try {
429  return getSingleResult(wc);
430  } catch(NoResultException ex) {
431  return null;
432  }
433  }
434 
435  public Object getSingleResultOrNull(String query) {
436  return getSingleResultOrNull(query, null);
437  }
438 
439  public Object getSingleResultOrNull(String query, Object[] pars) {
440  try {
441  return getSingleResult(query, pars);
442  } catch(NoResultException ex) {
443  return null;
444  }
445  }
446 
447  public Object getSingleNativeResult(String query) {
448  return getSingleNativeResult(query, null);
449  }
450 
451  public Object getSingleNativeResult(String query, Object[] pars) {
452  try(DaoManager manager = new DaoManager(this)) {
453  Query q = manager.createNativeQuery(toJpaPositional(query));
454  if(pars != null) {
455  for(int i = 0; i < pars.length; i++) {
456  q.setParameter(i + 1, pars[i]);
457  }
458  }
459  return q.getSingleResult();
460  }
461  }
462 
463  public int executeUpdate(String query) {
464  return executeUpdate(query, null);
465  }
466 
467  public int executeUpdate(String query, Object[] pars) {
468  try(DaoTransaction transaction = new DaoTransaction(this)) {
469  Query q = transaction.createQuery(toJpaPositional(query));
470  if(pars != null) {
471  for(int i = 0; i < pars.length; i++) {
472  q.setParameter(i + 1, pars[i]);
473  }
474  }
475  int res = q.executeUpdate();
476  return res;
477  }
478  }
479 
480  public int executeDelete(JpaCriteriaDelete jpaCriteriaDelete) {
481  List<JpaCriteriaDelete> list = new ArrayList<>();
482  list.add(jpaCriteriaDelete);
483  return executeDelete(list);
484  }
485 
486  public int executeDelete(Collection<JpaCriteriaDelete> jpaCriteriaDeletes) {
487  if(jpaCriteriaDeletes == null || jpaCriteriaDeletes.isEmpty()) return 0;
488  try(DaoTransaction transaction = new DaoTransaction(this)) {
489  int res = 0;
490  for(JpaCriteriaDelete jpaCriteriaDelete : jpaCriteriaDeletes) {
491  Query q = transaction.createQuery(jpaCriteriaDelete.delete());
492  res += q.executeUpdate();
493  }
494  return res;
495  }
496  }
497 
498  public int executeUpdate(JpaCriteriaUpdate jpaCriteriaUpdate) {
499  List<JpaCriteriaUpdate> list = new ArrayList<>();
500  list.add(jpaCriteriaUpdate);
501  return executeUpdate(list);
502  }
503 
504  public int executeUpdate(Collection<JpaCriteriaUpdate> jpaCriteriaUpdates) {
505  if(jpaCriteriaUpdates == null || jpaCriteriaUpdates.isEmpty()) return 0;
506  try(DaoTransaction transaction = new DaoTransaction(this)) {
507  int res = 0;
508  for(JpaCriteriaUpdate jpaCriteriaUpdate : jpaCriteriaUpdates) {
509  Query q = transaction.createQuery(jpaCriteriaUpdate.update());
510  res += q.executeUpdate();
511  }
512  return res;
513  }
514  }
515 
516  public int executeUpdate(WhereClause wc) {
517  try(DaoTransaction transaction = new DaoTransaction(this)) {
518  Query q = transaction.createQuery(wc.getClause());
519  wc.setNamedParameters(q);
520  int res = q.executeUpdate();
521  return res;
522  }
523  }
524 
525  @Override
526  public int executeUpdate(SqlClause sc) {
527  try(DaoTransaction transaction = new DaoTransaction(this)) {
528  Query q = transaction.createQuery(sc.clause());
529  transaction.setNamedParameters(q, sc.getNamedValues());
530  int res = q.executeUpdate();
531  return res;
532  }
533  }
534 
535  @Override
536  public int executeNativeUpdate(SqlClause sc, Object... pars) {
537  return executeNativeUpdate(sc.clause(), pars);
538  }
539 
540  public int executeNativeUpdate(String query, Object... pars) {
541  try(DaoTransaction transaction = new DaoTransaction(this)) {
542  Query q = transaction.createNativeQuery(toJpaPositional(query));
543  if(pars != null) {
544  for(int i = 0; i < pars.length; i++) {
545  q.setParameter(i + 1, pars[i]);
546  }
547  }
548  int res = q.executeUpdate();
549  return res;
550  }
551  }
552 
553  protected abstract EntityManagerFactory getFactory();
554  protected abstract EntityManager createEntityManager();
555  public abstract String getPath(Object object);
556 
557  @Deprecated
558  protected abstract EntityManager createCachedEntityManager();
559 
560  public <T> T lazyLoader(Class<T> javaClass, Object proxy, String property) {
561  return (T) getSingleResult(
562  "select c from " + javaClass.getSimpleName() +
563  " c left join fetch c." + property + " where c = ?",
564  new Object[] { proxy });
565  }
566 
567  public static String toJpaPositional(String query) {
568  MatchReplacer replacer = new MatchReplacer(Pattern.compile("\\?")) {
569  int i = 1;
570  @Override public String replacement(MatchResult m) {
571  return "$0" + i++;
572  }
573  };
574  return replacer.replace(query);
575  }
576 
577  /* Pool objects */
578 
579  private Collection pool;
580 
581  public void poolObject(Object obj, int poolSize) {
582  if(pool == null) {
583  pool = new ArrayList();
584  }
585  pool.add(obj);
586  if(pool.size() >= poolSize) {
587  saveCollection(pool);
588  pool.clear();
589  }
590  }
591 
592  public void finishPool() {
593  if(pool != null && pool.size() > 0) {
594  saveCollection(pool);
595  }
596  pool = null;
597  }
598 
599 
600  /* Streams */
601 
602  public <T> Stream<T> stream(Class<T> javaClass, String query) {
603  return new DaoStream<T>(this, query).stream();
604  }
605 
606  public <T> Stream<T> stream(Class<T> javaClass, String query, int bacthSize) {
607  return new DaoStream<T>(this, query).stream(bacthSize);
608  }
609 
610  public <T> Stream<T> stream(Class<T> javaClass, WhereClause wc) {
611  return new DaoStream<T>(this, wc).stream();
612  }
613 
614  public <T> Stream<T> stream(Class<T> javaClass, WhereClause wc, int bacthSize) {
615  return new DaoStream<T>(this, wc).stream(bacthSize);
616  }
617 
618  @Override
619  public <T> Stream<T> stream(Class<T> javaClass, SqlClause sc) {
620  return new DaoStream<T>(this, sc).stream();
621  }
622 
623  public <T> Stream<T> stream(Class<T> javaClass, SqlClause sc, int bacthSize) {
624  return new DaoStream<T>(this, sc).stream(bacthSize);
625  }
626 
627  public <T> Stream<T> stream(Class<T> javaClass, AbstractJpaQuery<T> query) {
628  return new DaoStream<>(this, query).stream();
629  }
630 
631  public <T> Stream<T> stream(Class<T> javaClass, AbstractJpaQuery<T> query, int bacthSize) {
632  return new DaoStream<>(this, query).stream(bacthSize);
633  }
634 
635  public <T> void forEach(Class<T> javaClass, String query, Consumer<T> action) {
636  new DaoStream<T>(this, query).forEach(action);
637  }
638 
639  public <T> void forEach(Class<T> javaClass, WhereClause wc, Consumer<T> action) {
640  new DaoStream<T>(this, wc).forEach(action);
641  }
642 
643  @Override
644  public <T> void forEach(Class<T> javaClass, SqlClause sc, Consumer<T> action) {
645  new DaoStream<T>(this, sc).forEach(action);
646  }
647 
648  public <T> void forEach(Class<T> javaClass, AbstractJpaQuery<T> query, Consumer<T> action) {
649  new DaoStream<>(this, query).forEach(action);
650  }
651 
652  /* Elephant Daos */
653 
654  public static Dao getDaoByPU(String pu) {
655  for(String className : ClassNames.cached().byAnnotation(ElephantDao.class.getName())) {
656  Class javaClass = Reflections.of(className).is(Dao.class).returnClass();
657  if(javaClass != null) {
658  if(((ElephantDao) javaClass.getAnnotation(ElephantDao.class)).pu().equals(pu)) {
659  return (Dao) Reflections.of(javaClass).instance();
660  }
661  }
662  }
663  return null;
664  }
665 
666 }
List getResultList(SqlClause sc)
Definition: Dao.java:332
List getResultList(String query, Object[] pars)
Definition: Dao.java:362
List getResultList(WhereClause wc, int max)
Definition: Dao.java:313
List getResultList(String query, int max)
Definition: Dao.java:358
List getResultList(SqlClause sc, int start, int max)
Definition: Dao.java:342
int executeDelete(JpaCriteriaDelete jpaCriteriaDelete)
Definition: Dao.java:480
boolean isLoaded(Object o)
Definition: Dao.java:220
abstract EntityManager createCachedEntityManager()
Object getSingleResult(SqlClause sc)
Definition: Dao.java:392
int executeDelete(Collection< JpaCriteriaDelete > jpaCriteriaDeletes)
Definition: Dao.java:486
int executeUpdate(String query, Object[] pars)
Definition: Dao.java:467
void close()
Definition: Dao.java:71
abstract String getPath(Object object)
int executeUpdate(JpaCriteriaUpdate jpaCriteriaUpdate)
Definition: Dao.java:498
int executeUpdate(WhereClause wc)
Definition: Dao.java:516
List getResultList(String query, Object[] pars, int max)
Definition: Dao.java:366
Object getSingleNativeResult(String query)
Definition: Dao.java:447
void deleteObject(Object obj)
Definition: Dao.java:162
void persistObject(Object obj)
Definition: Dao.java:127
Object getSingleResultOrNull(WhereClause wc)
Definition: Dao.java:427
void deleteCollection(Collection objs, DaoCallback callback)
Definition: Dao.java:179
int executeNativeUpdate(String query, Object... pars)
Definition: Dao.java:540
Object getSingleResult(String query)
Definition: Dao.java:401
EntityManager getEntityManager()
Definition: Dao.java:202
Object getSingleNativeResult(String query, Object[] pars)
Definition: Dao.java:451
List getResultList(SqlClause sc, int max)
Definition: Dao.java:337
abstract EntityManagerFactory getFactory()
void deleteEntity(IDaoEntity entity)
Definition: Dao.java:168
int executeUpdate(String query)
Definition: Dao.java:463
boolean isLoaded(Object o, String attribute)
Definition: Dao.java:211
void saveCollection(Collection objs, DaoCallback callback)
Definition: Dao.java:148
List getResultList(String query)
Definition: Dao.java:354
boolean isNotLoaded(Object o)
Definition: Dao.java:225
int executeUpdate(SqlClause sc)
Definition: Dao.java:526
void saveCollection(Collection objs)
Definition: Dao.java:144
abstract EntityManager createEntityManager()
EntityManager getCachedEntityManager()
Definition: Dao.java:207
Query createNamedQuery(String name)
Definition: Dao.java:66
Dao clear()
Definition: Dao.java:78
int executeUpdate(Collection< JpaCriteriaUpdate > jpaCriteriaUpdates)
Definition: Dao.java:504
void deleteCollection(Collection objs)
Definition: Dao.java:175
Object getSingleResult(WhereClause wc)
Definition: Dao.java:380
List getResultList(WhereClause wc, int start, int max)
Definition: Dao.java:317
Object getSingleResult(String query, Object[] pars)
Definition: Dao.java:405
Query createQuery(String query)
Definition: Dao.java:61
void poolObject(Object obj, int poolSize)
Definition: Dao.java:581
Object getSingleResultOrNull(SqlClause sc)
Definition: Dao.java:419
static String toJpaPositional(String query)
Definition: Dao.java:567
static Dao getDaoByPU(String pu)
Definition: Dao.java:654
Object getSingleResultOrNull(String query)
Definition: Dao.java:435
void finishPool()
Definition: Dao.java:592
void deleteEntities(Collection< IDaoEntity > entities)
Definition: Dao.java:193
boolean isNotLoaded(Object o, String attribute)
Definition: Dao.java:216
List getResultList(WhereClause wc)
Definition: Dao.java:309
int executeNativeUpdate(SqlClause sc, Object... pars)
Definition: Dao.java:536
void saveEntities(Collection<? extends IDaoEntity > entities)
Definition: Dao.java:133
Object getSingleResultOrNull(String query, Object[] pars)
Definition: Dao.java:439
void before(Object value)
void after(Object oldValue, Object newValue)