我有一个用户pojo类,当我使用Hibernate 4.2.0最终版本时,瞬态成员在序列化时填充到对象但在使用Hibernate 5.0.3.Final版本时没有填充。
Hibernate 5版本需要哪些配置才能使瞬态成员出现在条件对象/序列化中?
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Entity(name = "el_users")
@Table(name = "el_users")
public class User{
public User() {
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
private Long id;
@Column(name = "username")
@Size(min = 2, max = 30, message = "Please enter username")
private String username;
@Column(name = "password")
@NotNull
@Size(min = 2, max = 40, message = "Please enter password")
private String password;
@Column(name = "first_name")
@Size(min = 2, max = 40, message = "Please enter first name")
private String first_name;
@Column(name = "last_name")
private String last_name;
@Column(name = "email")
@Size(min = 2, max = 50, message = "Please enter email")
private String email;
@Column(name = "access_group")
private String accessGroup;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public String getAccessGroup() {
return accessGroup;
}
public void setAccessGroup(String accessGroup) {
this.accessGroup = accessGroup;
}
@Transient
public String getFullName() {
return first_name + " " + (last_name != null ? last_name : "");
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}