-->
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: Inheritance: Mapping discriminator values
PostPosted: Fri Jul 23, 2004 5:42 pm 
Beginner
Beginner

Joined: Thu Feb 05, 2004 10:39 pm
Posts: 44
I have a special case of mapping classes to tables.

Facts:
1. Let's say I have a DB table called IDENTITY
2. 2 different classes map to this table via 3 discriminator values
3. Discriminator values have significance elsewhere in the application and thus are not solemnly for hibernate mapping purposes

So, the two classes are:
1. ProgramID
2. PersonID

Discriminator value 10 maps to ProgramID
and values 1, 7 map to PersonID

How do I resolve this?

I presume I cannot have a comma delimitated discriminator field in my hibernate mapping for PersonID containing 1 ,7? Correct?

Does this mean I will have to:
1. create two mapping classes
2. both mapping the IDENTITY table to the PersonID class
3. Both having identical field mappings except for the discriminator value will be 1 and 7 respectively?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 23, 2004 10:46 pm 
Beginner
Beginner

Joined: Wed Jul 21, 2004 12:28 pm
Posts: 27
Location: New York
think about inserts:

when hibernate inserts a record for the class it actually uses your discriminator values to do the insertion. So if you have two discriminators how in the world would hibernate know what discriminator value to use for insertion.

Same is true for updates.

I guess you will have to use two different classes for values 1 and 7. Easy enough just subclass one from another. The thing that sucks though you will have to remember what class to create for 1 and for 7, when you are creating new records.

HTH


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.