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.  [ 3 posts ] 
Author Message
 Post subject: Question about multi-table mappings with NHibernate
PostPosted: Thu Jan 04, 2007 3:33 pm 
Newbie

Joined: Mon Jan 01, 2007 11:33 pm
Posts: 10
It's me again :)

Is there a way to map a single object to multiple tables?

I'm working on a legacy DB that's a mess and this would greatly simplify things for me.


Also, is returning a saveVeto the easiest way to make an object "read-only", or can this be specified somewhere in the xml file?


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 05, 2007 1:04 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
specifing the attribute mutable="true" in the <class> tag will make the class "readonly", what means that NHibernate will never persist any changes made to this class.

For your other problem: ORM will fit best following the opposite approach, which is persisting an object model to a relational database. If you want to map an existing relational model to an object model you have to make compromises. In my opinion the easiest will be to use NHibernate just as persistence level. You can build a 1:1 mapping (one table, one persistent class). Then you can build a "Business Object" layer based on the Data Mapper pattern (see http://martinfowler.com/eaaCatalog/dataMapper.html), which assembles the objects you need from your base persistent classes.

Regards
Klaus[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 05, 2007 3:57 pm 
Newbie

Joined: Mon Jan 01, 2007 11:33 pm
Posts: 10
Thanks luedi that's exactly what I was looking for


Interestingly enough that's basically what I ended up doing. I wasn't thinking of it in exactly those terms but it's nice to know that I'm on the right track :)


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