-->
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.  [ 6 posts ] 
Author Message
 Post subject: Where did the XMLDataBinder go?
PostPosted: Sun Apr 24, 2005 6:45 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 2:03 pm
Posts: 34
Basically all I want to do is export a collection of persistent objects to xml. I've discovered that java's own built in xmlencoder doesn't play nice with hibernate, so it was suggested I use hibernated xmldatabinder instead.
Ok, fair enough, but I'm on hibernate 3.0 and I can't seem to find the databinder anymore.

In the 2.1 series of hibernate there was an XMLDatabinder class:

net.sf.hibernate.xml.XMLDatabinder

I can't seem to find it anymore in my 3.0 distribution. Did it get depircated? Renamed?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
XML databinding is now built-in, check the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 7:53 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 2:03 pm
Posts: 34
christian wrote:
XML databinding is now built-in, check the documentation.


I found the new XML code, but I'm not quite sure it does what I'm looking for. In my app, I won't know beforehand that a given set is going to end up in XML. It's just a data set that at some point the user may decide to export to xml (or they may not).

So I want to get it back from Hibernate as a list of POJOs and then (maybe) export it as an XML document. The Hibernate XML support I've found so far seems to require me to tell hibernate at query time that I want to get XML data back. Am I wrong on this? Alternately is there a quick and easy way to translate a POJO set into and XML set?

Below is the code snipper I'm working on for reference.

Code:
Document d;
      d = createDomDocument();
      Session session = HibHelper.getSession();
      Session dom4jSession = session.getSession(EntityMode.DOM4J);
      HibHelper.beginTransaction();

      List results = dom4jSession.createCriteria("core.User").list();
      Element root = d.addElement( "root" );
      for ( int i=0; i<results.size(); i++ ) {
         
          Element u = (Element) results.get(i);
          root.add(u);
      }

      HibHelper.commitTransaction();
      try {
         FileWriter w = new FileWriter(f);
         d.write(w);
         w.close();
      } catch (IOException e) {
         Log.error(e);
      }


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 7:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
We will be adding a transform() method, when we get time to implement it. (It's mainly trivial to do, just got to figure out the details.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 2:17 am 
Newbie

Joined: Thu Nov 27, 2003 4:50 am
Posts: 16
Location: M
gavin wrote:
We will be adding a transform() method, when we get time to implement it. (It's mainly trivial to do, just got to figure out the details.)


this will be a very usefull feature!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 4:50 pm 
Newbie

Joined: Fri Aug 19, 2005 4:42 pm
Posts: 1
I am somewhat surprised to see that the XMLDatabinder is no longer part of the Hibernate package. The functionality it provided is exactly what was needed by those of us using Hibernate behind an Axis web-service.
If you factor in the convenience methods provided by Spring (such as getHibernateTemplate) that return a List type, then the utility of converting directly from a Collection to a DOM is invaluable.
I also like the concept of specifying an XSLT file to further format the data on the fly. I don't see how the 'latest' model in Hibernate is any better, in fact it's worse.

Please reconsider resurrecting the class, or make the process of returning a org.w3c.dom.Document less onerous.
Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.