-->
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.  [ 8 posts ] 
Author Message
 Post subject: Problem exporting to XML for collection
PostPosted: Wed May 04, 2005 12:02 am 
Newbie

Joined: Sun Jun 27, 2004 5:05 pm
Posts: 11
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.0

Mapping documents:
Code:
    <class name="Wine"
           table="wine"
           node="wine" >
        <id name="id"
            node="@id"
            type="long"
            unsaved-value="null"
            column="WINE_ID" >
            <generator class="hilo">
                <param name="table">HI_VALUE</param>
                <param name="column">NEXT_VALUE</param>
                <param name="max_lo">100</param>
            </generator>
        </id>

        <list
            name="reviews"
            node="reviews"
            embed-xml="true"
            cascade="save-update"
            inverse="true"
            lazy="true">
            <key column="WINE_ID"/>
            <list-index column="WINEREVIEW_INDEX"/>
            <one-to-many
                class="Review"
                embed-xml="false"
                node="review/@id"
                />
        </list>

...

Code between sessionFactory.openSession() and session.close():
Code:
            Session session = HibernateUtil.currentSession();
            Session s = session.getSession(EntityMode.DOM4J);

            List results = s.createQuery("from Wine wine ").list();

            Document doc = DocumentHelper.createDocument();
            Element root = doc.addElement("root");
            for (Iterator i = results.iterator(); i.hasNext();) {
                Element e = (Element) i.next();
                log.debug("node count="+root.nodeCount());
                root.add(e);
            }

            OutputFormat format = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(new FileWriter("test.xml"), format);
            writer.write(doc);
            writer.close();



Name and version of the database you are using:
MySQL 4.1.7-nt

I am exporting objects to XML. When I try to export a collection that is a one-to-many, it doesn't seem to recognize the /@id syntax:

Code:
<root>
  <wine id="1010">
    <reviews>
      <review/@id>1212</review/@id>
    </reviews>
  </wine>
</root>


Am I doing something wrong? Or is this a bug?

Thanks,
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 12:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Thanks, this is certainly a bug.

I'm looking into it now.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 12:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ugh, I'm an idiot.

no, not a bug. um, give me a second while i think about how to explain this...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 12:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
By the way, the docs get this wrong, so my fault, not your fault.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 1:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
OK, no, its really a bug, and a tedious-to-fix one at that.

It's basically "easy" to fix, but requires a lot of typing, unless we can find a nice refactoring.

I'm not fixing it tonight; too much effort.

I will add a bug report to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 1:28 pm 
Newbie

Joined: Sun Jun 27, 2004 5:05 pm
Posts: 11
Thanks Gavin.

Is there a workaround for this in the meantime?

-Dave


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 11:27 am 
Newbie

Joined: Fri Jun 17, 2005 11:24 am
Posts: 5
Is there an update on this issue? Has it been resolved, or is there a JIRA reference?

Thanks,
--david


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 11:31 am 
Newbie

Joined: Sun Jun 27, 2004 5:05 pm
Posts: 11
http://opensource.atlassian.com/project ... se/HHH-434


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

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.