[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-572) @Node(name=, embedXml=true|false) for DOM4J

Stephane Epardaud (JIRA) noreply at atlassian.com
Fri Jan 4 10:12:56 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29233 ] 

Stephane Epardaud commented on ANN-572:
---------------------------------------

I've made a patch to allow for this, since we do need it.
I'm using @Node.value instead of name so that it works without specifying the embedXML attribute: @Node("Foo").
I suspect the hbm.xml overriding is missing in the EJB3OverridenAnnotationReader, but this file is so overwhelming I didn't dare touch it.
In order to be able to specify the element name for a collection I've also added @ElementNode which is the same as @Node, but can be set for collections:

 @Node("Foos")
 @ElementNode("Foo")
 List<Foo> foos;

There may be some mappings missing for certain types of properties, since we do not use every possible property type in our project, but I've verified it works for at least SimpleValue, Component, Collection, ManyToOne, and simple ids.
When I say it works, I haven't tried to run code with it since I'd like to have some feedback from people with more insight on the code before I trust it with my data. But what we do now is I've patched hibernate-tools to print the node and embed-xml attributes with the hbm2hbmxml ant task, so that we generate our entities' hbm.xml files from the annotations using the patched hibernate-annotations and hibernate-tools, and use these hbm.xml files in our production environment. That way they are easy to check for defects, and they are actually correct: they get the correct embed-xml and node attributes from the annotations, so in all likelyhood it should be possible to do away with hbm.xml files and only use annotations to generate XML.
When I tried to do this though I noticed a few strange things:
>From an annotated file, the types of properties (as seen from their output in generated hbm.xml files) differ from those we would use when writing hbm.xml files:
 - a @Lob String would have type="org.hibernate.type.StringClobType" instead of type="text", which should be the same.
 - most other primitive types would have class names instead of hbm names: java.lang.String instead of string, java.util.TimeZone instead of timezone, java.util.Date instead of date, java.lang.Long instead of long...
I don't know if these are an issue, but the StringClobType was an issue for me, since hibernate tried to cast it to an ExtendedUserType, which it was not.

> @Node(name=, embedXml=true|false) for DOM4J
> -------------------------------------------
>
>                 Key: ANN-572
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-572
>             Project: Hibernate Annotations
>          Issue Type: Improvement
>          Components: binder
>            Reporter: Emmanuel Bernard
>         Attachments: hibernate-node-annotation.zip
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list