-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Entity Manager API Criteria with Embedded Object
PostPosted: Wed Feb 23, 2011 10:48 am 
Newbie

Joined: Wed Apr 26, 2006 1:10 pm
Posts: 14
Hi all,

I'm trying to migrate hibernate 3.3.1.GA to 3.6.1.Final but I've got some strange problem here is the case :

Code:
class A {
   @Embedded
   @AttributeOverrides( { @AttributeOverride(name = "value", column = @Column(name = "B", nullable = false)) })
    private B b;

}

@Embeddable
class B {
    @Column(name = "value", insertable = true, updatable = true)
    private String value;

    or

    private String value;

    @Column(name = "value", insertable = true, updatable = true)
    public String getValue() {
   return value;
    }

    public void setValue(String value) {
   this.value = value;
    }
}

Session sess = (Session) entityManager.getDelegate();
Criteria criteria = sess.createCriteria(A.class);
criteria.add(Restrictions.eq("b","Instance of B");
criteria.list();


With Hibernate 3.6.1
1. If i run, it works No Exception
2. But if i change last line with :
Code:
criteria.setCacheable(true).list();


With Hibernate 3.3.1.GA
1. OK
2. OK

I've got this exception :

org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.smalltox.business.model.persistent.impl.enumerations.VehicleEnergyEnumeration.value
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:62)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:77)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:83)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:108)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:386)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:204)
at org.hibernate.cache.QueryKey.generateHashCode(QueryKey.java:201)
at org.hibernate.cache.QueryKey.<init>(QueryKey.java:176)
at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:131)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2291)
at org.hibernate.loader.Loader.list(Loader.java:2268)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at com.smalltox.business.model.persistent.QueryTest.test1(QueryTest.java:31)
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.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field com.smalltox.foundation.model.enumeration.Enumeration.value to [Ljava.lang.Object;
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
at java.lang.reflect.Field.get(Field.java:358)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:59)
... 37 more

With Hibernate 3.6.1, it fails.
With Hibernate 3.3.1.GA, it works.

Can someone confirm this problem ? Any ideas ?

Thanks

Sébastien Boutté


Top
 Profile  
 
 Post subject: Re: Hibernate Entity Manager API Criteria with Embedded Object
PostPosted: Fri Feb 25, 2011 4:48 am 
Newbie

Joined: Wed Apr 26, 2006 1:10 pm
Posts: 14
Any Help ? Should i open a JIRA ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.