Hibernate version: hibernate-3.1
Mapping documents:
<hibernate-mapping>
<class entity-name="TvlyProperty" table="Property_Locale_Search" node=".">
<composite-id>
<key-property name="PropertyNbr" node="PropertyHeader/@PropertyID" type="string" column="Property_Nbr"/>
<key-property name="SupplierCode" node="PropertyHeader/@SupplierCode" type="string" column="Supplier_Code"/>
<key-property name="LocaleID" node="PropertyHeader/@LocaleID" type="string" column="Locale_ID"/>
</composite-id>
<property name="Name" type="string" node="Attribute_PROPTY_LONGNM/@value" column="Name"/>
<property name="Address1" type="string" node="Attribute_PROPTY_ADDR1/@value" column="Address1"/>
<property name="Address2" type="string" node="Attribute_PROPTY_ADDR2/@value" column="Address2"/>
<property name="City" type="string" node="Attribute_PROPTY_CITY/@value" column="City"/>
<property name="StateOrProvince" type="string" node="Attribute_PROPTY_POSTCD/@value" column="State_Or_Province"/>
<property name="ZipCode" type="string" node="Attribute_PROPTY_POSTCD/@value" column="ZIP_CODE"/>
<property name="OneLineDesc" type="string" node="Texts_PROPTY_DESC/@value" column="ONE_LINE_DESCR"/>
<property name="FullDesc" type="string" node="Texts_LEGPOL_GENERAL/@value" column="FULL_DESC"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Session session = sessionFactory.openSession();
Session dom4jSession = session.getSession( EntityMode.DOM4J );
Transaction transaction = session.beginTransaction();
SAXReader saxReader = new SAXReader();
Document document = saxReader.read("c:\\program files\\exist\\tempDataFile_1.xml");
Element element = document.getRootElement().element("DocumentRoot");
System.out.println("\n\n Document Root found :: " + element);
dom4jSession.saveOrUpdate("TvlyProperty", element);
transaction.commit();
session.close();
Full stack trace of any exception that occurs:
Document Root found :: org.dom4j.tree.DefaultElement@111ded2 [Element: <Documen
tRoot attributes: []/>]
TuplizerLookup.guessEntityMode:: Object is :: org.dom4j.tree.DefaultElement@111d
ed2 [Element: <DocumentRoot attributes: []/>]
java.lang.ClassCastException: org.dom4j.tree.DefaultElement
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:
279)
at org.hibernate.pretty.MessageHelper.infoString(MessageHelper.java:68)
at org.hibernate.persister.entity.BasicEntityPersister.getDatabaseSnapsh
ot(BasicEntityPersister.java:860)
at org.hibernate.engine.PersistenceContext.getDatabaseSnapshot(Persisten
ceContext.java:302)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:189)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(Abst
ractSaveEventListener.java:409)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveO
rUpdate(DefaultSaveOrUpdateEventListener.java:82)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.test.dom4j.TvlyPersist.persistFromfile(TvlyPersist.java
:173)
at org.exist.examples.xmldb.XqueryToHibernate.main(XqueryToHibernate.jav
a:21)
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
None
Debug level Hibernate log excerpt:
**********************************************************
I am using eXist as my XML data source and I query the XML document from eXist and use Hibernate to persist to Oracle. Hibernate throws the above exception whenever I try to run this in the same VM as eXist XML retrieval code. But, when I run this program in a separate VM the same code works fine although some times I get the above exception when I try more than one mapping file.
Can some one explain me what exactly the above exception means and how to fix it? Also, does using hibernate XML persistence has any prerequisties that I have missed when running with other XML utilities like eXist XML database?
I would appreciate if any one can shed some light on this.
thanks
|