-->
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.  [ 7 posts ] 
Author Message
 Post subject: Several entities for one table
PostPosted: Mon Jan 08, 2007 11:46 am 
Newbie

Joined: Mon Jan 08, 2007 10:14 am
Posts: 15
Location: Minsk, BY
I haven't found an answer for this question.

Suppose I have a database table with dozens of fields and several related tables.

Can I create two or more entities for it with different set of fields (and collections of related objects in child tables)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 5:49 am 
Newbie

Joined: Mon Jan 08, 2007 10:14 am
Posts: 15
Location: Minsk, BY
Maybe I asked incorrect question?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 7:09 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Yes, you can.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 7:57 am 
Newbie

Joined: Mon Jan 08, 2007 10:14 am
Posts: 15
Location: Minsk, BY
I mean maybe my question about several entities for one table was incorrect in terms of NHibernate idea.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 4:11 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
In general, I would recommend doing it, since it may have issues with concurrency, with different views of the same data, etc.

You need to consider the case and decide if this is possible or not.
I would usually try to refactor the DB first.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 7:27 am 
Newbie

Joined: Mon Jan 08, 2007 10:14 am
Posts: 15
Location: Minsk, BY
I think it is not a rare case to have a different views of the same data.

E.g. I can have two versions of the same object, a "heavy" version with all properties and all related collections of child objects and a "light" version with some set of properties. Also I think that these "light" objects are often read-only.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 1:23 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
For read only data, I would agree.
I am concerned with multiply updated views of the same row, especially if some of the columns are shared and updatable.


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