Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

HHH-7957 - Integrate Latest draft(s) of the JPA 2.1 spec

  • Loading branch information...
commit 076e17e5b130f2553ad03f18025ca8644d773f4a 1 parent 8316367
Steve Ebersole authored April 02, 2013
1  hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaQueryImpl.java
@@ -427,6 +427,7 @@ public void validate(Type[] returnTypes) {
427 427
 				}
428 428
 
429 429
 				return new CriteriaQueryTypeQueryAdapter(
  430
+						entityManager,
430 431
 						jpaqlQuery,
431 432
 						parameterMetadata.explicitParameterMapping(),
432 433
 						parameterMetadata.explicitParameterNameMapping()
16  hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/compile/CriteriaQueryTypeQueryAdapter.java
@@ -38,19 +38,23 @@
38 38
 import org.hibernate.Query;
39 39
 import org.hibernate.ejb.HibernateQuery;
40 40
 import org.hibernate.jpa.internal.QueryImpl;
  41
+import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
41 42
 
42 43
 /**
43 44
  * @author Steve Ebersole
44 45
  */
45 46
 public class CriteriaQueryTypeQueryAdapter<X> implements TypedQuery<X>, HibernateQuery {
  47
+	private final HibernateEntityManagerImplementor entityManager;
46 48
 	private final QueryImpl<X> jpaqlQuery;
47 49
 	private final Map<ParameterExpression<?>, String> explicitParameterMapping;
48 50
 	private final Map<String, ParameterExpression<?>> explicitParameterNameMapping;
49 51
 
50 52
 	public CriteriaQueryTypeQueryAdapter(
  53
+			HibernateEntityManagerImplementor entityManager,
51 54
 			QueryImpl<X> jpaqlQuery,
52 55
 			Map<ParameterExpression<?>, String> explicitParameterMapping,
53 56
 			Map<String, ParameterExpression<?>> explicitParameterNameMapping) {
  57
+		this.entityManager = entityManager;
54 58
 		this.jpaqlQuery = jpaqlQuery;
55 59
 		this.explicitParameterMapping = explicitParameterMapping;
56 60
 		this.explicitParameterNameMapping = explicitParameterNameMapping;
@@ -116,20 +120,24 @@ public LockModeType getLockMode() {
116 120
 
117 121
 	@SuppressWarnings({ "unchecked" })
118 122
 	public Set getParameters() {
  123
+		entityManager.checkOpen( false );
119 124
 		return explicitParameterMapping.keySet();
120 125
 	}
121 126
 
122 127
 	public boolean isBound(Parameter<?> param) {
  128
+		entityManager.checkOpen( false );
123 129
 		return jpaqlQuery.isBound( param );
124 130
 	}
125 131
 
126 132
 	@SuppressWarnings({ "unchecked" })
127 133
 	public <T> T getParameterValue(Parameter<T> param) {
  134
+		entityManager.checkOpen( false );
128 135
 		return ( T ) jpaqlQuery.getParameterValue( mapToNamedParameter( param ) );
129 136
 	}
130 137
 
131 138
 	@SuppressWarnings({ "unchecked" })
132 139
 	public <T> TypedQuery<X> setParameter(Parameter<T> param, T t) {
  140
+		entityManager.checkOpen( false );
133 141
 		jpaqlQuery.setParameter( mapToNamedParameter( param ), t );
134 142
 		return this;
135 143
 	}
@@ -143,12 +151,14 @@ private Parameter mapToNamedParameter(Parameter criteriaParameter) {
143 151
 
144 152
 	@SuppressWarnings({ "unchecked" })
145 153
 	public TypedQuery<X> setParameter(Parameter<Calendar> param, Calendar calendar, TemporalType temporalType) {
  154
+		entityManager.checkOpen( false );
146 155
 		jpaqlQuery.setParameter( mapToNamedParameter( param ), calendar, temporalType );
147 156
 		return this;
148 157
 	}
149 158
 
150 159
 	@SuppressWarnings({ "unchecked" })
151 160
 	public TypedQuery<X> setParameter(Parameter<Date> param, Date date, TemporalType temporalType) {
  161
+		entityManager.checkOpen( false );
152 162
 		jpaqlQuery.setParameter( mapToNamedParameter( param ), date, temporalType );
153 163
 		return this;
154 164
 	}
@@ -159,6 +169,7 @@ private Parameter mapToNamedParameter(Parameter criteriaParameter) {
159 169
 
160 170
 	@SuppressWarnings({ "unchecked" })
161 171
 	public Object getParameterValue(String name) {
  172
+		entityManager.checkOpen( false );
162 173
 		return getParameterValue( resolveExplicitCriteriaParameterName( name ) );
163 174
 	}
164 175
 
@@ -171,11 +182,13 @@ private Parameter resolveExplicitCriteriaParameterName(String name) {
171 182
 	}
172 183
 
173 184
 	public Parameter<?> getParameter(String name) {
  185
+		entityManager.checkOpen( false );
174 186
 		return mapToNamedParameter( resolveExplicitCriteriaParameterName( name ) );
175 187
 	}
176 188
 
177 189
 	@SuppressWarnings({ "unchecked" })
178 190
 	public <T> Parameter<T> getParameter(String name, Class<T> type) {
  191
+		entityManager.checkOpen( false );
179 192
 		Parameter parameter = resolveExplicitCriteriaParameterName( name );
180 193
 		if ( type.isAssignableFrom( parameter.getParameterType() ) ) {
181 194
 			return parameter;
@@ -188,6 +201,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name) {
188 201
 
189 202
 	@SuppressWarnings({ "unchecked" })
190 203
 	public TypedQuery<X> setParameter(String name, Object value) {
  204
+		entityManager.checkOpen( true );
191 205
 		setParameter(
192 206
 				resolveExplicitCriteriaParameterName( name, value ),
193 207
 				value
@@ -212,6 +226,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name, Object value
212 226
 
213 227
 	@SuppressWarnings({ "unchecked" })
214 228
 	public TypedQuery<X> setParameter(String name, Calendar calendar, TemporalType temporalType) {
  229
+		entityManager.checkOpen( true );
215 230
 		Parameter parameter = resolveExplicitCriteriaParameterName( name );
216 231
 		if ( ! Calendar.class.isAssignableFrom( parameter.getParameterType() ) ) {
217 232
 			throw new IllegalArgumentException(
@@ -226,6 +241,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name, Object value
226 241
 
227 242
 	@SuppressWarnings({ "unchecked" })
228 243
 	public TypedQuery<X> setParameter(String name, Date date, TemporalType temporalType) {
  244
+		entityManager.checkOpen( true );
229 245
 		Parameter parameter = resolveExplicitCriteriaParameterName( name );
230 246
 		if ( ! Date.class.isAssignableFrom( parameter.getParameterType() ) ) {
231 247
 			throw new IllegalArgumentException(
2  libraries.gradle
@@ -54,7 +54,7 @@ ext {
54 54
             javassist:      'org.javassist:javassist:3.15.0-GA',
55 55
 
56 56
             // javax
57  
-            jpa:            'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-14',
  57
+            jpa:            'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-16',
58 58
             jta:            'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Alpha1',
59 59
             validation:     'javax.validation:validation-api:1.1.0.CR3',
60 60
             jacc:           'org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:1.0.2.Final',

0 notes on commit 076e17e

Please sign in to comment.
Something went wrong with that request. Please try again.