[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-140?page=co...
]
Amit Kasher commented on ANN-140:
---------------------------------
I'd like to add another possible requirement for discriminator column support. If you
have a discriminator column, you can have it inside DB constraints, and achieve
constraints in which subclasses participate as different entities.
Example: I have the following entities:
A {
id, name
}
B extends A {
height
}
C extends A {
width
}
I need the following constraint: I don't want to allow (more than 1:) 2 or more
instances of B with the same name, and I don't want (more than 1:) 2 or more instances
of C with the same name. However, I DO want to allow 1 instance of B with the name
"Jack", and another instance, this time of C, with that same name,
"Jack". The only way to achieve this, I think, is having a discriminator column
in A which will allow you to define a unique constraint containing A.discriminator and
A.name.
Discriminator column not supported with JOINED strategy
-------------------------------------------------------
Key: ANN-140
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-140
Project: Hibernate Annotations
Type: Bug
Versions: 3.1beta6
Environment: Hibernate 3.1rc2, Hibernate Annotations 3.1b6
Reporter: Steven Grimm
Section 9.1.27 of the EJB3 persistence public draft says, "The DiscriminatorColumn
annotation is used to define the discriminator column for SINGLE_TABLE and JOINED mapping
strategies." But Hibernate ignores the DiscriminatorColumn annotation when the
mapping strategy is JOINED; when a JOINED entity is persisted, its discriminator column is
not included in the SQL "insert" statement, resulting in a not-null constraint
violation if the discriminator column is marked NOT NULL in the database.
The JOINED strategy with discriminators is pretty ubiquitous in EJB3 sample code and
tutorials out on the net, so lots of people are likely to run into this as they try out
EJB3 for the first time. A few examples:
http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos-ejb3/howtoejb...
http://www.solarmetric.com/Software/Documentation/4.0.0EA/docs/full/html/...
http://www.caucho.com/resin-3.0/amber/tutorial/cmp-inherit/index.xtp
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira