-->
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.  [ 5 posts ] 
Author Message
 Post subject: Clarification of discriminator formula
PostPosted: Tue Oct 25, 2005 4:01 pm 
Beginner
Beginner

Joined: Wed Nov 05, 2003 4:38 pm
Posts: 29
Facts from the documentation:

1.) A discriminator is a single column in the database used by Hibernate to distinguish different subclasses from one another.

2.) A discriminator does not need to be a property of the class (but can be), Hibernate will automatically fill this column in when writing or reading a mapped subclass to the database.

3.) Each subclass has a single discriminator value that distinguishes it from other subclasses.


Given those things which are easily understandable I am unable to reconcile my understanding of the formula property of the discriminator tag. My questions on it are as follows:

1.) Is it correct to say that since a formula can be abitrary SQL, you could read multiple columns from a table to determine a single value which would match the discriminator-value's of each subclass thereby allowing you to read in subclasses based off more than one column?

Example:
<discriminator formula="CLASS_TYPE1 + CLASS_TYPE2" type="varchar"/>

<subclass name="ClassAB" discriminator-value="AB"/>
<subclass name="ClassBA" discriminator-value="BA"/>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:05 pm 
Beginner
Beginner

Joined: Wed Nov 05, 2003 4:38 pm
Posts: 29
Accidentally clicked post before I was done.

2.) If the above is possible how does Hibernate handle inserting a totally new class instance?

3.) If the above is not possible I'm not sure I understand the usefulness of using the formula at all, can you provide a better example than the documenation?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:09 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
http://forum.hibernate.org/viewtopic.ph ... criminator

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:29 pm 
Beginner
Beginner

Joined: Wed Nov 05, 2003 4:38 pm
Posts: 29
Thanks! I had seen that post before but it didn't sink in till just now since I've been thinking about this some more since then.

I think they should add a short blurb to the docs saying something to the effect that when you use formula Hibernate no longer automatically handles your discriminator values and you must do them manually. It's something that to some people (myself included) might not be completely obvious. In my head I kept thinking that Hibernate always handled things automatically for this but in reasoning it out realized it could not in cases like this hence my confusion.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:30 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
jkolb wrote:
Thanks! I had seen that post before but it didn't sink in till just now since I've been thinking about this some more since then.

I think they should add a short blurb to the docs saying something to the effect that when you use formula Hibernate no longer automatically handles your discriminator values and you must do them manually. It's something that to some people (myself included) might not be completely obvious. In my head I kept thinking that Hibernate always handled things automatically for this but in reasoning it out realized it could not in cases like this hence my confusion.


The answer from the Hibernate guys would be to add it to the WIKI. Anyone can update it.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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