19 package org.turro.jpa.query;
21 import javax.persistence.criteria.CollectionJoin;
22 import javax.persistence.criteria.CriteriaDelete;
23 import javax.persistence.criteria.Expression;
24 import javax.persistence.criteria.Join;
25 import javax.persistence.criteria.JoinType;
26 import javax.persistence.criteria.ListJoin;
27 import javax.persistence.criteria.MapJoin;
28 import javax.persistence.criteria.Path;
29 import javax.persistence.criteria.Predicate;
30 import javax.persistence.criteria.Root;
31 import javax.persistence.criteria.Selection;
32 import javax.persistence.criteria.SetJoin;
40 private final Class<E> persistentClass;
42 private CriteriaDelete<E> criteriaDelete;
46 this.persistentClass = persistentClass;
47 this.jpaCriteria = jpaCriteria;
51 public CriteriaDelete<E>
delete() {
52 return criteriaDelete;
58 criteriaDelete.where(restriction);
63 criteriaDelete.where(restrictions);
68 return new JpaSubquery<>(javaClass, criteriaDelete.subquery(javaClass));
72 return criteriaDelete.getRestriction();
77 public Path
field(String fieldName) {
78 return root.get(fieldName);
81 public Selection<E>
alias(String name) {
82 return root.alias(name);
85 public <X, Y> Join<X, Y> join(String attributeName) {
86 return root.join(attributeName);
89 public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName) {
90 return root.joinCollection(attributeName);
93 public <X, Y> SetJoin<X, Y> joinSet(String attributeName) {
94 return root.joinSet(attributeName);
97 public <X, Y> ListJoin<X, Y> joinList(String attributeName) {
98 return root.joinList(attributeName);
101 public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName) {
102 return root.joinMap(attributeName);
105 public <X, Y> Join<X, Y> join(String attributeName, JoinType jt) {
106 return root.join(attributeName, jt);
109 public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
110 return root.joinCollection(attributeName, jt);
113 public <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
114 return root.joinSet(attributeName, jt);
117 public <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
118 return root.joinList(attributeName, jt);
121 public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
122 return root.joinMap(attributeName, jt);
125 private void initCriteria() {
126 criteriaDelete = jpaCriteria.
builder().createCriteriaDelete(persistentClass);
127 root = criteriaDelete.from(persistentClass);
JpaCriteriaDelete(Class< E > persistentClass, JpaCriteria jpaCriteria)
JpaCriteriaDelete< E > where(Expression< Boolean > restriction)
JpaCriteriaDelete< E > where(Predicate... restrictions)
Selection< E > alias(String name)
Path field(String fieldName)
Predicate getRestriction()
CriteriaBuilder builder()