19 package org.turro.jpa.query;
21 import javax.persistence.criteria.CollectionJoin;
22 import javax.persistence.criteria.CriteriaUpdate;
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;
33 import javax.persistence.metamodel.SingularAttribute;
41 private final Class<E> persistentClass;
43 private CriteriaUpdate<E> criteriaUpdate;
47 this.persistentClass = persistentClass;
48 this.jpaCriteria = jpaCriteria;
53 return criteriaUpdate;
58 public <Y, X extends Y>
JpaCriteriaUpdate<E> set(SingularAttribute<? super E, Y> attribute, X value) {
59 criteriaUpdate.set(attribute, value);
63 public <Y>
JpaCriteriaUpdate<E> set(SingularAttribute<? super E, Y> attribute, Expression<? extends Y> value) {
64 criteriaUpdate.set(attribute, value);
68 public <Y, X extends Y> JpaCriteriaUpdate<E>
set(Path<Y> attribute, X value) {
69 criteriaUpdate.set(attribute, value);
73 public <Y> JpaCriteriaUpdate<E>
set(Path<Y> attribute, Expression<? extends Y> value) {
74 criteriaUpdate.set(attribute, value);
79 criteriaUpdate.set(attributeName, value);
84 criteriaUpdate.where(restriction);
89 criteriaUpdate.where(restrictions);
94 return new JpaSubquery<>(javaClass, criteriaUpdate.subquery(javaClass));
98 return criteriaUpdate.getRestriction();
103 public Path
field(String fieldName) {
104 return root.get(fieldName);
107 public Selection<E>
alias(String name) {
108 return root.alias(name);
111 public <X, Y> Join<X, Y> join(String attributeName) {
112 return root.join(attributeName);
115 public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName) {
116 return root.joinCollection(attributeName);
119 public <X, Y> SetJoin<X, Y> joinSet(String attributeName) {
120 return root.joinSet(attributeName);
123 public <X, Y> ListJoin<X, Y> joinList(String attributeName) {
124 return root.joinList(attributeName);
127 public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName) {
128 return root.joinMap(attributeName);
131 public <X, Y> Join<X, Y> join(String attributeName, JoinType jt) {
132 return root.join(attributeName, jt);
135 public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
136 return root.joinCollection(attributeName, jt);
139 public <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
140 return root.joinSet(attributeName, jt);
143 public <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
144 return root.joinList(attributeName, jt);
147 public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
148 return root.joinMap(attributeName, jt);
151 private void initCriteria() {
152 criteriaUpdate = jpaCriteria.
builder().createCriteriaUpdate(persistentClass);
153 root = criteriaUpdate.from(persistentClass);
JpaCriteriaUpdate(Class< E > persistentClass, JpaCriteria jpaCriteria)
JpaCriteriaUpdate< E > where(Predicate... restrictions)
Path field(String fieldName)
Selection< E > alias(String name)
Predicate getRestriction()
CriteriaUpdate< E > update()
JpaCriteriaUpdate< E > where(Expression< Boolean > restriction)
CriteriaBuilder builder()