@Transient无效
使用了@Transient来注解属性salary,结果在控制台和数据库都看到了salary字段被创建进表中,这个@Transient在hibernate-core4.2.4无效吗?
实体类中标记 @Transient//表示该字段不会被映射到数据库表中。但是我试过,却没有效果 private double salary; public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; }
Eclipse中记录 create table t_students (identityId varchar(255) not null, learnId varchar(255) not null, address varchar(255), phone varchar(255), postCode varchar(255), birthday datetime, gender varchar(255), major varchar(255), salary double precision not null, sid integer not null, sname varchar(255), primary key (identityId, learnId) )
--数据库中记录 create table t_students ( identityId varchar(255) not null, learnId varchar(255) not null, address varchar(255), phone varchar(255), postCode varchar(255), birthday datetime, gender varchar(255), major varchar(255), salary double precision not null, sid integer not null, sname varchar(255), primary key (identityId, learnId) )