-->
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.  [ 1 post ] 
Author Message
 Post subject: Remove Discriminator Check when mapping a subclass?
PostPosted: Tue Mar 25, 2008 1:17 pm 
Newbie

Joined: Sun Mar 02, 2008 3:43 pm
Posts: 9
Hibernate version:3.2

Hi,

I am using an TablePerHierarchy strategy. I'm using a userType as a discriminator and it is working quite fine.

I use a discriminator Formula which I send to the userType discriminator who gives the right class Name to hibernate.

My Problem occurs when I need to map a sub class.

Let say we have the following hierarchy:




Code:

SuperClass
       |
--------------------------------------------------
|                            |                                |
Subclass1          Subclass2                 SubClass3
     |
---------------------------------------------------
|                             |                               |
Subclass11        Subclass12                SubClass13



In another Entity I have a field which is mapped to Subclass1

@ManyToOne @JoinColumn(nam="id")
Subclass1 myField;

Here comes the problem:

The generated SQL will look like something like that:

select * from 'table' where id=? and disc_col in ("Subclass1", "Subclass2","Subclass3");

"disc_col" is my formula (could be a disc_column, but the same column is mapped and used otherwise). This cause an sql exception since the column is not a a String type.

Probably the DiscriminatorType is faulty and should transform the class name to the right values, but it is not possible since I don't have a one-to-one mapping.

I would have something like that:

DiscCol Class
1 SuperClass
2 SuperClass
3 SubClass1
10 SubClass2
15 SubClass12
24 SubClass2
...

So my question is: is there any way to remove the discriminator check ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.