I tried to upgrade from hibernate 3.3.1 to 3.3.2, and some working code stopped to work.
The following criteria search is still working as expected:
Code:
List<DonneeDynamique> list = mySession.createCriteria(DonneeDynamique.class).add(
Restrictions.eq("clefScada", new ClefScada("s", "d", "d","a"))).list();
However, as soon as I add a
setCacheable(true) instruction, there is an IllegalArgumentException exception:
Code:
List<DonneeDynamique> list = mySession.createCriteria(DonneeDynamique.class).add(
Restrictions.eq("clefScada", new ClefScada("s", "d", "d","a"))).setCacheable(true).list();
The simplified class relations is as follow:
Code:
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DonneeDynamique {
private ClefScada clefScada;
@Embedded
public ClefScada getClefScada() {
return clefScada;
}
private String otherField;
//... other things
}
@Embeddable
public class ClefScada {
private String substation;
private String deviceType;
private String device;
private String analog;
//... getters, setters, etc
}
Please note that if I try a criteria search using an attribute that is not an @Embeddable, (such as the string "otherField" in the class DonneeDynamique, there is no problem adding the setCacheable(true) statement.
The complete stack trace is as follow:
14:10:29,599ERROR BasicPropertyAccessor:191 - IllegalArgumentException in class: ca.qc.xxx.jcommun.domaine.ClefScada, getter method of property: analog
14:10:29,599ERROR DonneeDynamiqueHibernateTest:65 - IllegalArgumentException occurred calling getter of ca.qc.xxx.jcommun.domaine.ClefScada.analog
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of ca.qc.xxx.jcommun.domaine.ClefScada.analog
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:87)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:93)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:109)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:376)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:194)
at org.hibernate.cache.QueryKey.generateHashCode(QueryKey.java:194)
at org.hibernate.cache.QueryKey.<init>(QueryKey.java:173)
at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:128)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2144)
at org.hibernate.loader.Loader.list(Loader.java:2121)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at ca.qc.xxx.jdshe.dao.DonneeDynamiqueHibernateTest.testTest(DonneeDynamiqueHibernateTest.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
... 34 more
Any help would be appreciated,
Thanks,