david wrote:
class2hbm is no longer supported and is/has been dropped from Hibernate 3.x and on. I'm not aware of any (other) tools that can do this - in anycase there is not enough information in a class file to do it well. Why don't you generate them from the database - use Middlegen.
I use wsdl or xsd documents as my design tool and find both axis wsdl compiler and castor xsd compiler very useful. In time I will move furtehr up the design tree to uml and xmi.
However from my playing around with collections and associations, I am not sure how feasible this approach is.
Initially everything went well. With an xml element that contained just an array of other elements, the composite-element relationship approach mentioned in the Parent/Child example (ch 16) worked really well.
However when the nested xml element itself had nested elements, the composite-element does not work (I think this is what caused the class2hbm to blow up).
In theory I could use a bidirectional one-to-many construct in the child classes to handle this, but then I have to generate a reference back to the parent xml element in the child xml element which feels clumsy. The only way I could get this to work is to declare the parent element to be minOccurs="0" and fill in the reference property in the generated java bean before I do the hibernate save; it feels very clumsy.
Do you think creating mapping files for generated axis or castor classes is feasible?
Is there any one else out there using wsdl or xsd compiler to generate beans that are mapped into hibernate?
James