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 ?