Reputation: 470
In already existing table structure inheritance I am adding a new column type (I cut some of the code)
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Account {
......
@Column // already existed column
private String name; // get/set also applied
@Column(length=20) // new added column
@Enumerated(EnumType.STRING) // get/set also applied
private AccountType type;
..........
}
@Entity
public User extends Account {
................ // some other already existed fields
}
In my persistence.xml file I am using next strategy policy for DDL generation
property name="eclipselink.ddl-generation" value="drop-and-create-tables"
When DDL generation is processing the new added column type in Account table is successfully created, BUT for User table there is no such kind of column at all (the strategy is TABLE_PER_CLASS). I fixed that when i drop the database and created it again. After that the current generation of DLL was applied - type in User is also added as a column. Does someone "met" with such kind of issue ? I fixed with with drop and create of the DB but I am not sure that should be the strategy in same cases in future, specially for production DB
Thanks, Simeon Angelov
Upvotes: 0
Views: 1638
Reputation: 21165
DDL generation is for development not production. The problem you are seeing is because when the table already exists, it cannot be created with the new field. Drop and create or the "create-or-extend-tables" feature will work if you are adding to the tables as described here http://wiki.eclipse.org/EclipseLink/DesignDocs/368365
Upvotes: 3