Hi all,

Some time ago, I posted some frustration about Hibernate on 
http://blogs.cocoondev.org/tomk/archives/000744.html. By the mysterious ways of the 
linked web, Gavin gave me a hint on how to solve the issue I was having. So first of 
all, I want to thank Gavin for that.

Now I finally got to implementing his solution, but there seems to be some weird crank 
in my brain that blocks me from doing this correctly. So I'll try to give you as 
complete information as possible, and I hope that somebody can help me out on this...

I have a table that has a String as key. In the Java class, this key is 'wrapped' in 
another class, ItemID.

Following Gavin's recommendations, I've tried to wrap the key in a composite-id tag in 
the .hbm.xml:

<composite-id name="itemID" class="com.scm.escher.base.ItemID">
        <key-property name="itemID" column="ITEMID" />
</composite-id>

However, when executing the code, I get an exception with the following line that 
looks important to know what's going on (full stack trace below, in case I missed 
something):

rethrown as cirrus.hibernate.PropertyAccessException: IllegalArgumentException 
occurred calling: object is not an instance of declaring class getter of 
com.scm.escher.base.ItemID.itemID

On close investigation, it seems that the ReflectHelper.Getter wants to execute the 
ItemID.getItemId() method on a String. In my brain, this Getter should receive an 
instance of ItemID (so the correct class). Am I wrong here? Can anybody explain me 
what reasoning mistake I'm making? And what is the correct way of doing this?

Thanks a lot,
tomK


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:324)
        at cirrus.hibernate.helpers.ReflectHelper$Getter.get(ReflectHelper.java:80)
        at cirrus.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:169)
        at 
cirrus.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:175)
        at 
cirrus.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:158)
        at cirrus.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:145)
        at cirrus.hibernate.loader.Loader.prepareQueryStatement(Loader.java:425)
        at cirrus.hibernate.loader.Loader.doFind(Loader.java:145)
        at cirrus.hibernate.loader.Loader.loadEntity(Loader.java:491)
        at cirrus.hibernate.loader.EntityLoader.load(EntityLoader.java:65)
        at cirrus.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
        at cirrus.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1554)
        at cirrus.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1425)
        at cirrus.hibernate.impl.SessionImpl.load(SessionImpl.java:1363)
        at com.scm.escher.persist.StoreFactory$StoreImpl.get(StoreFactory.java:42)
        at com.klaasen.playpen.Main.getItemStockVO(Main.java:160)
        at com.klaasen.playpen.Main.main(Main.java:178)
rethrown as cirrus.hibernate.PropertyAccessException: IllegalArgumentException 
occurred calling: object is not an instance of declaring class getter of 
com.scm.escher.base.ItemID.itemID
        at cirrus.hibernate.helpers.ReflectHelper$Getter.get(ReflectHelper.java:90)
        at cirrus.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:169)
        at 
cirrus.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:175)
        at 
cirrus.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:158)
        at cirrus.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:145)
        at cirrus.hibernate.loader.Loader.prepareQueryStatement(Loader.java:425)
        at cirrus.hibernate.loader.Loader.doFind(Loader.java:145)
        at cirrus.hibernate.loader.Loader.loadEntity(Loader.java:491)
        at cirrus.hibernate.loader.EntityLoader.load(EntityLoader.java:65)
        at cirrus.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
        at cirrus.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1554)
        at cirrus.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1425)
        at cirrus.hibernate.impl.SessionImpl.load(SessionImpl.java:1363)
        at com.scm.escher.persist.StoreFactory$StoreImpl.get(StoreFactory.java:42)
        at com.klaasen.playpen.Main.getItemStockVO(Main.java:160)
        at com.klaasen.playpen.Main.main(Main.java:178)
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:324)
        at cirrus.hibernate.helpers.ReflectHelper$Getter.get(ReflectHelper.java:80)
        ... 15 more




-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Reply via email to