-->
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 Data Mapping
PostPosted: Tue Feb 03, 2009 7:36 am 
Newbie

Joined: Tue Dec 30, 2008 1:02 am
Posts: 2
Location: Kochi
HIbernate Version 3.2.2
I am using the entity mode as dom4j. It is working fine for me for all cases except for bidirectional mapping. When we use bidirectional mapping with embed-xml="true", Hibernate fetches the data but on converting the data to xml string using dom4j leads to an infinite loop and
StackOverflowError occurs.
Is there any solution to this problem my mapping files are attched below

Code:
<?xml version="1.0" encoding="UTF-8"?>
[b]Child table[/b]
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.nest.shop.dbmodel">
  <class entity-name="NTColumn" node="NTColumn" table="NTColumn">
    <id column="Id" name="Id" node="Id" type="string">
      <generator class="guid"/>
    </id>
    <!--property column="TableId" name="TableId" node="TableId"/-->
    <property column="Name" name="Name" node="Name" type="string"/>
    <property column="Type" name="Type" node="Type" type="string"/>
    <property column="Description" name="Description" node="Description" type="string"/>
    <property column="DataType" name="DataType" node="DataType" type="string"/>
    <property column="DataSize" name="DataSize" node="DataSize" type="string"/>
    <property column="DataScale" name="DataScale" node="DataScale" type="string"/>
    <property column="Comment" name="Comment" node="Comment" type="string"/>
    <many-to-one column="TableId" entity-name="NTTable"
     name="myTable" embed-xml="true" node="NTTable"/>
  </class>
</hibernate-mapping>
[b]Parent Table[/b]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.test.dbmodel">
  <class entity-name="NTTable" node="NTTable" table="NTTable">
    <id column="Id" name="Id" node="Id" type="string">
      <generator class="guid"/>
    </id>
    <property column="Name" name="Name" node="Name" type="string"/>
    <property column="Type" name="Type" node="Type" type="string"/>
    <property column="Description" name="Description" node="Description" type="string"/>
    <property column="Comment" name="Comment" node="Comment" type="string"/>
    <property column="History" name="History" node="History" type="string"/>
    <property column="Boundary" name="Boundary" node="Boundary" type="string"/>
    <property column="Log" name="Log" node="Log" type="string"/>
    <property column="Cache" name="Cache" node="Cache" type="string"/>
    <property column="Notify" name="Notify" node="Notify" type="string"/>
    <property column="Identifier" name="Identifier" node="Identifier" type="string"/>
    <set name="columnSet" embed-xml="true" node="Columns" lazy="false" inverse="false">
        <key column="tableId"/>
        <one-to-many entity-name="NTColumn" embed-xml="true"/>
    </set>
  </class>
</hibernate-mapping>

Code:


      List<Element> l =session.createQuery("from NTColumn" +
               " where Id=1").list();
   
       Document doc = DocumentHelper.createDocument();
       Element root = doc.addElement("Root");
       doc.setRootElement(root);
        for (Element nTTable : l) {
            nTTable.setParent(null);
            doc.getRootElement().add(nTTable);
        }

[b]doc.asXML()// Here causes the error StackOverflow[/b]
[/b]


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.