class MyClass{
private int id;
private String name;
@Transient
private int identity;
}
这里,identity字段在数据库中是暂时的,而不是持久的
This means if a variable is marked @Transient then it won't be added
in the database. it has no persistence representation of this variable
in that hibernate session. After the session is closed these transient
objects will be destroyed by garbage collection.
# 1 楼答案
当然,您可以使用
@Transient
注释。例如:这里,
identity
字段在数据库中是暂时的,而不是持久的