[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2743?page=c...
]
Chris Bredesen commented on HHH-2743:
-------------------------------------
Note that this limitation is listed in section 9.1.1 of the manual:
http://hibernate.org/hib_docs/core/reference/en/html/inheritance.html#inh...
"Exactly one table is required. There is one big limitation of this mapping strategy:
columns declared by the subclasses, such as CCTYPE, may not have NOT NULL
constraints."
Whether hibernate should check for this and fail is another question...
NOT NULL columns for "nullable=false" properties not always
correct
-------------------------------------------------------------------
Key: HHH-2743
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2743
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Reporter: Andreas Schildbach
Attachments: problem.zip
When Hibernate creates a schema for a "table-per-class-hierarchy" mapping, it
does not take into account that some properties might only exist on single branches of
that hierarchy.
Have a look at the attached example (Maven2: mvn eclipse:eclipse to create an eclipse
project).
Classes A and B extend Base. Class A defines a property "a", and B defines b -
both with "nullable = false". Hibernate then creates a "NOT NULL"
column for those properties. I think this is not correct, because even if instances of A
always have that property set it might still be NULL (for instances of B) in the database
due to the table-per-class-hierarchy mapping.
Here is what happens if you start "ProblemTest":
"Attempt to insert null into a non-nullable column: column: B table: BASE in
statement [insert into Base (id, a, class) values (null, ?, 'a')]"
This is the schema that has been created by Hibernate for HSQLDB:
create table Base
(
class varchar(31) not null,
id integer generated by default as identity (start with 1),
a integer not null,
b integer not null,
primary key (id)
)
--
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