Adding attributes to hibernate mapping file
If I decorate the hibernate mapping xml file with additional attributes of my own is there a way to access the开发者_C百科se via the hibernate meta-model or would I have to access the xml document directly?
for instance:
<class entity-name="..." ....>
...
<property name="name" column="name" type="string" myNamespace:customAttr="someVal" />
</class>
Is there a way to access the "customAttr" ?
It might not be an option in your context, but I would recommend specifying the meta-model by annotating model classes with JavaEE javax.persistence
annotations.
That way you can easily add your custom attributes as custom annotations.
I don't think hibernate supports it. Why don't you define your own XML to put up your attributes to avoid any clashes and headaches you might face in the future? Besides, it is not a good approach either!!! And when the Hibernate API is validating the XML, it won't take that, so you'll end up having to define your own XML.
精彩评论