Hibernate version:
3.1.2
I am writing a utility to export and import data between the database
and XML.
I have the output part going, for example:
<class name="com.myorg.export.Detail" node="Detail" table="WDetail" >
<id name="FID" type="int" unsaved-value="0">
<generator class="assigned"/>
</id>
<property name="TID" type="int"/>
<property name="displayName" type="string"/>
</class>
Note that I have a class mapping _and_ use the node attribute to
format the XML output. This appears to be in line with the
intended use of session.getSession(EntityMode.DOM4J).
The overall mapping of course is much more complex than this...
For input from XML, I create a dom4J session, and
call
session.update(el);
for the 'Detail' Element from my XML tree.
For that I get:
org.hibernate.MappingException: Unknown entity: Detail
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:513)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1321)
Q: shouldn't the SessionFactory be able to work out that 'Detail' is the node name used in conjunction with class "com.myorg.export.Detail"?
Is this a reasonable feature request?
How would I implement it?
I realize that the when I use
entity-name="Detail"
all is well, except that I just lost the ability to map my class "com.myorg.export.Detail", which I don't like.
Also interesting is the fact that if I change the node attribute to
node="Detail2"
then the session still insists on finding a 'Detail' Element,
which is, in my mind, semantically incorrect.
Has anybody experience with this type of usage of the XML feature in H3?
Should I just go an enhance my classes to be able to instantiate
from the XML to avoid the problems I'm hitting?
|