Following the advice of hardy.ferentschik, I post my question in this forum (original is at
I'm using validator-3.1, core-3.3.1, annotations-3.4.
Here is my problem, may be a bug:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Parent
{
@Id
int id;
@Column(nullable = true)
String string;
public int getId() { return this.id; }
public String getString() { return this.string; }
}
@Entity
public class CanBeNull
extends Parent
{
}
@Entity
public class CannotBeNull
extends Parent
{
// omitted for demo: @Column(nullable = false)
@NotNull
@Override
public String getString() { return this.string; }
}
Now the DDL looks like:
Code:
CREATE TABLE cannot_be_nulls
(
id integer NOT NULL,
string character varying(255) NOT NULL,
CONSTRAINT cannot_be_nulls_pkey PRIMARY KEY (id)
)
CREATE TABLE can_be_nulls
(
id integer NOT NULL,
string character varying(255) *************NOT NULL*******************,
CONSTRAINT can_be_nulls_pkey PRIMARY KEY (id)
)
This does not happen if I use @MappedSuperclass on Parent, but I need @Entity because some other entity have references to Parent.
This is quite annoying... Is there something i can do, is this a bug (looks like), should i open an issue on jira ?
seems to be a bug. The DDL is also correct when @MappedSuperclass is used or when CannotBeNull is not mapped at all.
However, I think this is really a Hibernate Tools bug. Hibernate Annotations and Validator provide the meta data, but Hibernate
Tools generates the actual DDL. You might want to post your question there or check Jira for Hibernate Tools.