Reputation: 2752
I want to increase the 255 to 1000 when the table is automatically created by Java Hibernate, but how to do this?
Part of the code that might need changes for it:
@Entity
public class Work implements Serializable {
@Id
@GeneratedValue
private long workNumber;
private int fromYear;
private int tillYear;
private String name;
private String profession;
private String description;
@ManyToOne
private User user;
public Work() {
}
public Work(long workNumber, int fromYear, int tillYear, String name, String profession, String description) {
this.setWorkNumber(workNumber);
this.setFromYear(fromYear);
this.setTillYear(tillYear);
this.setName(name);
this.setProfession(profession);
this.setDescription(description);
}
Upvotes: 4
Views: 6178
Reputation: 5274
You add a @Column annotation to the property and set a length property on it: Very, very basic JPA stuff. You would do well to read at least the Java EE 6 tutorial on the subject to learn about the basic annotations that you have available.
Upvotes: 1
Reputation: 4623
Why not trying simply
@Column(columnDefinition="varchar(1000)")
?
Upvotes: 4
Reputation: 9639
You need to explicitly specify in the annotation, for example for the profession attribute your code would look like
@Column(length=1000)
private String profession;
The same principle applies if you want for example to have a different name for your property in your object than the name of the column in database, you override the convention with some configuration.
Upvotes: 3