Reputation: 21
@NotNull
@Column(name = "ShortDescription", length = 65)
private String shortDescription;
Upvotes: 1
Views: 1366
Reputation: 4309
For EclipseLink
EclipseLink does not support the automatic update of existing columns. You have to update it manually using DDL query or you can use one of the following options according to your requirements.
create-tables
: EclipseLink will attempt to execute a CREATE TABLE SQL for each table. If the table already exists, EclipseLink will follow the default behavior for your specific database and JDBC driver combination (When a CREATE TABLE SQL is issued for an already existing table). In most cases an exception is thrown and the table is not created; the existing table will be used. EclipseLink will then continue with the next statement.
create-or-extend-tables
: EclipseLink will attempt to create tables. If the table exists, EclipseLink will add any missing columns.
drop-and-create-tables
: EclipseLink will attempt to DROP all tables, then CREATE all tables. If any issues are encountered. EclipseLink will follow the default behavior for your specific database and specific JDBC driver combination, then continue with the next statement. This is useful in development if the schema frequently changes or during testing when an existing data needs to be cleared.
none
: default, no ddl generated; no schema generated.
Add this property in your persistence.xml
file.
For Hibernate
The values create
, create-drop
, validate
, and update
basically influence how the schema tool management will manipulate the database schema at startup.
You can use update
value for hibernate.hbm2ddl.auto
so that your column length will get updated on application startup. Add this property in your persistence.xml
file.
Upvotes: 1