-->
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.  [ 4 posts ] 
Author Message
 Post subject: XML and generate ORM vs. annotate Java and generate XML
PostPosted: Tue Mar 18, 2008 1:53 pm 
Newbie

Joined: Tue Mar 18, 2008 1:42 pm
Posts: 2
For maintaing the ORM layer, what are the pros and cons / best practices with these two approaches:

1. Maintain XML files for the DB mapping. From these you can auto-generate Java ORM objects and the SQL needed to create the database schema.

2. Maintain Java ORM objects, and annotate them with the DB column information. Use this to generate XML and SQL for the schema.

2 seems cleaner, since you maintain the Java ORM objects that the DAO's use. But I am wondering if this approach is somewhat less flexible. There are all sorts of configurations you can make in the XML mapping files, and we may need to tweak them for performance reasons. Just seems like there is less support for hibernate configuration in the annotations. Also the annotation technique is newer and maybe less mature?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 2:10 pm 
Newbie

Joined: Tue Mar 18, 2008 1:42 pm
Posts: 2
Bump...

Anyone have thoughts on this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 3:26 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I like being able to manually load the hbm.xml files into my configuration as I require their usage in my installation. I like to keep the config stuff separate from the java beans. Personal preference I guess.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 3:59 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
kochcp wrote:
I like being able to manually load the hbm.xml files into my configuration as I require their usage in my installation. I like to keep the config stuff separate from the java beans. Personal preference I guess.


Ditto. Furthermore, you need to ask yourself whether not the things you want to put in Java code are the responsibility of a developer or a deployer. If it is for a developer then it is ok to put them in Java code but if it is something that can be of a deployer's interest then you need to put it somewhere outside Java code. For example, once I was in this situation where we had a third party software that used hibernate with annotations and according to contract we did not own the source so we were not able to tweak caching strategies according to our needs and it was a lot better for us if we had access to XML files.

In any events, I don't think we can have any reasonable discussion on whether not we should favour annotations over xml files, and with the kind of technologies we have at this point (IDEs, frameworks that integrate with each other, ...), this stays as a personal choice and the kind of people you have in your project. I have seen people that feel a lot more confident with annotations. I personally feel better with XMLs but I am a little bit old school.


Farzad-


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