]
Sebastian Baltes commented on HHH-3124:
---------------------------------------
@Column(nullable=true)
int x;
can be used as a workaround
@Embeddable with int field leads to java.sql.SQLException: Field
doesn't have a default value for one table per class hirarchy
------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3124
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3124
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5, 3.2.6
Environment: Hibernate 3.2.6
Hibernate Annotations 3.3.0.GA
Hibernate EntityManager 3.3.1.GA
MySQL 5.1
Reporter: Sebastian Baltes
Attachments: log.txt
Given the following class hirarchy:
@Entity class Dummy ...
@Entity class DummyA extends Dummy ...
@Entity class DummyB extends Dummy {
DummyEmbedded embedded;
}
@Embeddable public class DummyEmbedded {
int x;
}
calling
DummyA d = new DummyA();
em.persist(d);
leads to
[SERVER] DEBUG [main] - could not insert: [de.neise.gena.model.persistence.DummyA]
[insert into gena_test.Dummy (name, DTYPE, id) values (?, 'DummyA', ?)]
java.sql.SQLException: Field 'embedded_x' doesn't have a default value
and the generated DDL is
CREATE TABLE `dummy` (
`DTYPE` varchar(31) NOT NULL,
`id` bigint(20) NOT NULL,
`embedded_x` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
embedded_x should habe been DEFAULT NULL instead of NOT NULL, as it is the case if I
don't use an embedded object:
@Entity class DummyB extends Dummy {
int x;
}
works, then the DDL is korrekt:
CREATE TABLE `dummy` (
`DTYPE` varchar(31) NOT NULL,
`id` bigint(20) NOT NULL,
`x` int(11) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: