I'm exporting a ddl schema (by code using the Hbm2DDLExporter) via my generated entities and there is inheritance hierarchy in my entities structure. I would like a child class to override a parent attribute and make the field length smaller but it seems that the length of the overridden field in the child table schema is still following the length of the parent class. Need some advice in how to implement this.
Thanks.
Code:
@Inheritance( strategy = InheritanceType.TABLE_PER_CLASS )
@Entity
@Table( name = "Parent" )
class Parent{
@Column( name = "name", length = 8 )
private String name;
//....setters getters
}
@Entity
@Table( name = "Child" )
@AttributeOverrides( { @AttributeOverride( name = "name", column = @Column( name = "name", length = 5 ) ) } )
class Child extends Parents{
//no setter, getter and name attribute defined in child class.
}
The ddl generated for child classcreate table parent( name varchar2(8 char) )
create table child( name varchar2(8 char) ) -- the length should be 5 instead