Hibernate官方文档
manaul
中提到,hibernate实体有三种状态:Transient、Persistent、Detached。本文参考了官网手册和
http://blog.csdn.net/hgd250/article/details/2775943这篇博客。
1、Transient状态
An object is transient if it has just been instantiated using the new operator, and it is not associated with a Hibernate Session. It has no persistent representation in the database and no identifier value has been assigned. Transient instances will be destroyed by the garbage collector if the application does not hold a reference anymore. Use the Hibernate Session to make an object persistent (and let Hibernate take care of the SQL statements that need to be executed for this transition).