<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fan&#039;s blog &#187; Hibernate</title>
	<atom:link href="http://fkpwolf.net/category/hibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://fkpwolf.net</link>
	<description>无为而无不为</description>
	<lastBuildDate>Sun, 13 May 2012 13:24:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Hibernate乐观离线锁(Appfuse Practise)</title>
		<link>http://fkpwolf.net/2006/09/09/hibernate%e4%b9%90%e8%a7%82%e7%a6%bb%e7%ba%bf%e9%94%81appfuse-practise/</link>
		<comments>http://fkpwolf.net/2006/09/09/hibernate%e4%b9%90%e8%a7%82%e7%a6%bb%e7%ba%bf%e9%94%81appfuse-practise/#comments</comments>
		<pubDate>Sat, 09 Sep 2006 12:36:00 +0000</pubDate>
		<dc:creator>Fan Fan</dc:creator>
				<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http:///2006/09/09/hibernate%e4%b9%90%e8%a7%82%e7%a6%bb%e7%ba%bf%e9%94%81appfuse-practise/</guid>
		<description><![CDATA[一个在Hibernate中的实践操作描述的很好的文档在这里。原理上的描述在Addison Wesley : Patterns of Enterprise Application Architecture Chapter 16里面有详尽的描写，这本Martin Fowler撰写的书称乐观锁定为Optimistic Offline Lock，Hibernate的实现基本上跟这本书里面的一样。里面有副时序图，画的相当的明白。(copy from the book. copyleft.) 另外一本书Hibernate in Action将乐观锁划分为Application Transacation，而悲观锁则划分为Database Transaction（Hibernate总是使用数据库的锁定机制，从不在内存中锁定对象！见：Hibernate的reference document）。Appfuse实践 Appfuse可以generate一个model的CRUD所有jsf页面，这可以作为实践上的起步。然后，version字段应该在页面上不能修改，而是作为一个hidden的字段，这样在显示record详细信息界面上就需要有两个hidden字段：&#60;h:inputHidden value=&#8221;#{personForm.person.id}&#8221; id=&#8221;id&#8221;/&#62;&#60;h:inputHidden value=&#8221;#{personForm.person.version}&#8221; id=&#8221;version&#8221;/&#62;Patterns of Enterprise Application Architecture里面的做法是将version作为session变量，都是可以的。只要这个值是读取对象时取出来的就可以。 这样做后，如果两个不同的用户同时修改一条记录时，hibernate就会报错Row was updated or deleted by another transaction。]]></description>
			<content:encoded><![CDATA[<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_lz-dDaxCZHc/Rmaqz3h5QYI/AAAAAAAAABs/jRfSRI2E5yY/s1600-h/01695366102a6624ab184cb5.jpg.bmp"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_lz-dDaxCZHc/Rmaqz3h5QYI/AAAAAAAAABs/jRfSRI2E5yY/s400/01695366102a6624ab184cb5.jpg.bmp" alt="" id="BLOGGER_PHOTO_ID_5072929838335607170" border="0" /></a><br />一个在Hibernate中的实践操作描述的很好的文档在<a href="http://caterpillar.onlyfun.net/Gossip/HibernateGossip/OptimisticLocking.html">这里</a>。原理上的描述在Addison Wesley : Patterns of Enterprise Application Architecture Chapter 16里面有详尽的描写，这本Martin Fowler撰写的书称乐观锁定为Optimistic Offline Lock，Hibernate的实现基本上跟这本书里面的一样。里面有副时序图，画的相当的明白。(copy from the book. copyleft.)</p>
<p>    另外一本书Hibernate in Action将乐观锁划分为Application Transacation，而悲观锁则划分为Database Transaction（Hibernate总是使用数据库的锁定机制，从不在内存中锁定对象！见：Hibernate的reference document）。<br />Appfuse实践<br /> Appfuse可以generate一个model的CRUD所有jsf页面，这可以作为实践上的起步。然后，version字段应该在页面上不能修改，而是作为一个hidden的字段，这样在显示record详细信息界面上就需要有两个hidden字段：<br />&lt;h:inputHidden value=&#8221;#{personForm.person.id}&#8221; id=&#8221;id&#8221;/&gt;<br />&lt;h:inputHidden value=&#8221;#{personForm.person.version}&#8221; id=&#8221;version&#8221;/&gt;<br />Patterns of Enterprise Application Architecture里面的做法是将version作为session变量，都是可以的。只要这个值是读取对象时取出来的就可以。<br /> 这样做后，如果两个不同的用户同时修改一条记录时，hibernate就会报错Row was updated or deleted by another transaction。</p>
]]></content:encoded>
			<wfw:commentRss>http://fkpwolf.net/2006/09/09/hibernate%e4%b9%90%e8%a7%82%e7%a6%bb%e7%ba%bf%e9%94%81appfuse-practise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

