-->
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.  [ 2 posts ] 
Author Message
 Post subject: Versions of an object - use inheritance or not ?
PostPosted: Thu May 05, 2011 7:40 am 
Newbie

Joined: Wed May 04, 2011 3:33 pm
Posts: 4
Hello,

In our application we have an object that holds all the details of a Project. At some point we decided we needed versions for a Project so we created a new class ProjectVersion and made Project a child of this class (ProjectVersion has the project fields declaration now). Also we added a class ProjectGroup that holds the original project id and the link to its latest version. In order to change as little as possible in the code, at the database level we changed the Project table into a view that joins ProjectVersion with ProjectGroup in order to show only the latest versions of the projects.

Now for Hibernate we first tried to use inheritance and joined-subclass seemed to be the proper choice for the Project class (joining with ProjectGroup to obtain only the latest versions). But when trying to select all the ProjectVersions hibernate will automatically add the join for the Project class, so we can't do queries on ProjectVersions.
After that we tried to map individually the two classes, so we mapped the Project class on the Project view. But now at startup Hibernate complains that it can't add foreign keys because underlying table is actually a view. And maybe there are other things wrong with this approach?!?

I'm asking to see if you guys know a better way to do the hibernate mappings in this case or maybe you did things differently to add versions to an object?

Thanks,
Alex


Top
 Profile  
 
 Post subject: Re: Versions of an object - use inheritance or not ?
PostPosted: Thu May 12, 2011 5:27 am 
Newbie

Joined: Wed May 04, 2011 3:33 pm
Posts: 4
Anyone ? :D


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