-->
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: Mapping Attributes or Mapping files?
PostPosted: Mon Oct 08, 2007 3:16 pm 
Newbie

Joined: Mon Aug 22, 2005 7:11 pm
Posts: 13
New to NHIbernate and working thru making a decision on whether or not to use the attribute based approach available in 1.2 over and against the tradition separate hbm.xml files.

Any opinions either way on this???

Thanks - wg


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 11:26 pm 
Regular
Regular

Joined: Wed Oct 25, 2006 10:51 pm
Posts: 71
I wrote a similar question but no takers ;-)
The overall best-practices opinion is that attributes are best. There are some dissenters but not many.

It means you have refactorable attribute-code (avoids constantly editing text files to change variable/column names), it's unintrusive in that even though you need the attribute dll, this is just metadata, you don't NHibernate assembly to compile the code that contains the attributes.

A small benefit might be that startup would be faster because there's no XML to parse (I've no idea how much of a difference this would make in practice).

And, you write less code/text because you can inherit properties that have attributes on them, if writing XML, you often have to repeat the XML fragment for each and every class.

And Ayende uses attributes. That's worth a few points... ;-) I think just because they're a 'lot easier'.

From some authorative point of view, the book 'Hibernate In Action' co-authored by a guy who wrote the original Hibernate, seriously recommends attributes over XML for new projects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 8:37 am 
Beginner
Beginner

Joined: Wed Jul 19, 2006 8:24 am
Posts: 35
IMHO, the attributes are much easier to maintain.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 1:45 pm 
Newbie

Joined: Mon Aug 22, 2005 7:11 pm
Posts: 13
I've been reading thru the NHibernate In Action book and I think you're right ... they do seem to lean towards using attributes.

Are there any code gen tools that actually generate partial classes with attribute based mappings?

How are you all proceeding with development using this approach?

thanks - wg


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 3:32 pm 
Newbie

Joined: Tue Oct 09, 2007 3:30 pm
Posts: 1
I looked at using attributes since I used them in Java and they were great, but the documentation seemed to be completely missing. Is there a place I should be looking other than the main reference? The only thing there seems to be 2 or 3 pages long and mostly useless. Are there good examples out there? Can you do everything you can do with mapping files with attributes?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 10, 2007 4:27 am 
Regular
Regular

Joined: Wed Oct 25, 2006 10:51 pm
Posts: 71
jarito wrote:
I looked at using attributes since I used them in Java and they were great, but the documentation seemed to be completely missing. Is there a place I should be looking other than the main reference? The only thing there seems to be 2 or 3 pages long and mostly useless. Are there good examples out there? Can you do everything you can do with mapping files with attributes?


From what I've read there are some things you can't do with Attributes. At a guess they're probably not worth doing... For examples, I download the NHibernate source code and have a look at the tests. They use all possible attribute mappings.


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.