-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Reflection -- Bean Properties
PostPosted: Thu Sep 11, 2003 11:45 pm 
Newbie

Joined: Thu Sep 11, 2003 10:54 pm
Posts: 2
From all indications within the hibernate documentation it appears that it supports bean property type mappings, but when I attempt to use a nested composite identifier I can't figure out how to accomplish this. Here is an example of a mapping that I would like to be able to create.

Code:
<class name="eg.Foo" table"FOOS">
    <composite-id name="compId" class="eg.FooCompositeID">
        <key-property name="test.string"/>
        <key-property name="test.short"/>
    </composite-id>
</class>


I have searched high and low within the hibernate documentation on how to accomplish such a task and have been unable to figure out how to do so. I realize that one of my problems is that I am using a composite identity, which Hibernate's philosophy is generally against. :) But unfortunately the decision to use a composite identifier has already been made.

A solution to this problem is rather simple due to the good design of creating a reflection helper class. Here is a sample of a change to the ReflectHelper class that would make this possible.

Code:
private static Method getterMethod(Class theClass, String propertyName) {
return
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(java.lang.Object bean, java.lang.String name) .getReadMethod();

}


Obviously this is pseudo code, but it displays the utilization of the PropertyUtils class(part of the Jakarta Commons) that can return simple, nested, indexed, mapped, and combined type of properties from a bean.

Please let me know if a change like this would be necessary / possible, or if there is another solution to this type of an example besides using a CompositeUserType. I find that the CompositeUserType does not offer enough dynamic flexibility when used on a large scale basis. Everything within the class must be hard coded.

Thanks in advance,

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 12:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate does not support this, for various sensible reasons. Usually you can do it using nested <component> mappings, but this is not available in a composite id.

And we will NOT use slow, buggy beanutils for this! Our own reflection implementation is MUCH faster and more robust.


Top
 Profile  
 
 Post subject: Hibernate Reflection -- Bean Properties
PostPosted: Fri Sep 12, 2003 10:52 am 
Newbie

Joined: Thu Sep 11, 2003 10:54 pm
Posts: 2
If it wouldn't be too much trouble please enlighten me as to why this is such an insensible approach? I really see no other work around for a nested compositeId such as this.

As for the performance of the Beanutils, I cannot attest to whether it is faster than your approach, but does it really matter since the operations are performed in a one time only initialization. From there on out you simply just store the method....correct me if I'm wrong. As far as the bugginess of this beanutils package is concerned, please elaborate?

Thanks again,

Dan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.