i got the following entity:
@Entity
public class Person {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(columnDefinition="int(11)",nullable=false)
private int id;
@Column(columnDefinition="varchar(255)",nullable=false)
private String name;
@Column(columnDefinition="varchar(255)",nullable=false)
private String vorname;
@Column(columnDefinition="varchar(255)",nullable=false)
private String password;
@Column(columnDefinition="varchar(100)",nullable=false)
private String user;
@Column(columnDefinition="varchar(20)",nullable=false)
private String klasse;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="timestamp",nullable = false,columnDefinition="default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP")
private Date timestamp = new Date();
public Person(){
}
@PreUpdate
public void updatePerson(){
this.timestamp = new Date();
}
...getters
...setters
}
When invoking hibenate , i get an error when hibernate wants to create the table. it seems the errror occurs, beacause the column timestamp has no name:
ERROR: HHH000389: Unsuccessful: create table Person (id int(11) not null auto_increment, klasse varchar(20) not null, name varchar(255) not null, password varchar(255) not null, timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP not null, user varchar(100) not null, vorname varchar(255) not null, primary key (id)) type=MyISAM
Does anyone knows why hibernate does this ?