Permalink
Browse files

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

  • Loading branch information...
1 parent 8316367 commit 076e17e5b130f2553ad03f18025ca8644d773f4a @sebersole sebersole committed Apr 3, 2013
View
1 hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaQueryImpl.java
@@ -427,6 +427,7 @@ public void validate(Type[] returnTypes) {
}
return new CriteriaQueryTypeQueryAdapter(
+ entityManager,
jpaqlQuery,
parameterMetadata.explicitParameterMapping(),
parameterMetadata.explicitParameterNameMapping()
View
16 ...nager/src/main/java/org/hibernate/jpa/criteria/compile/CriteriaQueryTypeQueryAdapter.java
@@ -38,19 +38,23 @@
import org.hibernate.Query;
import org.hibernate.ejb.HibernateQuery;
import org.hibernate.jpa.internal.QueryImpl;
+import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
/**
* @author Steve Ebersole
*/
public class CriteriaQueryTypeQueryAdapter<X> implements TypedQuery<X>, HibernateQuery {
+ private final HibernateEntityManagerImplementor entityManager;
private final QueryImpl<X> jpaqlQuery;
private final Map<ParameterExpression<?>, String> explicitParameterMapping;
private final Map<String, ParameterExpression<?>> explicitParameterNameMapping;
public CriteriaQueryTypeQueryAdapter(
+ HibernateEntityManagerImplementor entityManager,
QueryImpl<X> jpaqlQuery,
Map<ParameterExpression<?>, String> explicitParameterMapping,
Map<String, ParameterExpression<?>> explicitParameterNameMapping) {
+ this.entityManager = entityManager;
this.jpaqlQuery = jpaqlQuery;
this.explicitParameterMapping = explicitParameterMapping;
this.explicitParameterNameMapping = explicitParameterNameMapping;
@@ -116,20 +120,24 @@ public LockModeType getLockMode() {
@SuppressWarnings({ "unchecked" })
public Set getParameters() {
+ entityManager.checkOpen( false );
return explicitParameterMapping.keySet();
}
public boolean isBound(Parameter<?> param) {
+ entityManager.checkOpen( false );
return jpaqlQuery.isBound( param );
}
@SuppressWarnings({ "unchecked" })
public <T> T getParameterValue(Parameter<T> param) {
+ entityManager.checkOpen( false );
return ( T ) jpaqlQuery.getParameterValue( mapToNamedParameter( param ) );
}
@SuppressWarnings({ "unchecked" })
public <T> TypedQuery<X> setParameter(Parameter<T> param, T t) {
+ entityManager.checkOpen( false );
jpaqlQuery.setParameter( mapToNamedParameter( param ), t );
return this;
}
@@ -143,12 +151,14 @@ private Parameter mapToNamedParameter(Parameter criteriaParameter) {
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setParameter(Parameter<Calendar> param, Calendar calendar, TemporalType temporalType) {
+ entityManager.checkOpen( false );
jpaqlQuery.setParameter( mapToNamedParameter( param ), calendar, temporalType );
return this;
}
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setParameter(Parameter<Date> param, Date date, TemporalType temporalType) {
+ entityManager.checkOpen( false );
jpaqlQuery.setParameter( mapToNamedParameter( param ), date, temporalType );
return this;
}
@@ -159,6 +169,7 @@ private Parameter mapToNamedParameter(Parameter criteriaParameter) {
@SuppressWarnings({ "unchecked" })
public Object getParameterValue(String name) {
+ entityManager.checkOpen( false );
return getParameterValue( resolveExplicitCriteriaParameterName( name ) );
}
@@ -171,11 +182,13 @@ private Parameter resolveExplicitCriteriaParameterName(String name) {
}
public Parameter<?> getParameter(String name) {
+ entityManager.checkOpen( false );
return mapToNamedParameter( resolveExplicitCriteriaParameterName( name ) );
}
@SuppressWarnings({ "unchecked" })
public <T> Parameter<T> getParameter(String name, Class<T> type) {
+ entityManager.checkOpen( false );
Parameter parameter = resolveExplicitCriteriaParameterName( name );
if ( type.isAssignableFrom( parameter.getParameterType() ) ) {
return parameter;
@@ -188,6 +201,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name) {
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setParameter(String name, Object value) {
+ entityManager.checkOpen( true );
setParameter(
resolveExplicitCriteriaParameterName( name, value ),
value
@@ -212,6 +226,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name, Object value
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setParameter(String name, Calendar calendar, TemporalType temporalType) {
+ entityManager.checkOpen( true );
Parameter parameter = resolveExplicitCriteriaParameterName( name );
if ( ! Calendar.class.isAssignableFrom( parameter.getParameterType() ) ) {
throw new IllegalArgumentException(
@@ -226,6 +241,7 @@ private Parameter resolveExplicitCriteriaParameterName(String name, Object value
@SuppressWarnings({ "unchecked" })
public TypedQuery<X> setParameter(String name, Date date, TemporalType temporalType) {
+ entityManager.checkOpen( true );
Parameter parameter = resolveExplicitCriteriaParameterName( name );
if ( ! Date.class.isAssignableFrom( parameter.getParameterType() ) ) {
throw new IllegalArgumentException(
View
2 libraries.gradle
@@ -54,7 +54,7 @@ ext {
javassist: 'org.javassist:javassist:3.15.0-GA',
// javax
- jpa: 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-14',
+ jpa: 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-16',
jta: 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Alpha1',
validation: 'javax.validation:validation-api:1.1.0.CR3',
jacc: 'org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:1.0.2.Final',

0 comments on commit 076e17e

Please sign in to comment.