-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate XML to relational persistence
PostPosted: Mon Aug 29, 2005 3:14 pm 
Newbie

Joined: Mon Aug 29, 2005 3:03 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.