Skip to content

Commit

Permalink
HHH-9160 - javax.persistence.Query#getParameterValue(String) returns …
Browse files Browse the repository at this point in the history
…the ParameterRegistration not the parameter value

(cherry picked from commit eb2f333)
  • Loading branch information
sebersole committed Oct 30, 2015
1 parent 691d872 commit 315e57c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/**
* Models basic query structure. Used as a delegate in implementing both
* {@link org.hibernate.criterion.CriteriaQuery} and
* {@link javax.persistence.criteria.CriteriaQuery} and
* {@link javax.persistence.criteria.Subquery}.
* <p/>
* Note the <tt>ORDER BY</tt> specs are neglected here. That's because it is not valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public <T> T unwrap(Class<T> cls) {
public Object getParameterValue(String name) {
entityManager.checkOpen( false );
locateParameterByName( name );
return jpqlQuery.getParameter( name );
return jpqlQuery.getParameterValue( name );
}

private ExplicitParameterInfo locateParameterByName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

/**
* @author Steve Ebersole
Expand All @@ -37,6 +39,7 @@ public void testPrimitiveArrayParameterBinding() {
criteria.where( em.getCriteriaBuilder().equal( someBytesPath, param ) );
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
query.setParameter( param, new byte[] { 1,1,1 } );
assertThat( query.getParameterValue( param.getName() ), instanceOf( byte[].class) );
query.getResultList();
em.getTransaction().commit();
em.close();
Expand All @@ -54,6 +57,7 @@ public void testNonPrimitiveArrayParameterBinding() {
criteria.where( em.getCriteriaBuilder().equal( thePath, param ) );
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
query.setParameter( param, new Byte[] { Byte.valueOf((byte)1), Byte.valueOf((byte)1), Byte.valueOf((byte)1) } );
assertThat( query.getParameterValue( param.getName() ), instanceOf( Byte[].class ) );
query.getResultList();
em.getTransaction().commit();
em.close();
Expand Down

0 comments on commit 315e57c

Please sign in to comment.