<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: JPA implementation patterns: Wrap-up</title>
	<atom:link href="http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 08 Feb 2012 14:41:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ted Kenney</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-101194</link>
		<dc:creator>Ted Kenney</dc:creator>
		<pubDate>Thu, 24 Feb 2011 02:01:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-101194</guid>
		<description>For an interesting read on a similar, but alternative, approach to JPA, take a look at the article and subsequent discussion in the comments, on the eXtremeDB JNI at http://java.dzone.com/articles/java-annotations-and.  More information about eXtremeDB is here:  http://www.mcobject.com/extremedbfamily.shtml</description>
		<content:encoded><![CDATA[<p>For an interesting read on a similar, but alternative, approach to JPA, take a look at the article and subsequent discussion in the comments, on the eXtremeDB JNI at <a href="http://java.dzone.com/articles/java-annotations-and" rel="nofollow">http://java.dzone.com/articles/java-annotations-and</a>.  More information about eXtremeDB is here:  <a href="http://www.mcobject.com/extremedbfamily.shtml" rel="nofollow">http://www.mcobject.com/extremedbfamily.shtml</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett Lindsley</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-100359</link>
		<dc:creator>Brett Lindsley</dc:creator>
		<pubDate>Tue, 08 Feb 2011 13:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-100359</guid>
		<description>Very good articles; however, one issue that was not covered was dealing with exceptions. Most methods in the EntityManager throw many exceptions. Some are fatal, some are informational. One exception that is generally confusing is the OptimisticLockException. This exception indicates two transactions interfered - one was successful, the other got an exception. The exception is not fatal, thus should be retried. If the exception is thrown after several retries (maybe because of a strange execution pattern), it should be considered to be fatal.

The solution I use is to introduce a &quot;management layer&quot; between the DAO and the EJB implementing the JPA calls. The management layer has the same method signatures (it is implemented by simply extending the JPA interface), and implements the retries. For example, the DAO may call the management layer for a remove. The management layer calls the JPA EJB to remove the entity. If the JPA EJB throws an exception, the management layer attempts the delete again. After several failure attempts, the mangement layer throws a checked exception to the DAO. The checked exception indicates the DAO must deal with the fact that the delete could not be completed. I usually throw this exception from the DAO to allow upper layers to take corrective action.

A few tips on implementing this strategy. The management EJB uses the default transaction (uses the existing or creates a new one if none exists); however, the JPA EJB uses &quot;create new&quot; such that if the transaction fails, the management EJB can capture it and try again. In the JPA EJB, I catch all run-time exceptions and either process them (e.g. converting a not found to a null response), or, throw a checked exception. This prevents the container from pumping the log with a lot of junk about EJB exceptions.

I found these articles interesting because I found an important use of the DAO is to access the service locator to find the EJBs. This isolates all implementation dependencies to the DAO and keeps the upper layers of code clean. It also allows switching in other DB systems (which has happened on occasion).

Brett.</description>
		<content:encoded><![CDATA[<p>Very good articles; however, one issue that was not covered was dealing with exceptions. Most methods in the EntityManager throw many exceptions. Some are fatal, some are informational. One exception that is generally confusing is the OptimisticLockException. This exception indicates two transactions interfered &#8211; one was successful, the other got an exception. The exception is not fatal, thus should be retried. If the exception is thrown after several retries (maybe because of a strange execution pattern), it should be considered to be fatal.</p>
<p>The solution I use is to introduce a &#8220;management layer&#8221; between the DAO and the EJB implementing the JPA calls. The management layer has the same method signatures (it is implemented by simply extending the JPA interface), and implements the retries. For example, the DAO may call the management layer for a remove. The management layer calls the JPA EJB to remove the entity. If the JPA EJB throws an exception, the management layer attempts the delete again. After several failure attempts, the mangement layer throws a checked exception to the DAO. The checked exception indicates the DAO must deal with the fact that the delete could not be completed. I usually throw this exception from the DAO to allow upper layers to take corrective action.</p>
<p>A few tips on implementing this strategy. The management EJB uses the default transaction (uses the existing or creates a new one if none exists); however, the JPA EJB uses &#8220;create new&#8221; such that if the transaction fails, the management EJB can capture it and try again. In the JPA EJB, I catch all run-time exceptions and either process them (e.g. converting a not found to a null response), or, throw a checked exception. This prevents the container from pumping the log with a lot of junk about EJB exceptions.</p>
<p>I found these articles interesting because I found an important use of the DAO is to access the service locator to find the EJBs. This isolates all implementation dependencies to the DAO and keeps the upper layers of code clean. It also allows switching in other DB systems (which has happened on occasion).</p>
<p>Brett.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jochen Szostek</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-94072</link>
		<dc:creator>Jochen Szostek</dc:creator>
		<pubDate>Tue, 09 Feb 2010 10:37:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-94072</guid>
		<description>Awesome set of interesting articles!</description>
		<content:encoded><![CDATA[<p>Awesome set of interesting articles!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JPA Implementation Patterns &#124; Upthrust</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-94019</link>
		<dc:creator>JPA Implementation Patterns &#124; Upthrust</dc:creator>
		<pubDate>Sat, 30 Jan 2010 11:29:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-94019</guid>
		<description>[...] for anyone who new to JPA. In this post I am going to summarize each and every post from &#8216;JPA Implementation Patterns&#8216; article [...]</description>
		<content:encoded><![CDATA[<p>[...] for anyone who new to JPA. In this post I am going to summarize each and every post from &#8216;JPA Implementation Patterns&#8216; article [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ecapot</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-93466</link>
		<dc:creator>ecapot</dc:creator>
		<pubDate>Fri, 11 Dec 2009 14:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-93466</guid>
		<description>Is there any JPA implementation pattern for storing internationalized data?
I found some solutions for hibernate

e.g. http://www.theserverside.com/tt/blogs/showblog.tss?id=HibernateInternational

but nothing for JPA only.

Perhaps someone can post suggestions or maybe JPA 2.0 solutions?</description>
		<content:encoded><![CDATA[<p>Is there any JPA implementation pattern for storing internationalized data?<br />
I found some solutions for hibernate</p>
<p>e.g. <a href="http://www.theserverside.com/tt/blogs/showblog.tss?id=HibernateInternational" rel="nofollow">http://www.theserverside.com/tt/blogs/showblog.tss?id=HibernateInternational</a></p>
<p>but nothing for JPA only.</p>
<p>Perhaps someone can post suggestions or maybe JPA 2.0 solutions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: edansys &#187; Blog Archive &#187; links for 2009-12-02</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-93318</link>
		<dc:creator>edansys &#187; Blog Archive &#187; links for 2009-12-02</dc:creator>
		<pubDate>Thu, 03 Dec 2009 01:44:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-93318</guid>
		<description>[...] JPA implementation patterns: Wrap-up &#124; Xebia Blog (tags: JPA patterns) [...]</description>
		<content:encoded><![CDATA[<p>[...] JPA implementation patterns: Wrap-up | Xebia Blog (tags: JPA patterns) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-92996</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Sat, 31 Oct 2009 10:05:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-92996</guid>
		<description>&lt;strong&gt;@JJ:&lt;/strong&gt; No, I have not created a project to bundle all this code. I don&#039;t really think there is that much code to bundle... But please feel free to this so in my stead. By publishing the code I have placed it in the public domain already anyway. ;-)
</description>
		<content:encoded><![CDATA[<p><strong>@JJ:</strong> No, I have not created a project to bundle all this code. I don&#8217;t really think there is that much code to bundle&#8230; But please feel free to this so in my stead. By publishing the code I have placed it in the public domain already anyway. <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JJ</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-92966</link>
		<dc:creator>JJ</dc:creator>
		<pubDate>Tue, 27 Oct 2009 05:09:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-92966</guid>
		<description>Vincent, have you/will you create an FOS project that has the core classes and other ones to support the ideas you&#039;ve presented?  Would be good... :-)

From a little searching, I saw projects create their own similar base classes within themselves (even FOS ones), and even one that tries to be stand alone (is nice, but has some goofy config needs that cause concern for me).  It is uncoordinated.

Would be good to create a simple clean one.</description>
		<content:encoded><![CDATA[<p>Vincent, have you/will you create an FOS project that has the core classes and other ones to support the ideas you&#8217;ve presented?  Would be good&#8230; <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>From a little searching, I saw projects create their own similar base classes within themselves (even FOS ones), and even one that tries to be stand alone (is nice, but has some goofy config needs that cause concern for me).  It is uncoordinated.</p>
<p>Would be good to create a simple clean one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-92340</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Mon, 24 Aug 2009 18:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-92340</guid>
		<description>&lt;strong&gt;@Ramkumar:&lt;/strong&gt; Thanks for the translation. Yahoo Babel Fish even seems to a pretty descent job of it. :-)</description>
		<content:encoded><![CDATA[<p><strong>@Ramkumar:</strong> Thanks for the translation. Yahoo Babel Fish even seems to a pretty descent job of it. <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramkumar</title>
		<link>http://blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/#comment-92338</link>
		<dc:creator>Ramkumar</dc:creator>
		<pubDate>Mon, 24 Aug 2009 00:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2605#comment-92338</guid>
		<description>I found the JPA presentation in Dutch very useful introduction to JPA. Thought it was too useful to remain in Dutch and used Yahoo&#039;s Babel Fish service to translate it into English. Here is the URL of my attempt:

(Original in Dutch):
http://www.nljug.org/pages/events/content/jspring_2009/sessions/00027/ 

Translation in English (as a Google Doc):
http://docs.google.com/Doc?docid=0AZ8jw5JC8Og2ZGZmNTI4emtfMTJtZzRoYmNjag&amp;hl=en</description>
		<content:encoded><![CDATA[<p>I found the JPA presentation in Dutch very useful introduction to JPA. Thought it was too useful to remain in Dutch and used Yahoo&#8217;s Babel Fish service to translate it into English. Here is the URL of my attempt:</p>
<p>(Original in Dutch):<br />
<a href="http://www.nljug.org/pages/events/content/jspring_2009/sessions/00027/" rel="nofollow">http://www.nljug.org/pages/events/content/jspring_2009/sessions/00027/</a> </p>
<p>Translation in English (as a Google Doc):<br />
<a href="http://docs.google.com/Doc?docid=0AZ8jw5JC8Og2ZGZmNTI4emtfMTJtZzRoYmNjag&#038;hl=en" rel="nofollow">http://docs.google.com/Doc?docid=0AZ8jw5JC8Og2ZGZmNTI4emtfMTJtZzRoYmNjag&#038;hl=en</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/2009/07/13/jpa-implementation-patterns-wrap-up/feed/ ) in 0.46361 seconds, on Feb 9th, 2012 at 7:53 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 8:53 pm UTC -->
