[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5964) IllegalArgumentException (Parameter value ... was not matching type ...) for JPA-Query: Worked with 3.3.1.GA

Sebastian Hasait (JIRA) noreply at atlassian.com
Wed Apr 11 04:52:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-5964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46236#comment-46236 ] 

Sebastian Hasait commented on HHH-5964:
---------------------------------------

Longer ago we applied the following patch (Variant 1a from above):

--- /org.hibernate/hibernate-entitymanager/3.6.1.Final/org/hibernate/ejb/AbstractQueryImpl.java	2011-01-25 12:54:39.000000000 +0000
+++ /org.hibernate/hibernate-entitymanager/3.6.1.Final.patched/org/hibernate/ejb/AbstractQueryImpl.java	2011-02-25 17:36:33.000000000 +0200
@@ -331,7 +331,7 @@
 	private Map parameterBindings;
 
 	protected void registerParameterBinding(Parameter parameter, Object value) {
-		if ( value != null && parameter.getParameterType() != null ) {
+		if ( value != null && parameter.getParameterType() != null && (!(value instanceof HibernateProxy)) ) {
 			if ( Collection.class.isInstance( value ) ) {
 				final Collection collection = (Collection) value;
 				// validate the elements...


> IllegalArgumentException (Parameter value ... was not matching type ...) for JPA-Query: Worked with 3.3.1.GA
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5964
>                 URL: https://hibernate.onjira.com/browse/HHH-5964
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: entity-manager
>    Affects Versions: 3.6.1
>            Reporter: Sebastian Hasait
>         Attachments: hb.hhh5964.zip
>
>
> We have switched from core-3.3.1.GA and entity-manager-3.4.0.GA to 3.6.1.Final.
> Now some queries stopped working.
> This is caused by an additional type check in org.hibernate.ejb.AbstractQueryImpl#registerParameterBinding at 359 which does not care about hibernate-proxies. This method is called from QueryImpl#setParameter(...). This call doesn't exist in 3.4.0.GA.
> I think the proxies should be as transparent as possible. So if I get a proxy from some relation getter and put this into a query as parameter, there should be no exception.
> Because the proxy cannot know the concrete type without initializing the proxy-target (reading discriminator from database) there remain four solutions:
> 1.) Hibernate is not checking the type for proxies OR only ensures expected type and proxy-type are related.
> 2.) Hibernate initializes the parameter and the type checking works without exception.
> 3.) Our DAO initializes the parameter before passing.
> 4.) We rewrite our queries to pass only the PK
> I would prefer 1 or 2. :-)
> Will attach test case asap.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list