<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/hibernate-three-status-description/</link>
<title><![CDATA[Hibernate对象的三种状态是什么？]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[编程杂谈]]></category>
<pubDate>Thu, 05 Jul 2012 16:51:14 +0000</pubDate> 
<guid>https://www.heckjj.com/hibernate-three-status-description/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 微软雅黑;">三种状态分别为瞬时态(Transient)、 持久态(Persistent)、脱管态(Detached)。处于持久态的对象也称为PO(Persistence Object)，瞬时对象和脱管对象也称为VO（Value Object）。<br/><br/>瞬时态<br/><br/>由new命令开辟内存空间的java对象，<br/><br/>eg. Person person = new Person(”amigo”, “女”);<br/><br/>如果没有变量对该对象进行引用，它将被java虚拟机回收。<br/><br/>瞬时对象在内存孤立存在，它是携带信息的载体，不和数据库的数据有任何关联关系，在Hibernate中，可通过session的save()或 saveOrUpdate()方法将瞬时对象与数据库相关联，并将数据对应的插入数据库中，此时该瞬时对象转变成持久化对象。<br/><br/>持久态<br/><br/>处于该状态的对象在数据库中具有对应的记录，并拥有一个持久化标识。如果是用hibernate的delete()方法，对应的持久对象就变成瞬时对象，因数据库中的对应数据已被删除，该对象不再与数据库的记录关联。<br/><br/>当一个session执行close()或clear()、evict()之后，持久对象变成脱管对象，此时持久对象会变成脱管对象，此时该对象虽然具有数据库识别值，但它已不在HIbernate持久层的管理之下。</span> <span style="font-family: 微软雅黑;"><br/><br/>持久对象具有如下特点：<br/><br/>1. 和session实例关联；<br/><br/>2. 在数据库中有与之关联的记录。<br/><br/>脱管态<br/><br/>当与某持久对象关联的session被关闭后，该持久对象转变为脱管对象。当脱管对象被重新关联到session上时，并再次转变成持久对象。<br/><br/>脱管对象拥有数据库的识别值，可通过update()、saveOrUpdate()等方法，转变成持久对象。<br/><br/>脱管对象具有如下特点：<br/><br/>1. 本质上与瞬时对象相同，在没有任何变量引用它时，JVM会在适当的时候将它回收；<br/><br/>2.&nbsp;&nbsp; 比瞬时对象多了一个数据库记录标识值。</span><br/>Tags - <a href="https://www.heckjj.com/tags/hibernate%25E4%25B8%2589%25E7%25A7%258D%25E7%258A%25B6%25E6%2580%2581/" rel="tag">hibernate三种状态</a> , <a href="https://www.heckjj.com/tags/hibernate/" rel="tag">hibernate</a>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/hibernate-three-status-description/#blogcomment</link>
<title><![CDATA[[评论] Hibernate对象的三种状态是什么？]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/hibernate-three-status-description/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>