-->
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.  [ 11 posts ] 
Author Message
 Post subject: Databinder - Marshalling and unmarshalling of xml
PostPosted: Wed Jan 28, 2004 4:09 am 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
I have seen a few posts about the use of the Databinder. I was wondering if anyone had some sample code to share.

I am passing information between applications via xml and need a nice way to marshall the data.

The database will be generated from our xml DTDs and then the java objects will be created using Hibernate/Middlegen utility.

I have done some research on this and it appears CASTOR would be one way to go.. but I would prefer to just stick to Hibernate if possible.

Would you suggest using the Databinder? Or go with CASTOR, JiBX, JAXB etc.


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 4:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Are you sure the least performant way of passing data from tier to tier is the best for you?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Beginning with XML and DTD
PostPosted: Wed Jan 28, 2004 2:16 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
I am not sure what you mean. Are you saying that Caster is the least performant or hibernate databinder?

We have a requirement to go from already defined and standardized XML/DTD schema. We would like to autogen as much as possible as our timeline is very aggressive. We are planning to use Hibernate because we believe it will be a great timesaver as well as a solid data access layer.

After a day of research I had come to the conclusion that Caster would be a good option for the marshalling/unmarshalling of our XML data into our java objects... which we would then use hibernate to persist. And then use the hibernate util to generate a database schema from the hibernate java objects.

I would really appreciate some feedback/suggestions on how we could/should acheive this. Specifically:

1) Would you suggest going from the XML --> dataobjects --> hbm --> SQL Server or XML --> SQL Server --> hbm --> dataobjects.

2) In the first case: If a marshalling framework is used to auto generate the java files (i.e. Caster) Can these easily be mapped to hibernate objects. (I would guess that you would generate the java files and then use the xdoclet hibernate tags to BIND the files to the database). Then use the hibernate util to generate the database schema from these mappings?

3) In the second case: (This would probably be the easiest and fastest way ? Would it not) What tool would you use to generate the database schema from the xml/dtd. Then use the middlegen hibernate tool to generate the mapping files and java objects. BUT: what then how would you then bind the java objects to the xml data files for marshalling/unmarshalling?

Any feedback would be greatly appreciated. Unfortunately time is short so we don't have time to evaluate a lot of options.

Troy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Your approach in 2) is reasonable. But why do you need XML marshalling? Are the objects send out-of-process to a non-Java application?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: xml marshalling
PostPosted: Wed Jan 28, 2004 2:27 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
We will have a portal front end as well as a webservice data service.

We will be sending and receiving information in as XML.

We already have the XML definations and are basing our database off of them. We want to easily bind this DATA into our java objects so it can be very easily persisted without having to manually parse the xml and populate the java objects.

Am I going about this wrong?

Thanks


Top
 Profile  
 
 Post subject: better forum?
PostPosted: Wed Jan 28, 2004 2:28 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
Should I maybe take this to the tools discussion?

I am not sure if I am off topic here or not.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, just go ahead and try it, I don't see a reason why it should be a problem. You obviously need XML marshalling for webservices.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: least performant?
PostPosted: Wed Jan 28, 2004 2:55 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
christian wrote:
Are you sure the least performant way of passing data from tier to tier is the best for you?


Christian,

just a couple more questions to wrap this up:

1) what did you mean by least performant?
2) Is the hibernate DataBinder worth a try over Caster etc?
3) Do you know if the java objects created by Caster will be easily mapped to the hibernate framework? ( I assume so! :)

Thanks for the feedback


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
1) There is nothing slower than serializing objects to a verbose text format.

2) The DataBinder is usable for export/import of (test)data, not runtime object marshalling.

3) As long as Castor generates POJO classes, you'll be fine. Hibernate requires a no-arg constructor and at least private getter and setter methods for properties. An identifier and version property would be very useful.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Castor is a good choice
PostPosted: Mon Aug 23, 2004 6:57 am 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
tmckinnon, in case you are still on this problem, you can use Castor and Hibernate. What I mean is you can continue to use Hibernate to manage DB persistence and use Castor to handle XML Marshalling and Unmarshalling. Having used Castor myself, Castors JDO is not as robust as Hibernates. The XML components is very robust and offers a number of options in regurads to XML serialization. One such option is to be able to create a mapping for Bean <-> XML serialization allowing you to control the serialization process. Alternatively, you can generate sources from an XML Schema. Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 1:55 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
I've worked on projects that implement both DAO and a DBO (data binding object) layers. The latter was required because we had real requirements to support multiple XML serialization APIs.

See: http://www.theserverside.com/patterns/thread.tss?thread_id=19361


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