-->
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: How to use existing column to denote discriminator
PostPosted: Mon Sep 26, 2011 10:00 am 
Newbie

Joined: Thu Aug 04, 2011 10:41 am
Posts: 4
Hi,
I have an existing database table(in which each row contains a classId column).
I am now trying to map my various related objects to this data and need to use the existing classid column to denote the class discriminator using single table inheritance.
I have just setting the classid as the @DiscriminatorColumn but Hibernate attempts to recreate this columns and throws an exception.
I think therefore, that I have to use a @DescriminatorFormula but cannot find a way to simply apply it.
Thanks,
Barry


Top
 Profile  
 
 Post subject: Re: How to use existing column to denote discriminator
PostPosted: Tue Sep 27, 2011 2:55 am 
Newbie

Joined: Thu Aug 04, 2011 10:41 am
Posts: 4
I managed to get to the bottom of this myself using the @DescriminatorFormula and hope that this is the most elegant solution.
Simply adding a @DescriminatorFormula("classID") to the super class and the appropriate discriminators (@DiscriminatorValue("A") to A and @DiscriminatorValue("B") to B) to the subclasses seems to do the trick.
Cheers,
Barry


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.