[
https://hibernate.onjira.com/browse/HHH-5964?page=com.atlassian.jira.plug...
]
Sebastian Hasait edited comment on HHH-5964 at 4/11/12 3:54 AM:
----------------------------------------------------------------
Longer ago we applied the following patch (Variant 1a from above):
{code}
---
/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...
{code}
was (Author: shasait):
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@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