<?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: Removing entities</title>
	<atom:link href="http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/</link>
	<description></description>
	<lastBuildDate>Thu, 11 Mar 2010 16:23:01 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: JPA Implementation Patterns &#124; Upthrust</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-94040</link>
		<dc:creator>JPA Implementation Patterns &#124; Upthrust</dc:creator>
		<pubDate>Tue, 02 Feb 2010 16:42:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-94040</guid>
		<description>[...] Removing Entities [...]</description>
		<content:encoded><![CDATA[<p>[...] Removing Entities [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-93027</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Fri, 06 Nov 2009 07:27:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-93027</guid>
		<description>&lt;strong&gt;@Colin:&lt;/strong&gt; Have you set your transaction boundaries correctly? The error message implies that the session has been closed before you invoked orderLineDao.remove().</description>
		<content:encoded><![CDATA[<p><strong>@Colin:</strong> Have you set your transaction boundaries correctly? The error message implies that the session has been closed before you invoked orderLineDao.remove().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-92999</link>
		<dc:creator>Colin</dc:creator>
		<pubDate>Sun, 01 Nov 2009 10:32:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-92999</guid>
		<description>There is a error:
org.apache.cxf.interceptor.Fault: Removing a detached instance ...OrderLine

when I executed the orderLineDao.remove(...)</description>
		<content:encoded><![CDATA[<p>There is a error:<br />
org.apache.cxf.interceptor.Fault: Removing a detached instance &#8230;OrderLine</p>
<p>when I executed the orderLineDao.remove(&#8230;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JPA Implementation Patterns &#171; Fernando Franzini Java Blog</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-92744</link>
		<dc:creator>JPA Implementation Patterns &#171; Fernando Franzini Java Blog</dc:creator>
		<pubDate>Fri, 09 Oct 2009 15:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-92744</guid>
		<description>[...] Removing entities [...]</description>
		<content:encoded><![CDATA[<p>[...] Removing entities [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-92310</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Wed, 19 Aug 2009 06:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-92310</guid>
		<description>&lt;strong&gt;@allan:&lt;/strong&gt; Putting the logic to disassociate this object from any it is connected to makes sure you won&#039;t run into any constraint violation in the database when removing it, so that is good reason to put it in &lt;tt&gt;@PreRemove.&lt;/tt&gt;

That does mean that the Java object model will be inconsistent with the contents of the database when the deletion fails. Then again, in that case an exception will probably be thrown ending the user request/transaction anyway.</description>
		<content:encoded><![CDATA[<p><strong>@allan:</strong> Putting the logic to disassociate this object from any it is connected to makes sure you won&#8217;t run into any constraint violation in the database when removing it, so that is good reason to put it in <tt>@PreRemove.</tt></p>
<p>That does mean that the Java object model will be inconsistent with the contents of the database when the deletion fails. Then again, in that case an exception will probably be thrown ending the user request/transaction anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: allan</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-92277</link>
		<dc:creator>allan</dc:creator>
		<pubDate>Tue, 11 Aug 2009 06:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-92277</guid>
		<description>Shouldn&#039;t that be @PostRemove rather than @PreRemove, what if things go wrong during deleting?</description>
		<content:encoded><![CDATA[<p>Shouldn&#8217;t that be @PostRemove rather than @PreRemove, what if things go wrong during deleting?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91562</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Sun, 19 Apr 2009 15:23:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-91562</guid>
		<description>&lt;b&gt;@Ed&lt;/b&gt;: Thanks for attending my J-Spring 2009 talk. I&#039;ll remember to bring my own water next time. ;-)

I&#039;m not going to translate your questions, but as this blog is usually in English, I will reply to your questions in English. If you don&#039;t mind.

1. When starting out with JPA, I started using more of the modern ideas, doing away with DAO&#039;s and DTO&#039;s, etc. Only to discover that these abstractions do have a place in the architecture. But I would love to hear other peoples&#039; innovations on JPA.

2. Acually, I don&#039;t think injecting your DAO into your domain objects is a good idea. They are in fact two different things: a domain object represents one, euh, thing in your domain, while a DAO represents a collection of those things. So I think having a non-static findOrder method in OrderDao is nicer than having a static findOrder in the Order class. The single responsibility principle applies here, I think.
But if a domain object needs access to other services, injecting them with those other services is very needed to prevent your domain model from being anemic. In fact that is what we do in our application. Most of our logic is in our domain objects; the services only load the right objects by invoking the DAO and then invoke the right methods on those objects. This is something I will revisit in a later blog.

3 I have looked at Dozer and it looks very nice. The only reason we haven&#039;t used it yet, is because the code we had to write to copy properties from DO to DTO and back was not that much. Introducing another framework for this did not seem like something that would pay off. The whole team would have to know about the framework, we could run into bugs in that framework, etc.

4. I didn&#039;t mention any JPA 2.0 features because I have no real-life experience with them. Once I do, I will probably be writing a few more blogs. I&#039;m really interested to see how the Criteria thing works out.

5. Using delegation instead of implementation inheritance is the thing to do these days. Then again, these DAO&#039;s are so small that I feel that implementation inheritance is simpler to understand. See also &lt;a href=&quot;http://blog.xebia.com/2009/03/09/jpa-implementation-patterns-data-access-objects/#comment-91561&quot; rel=&quot;nofollow&quot;&gt;my comment dated April 19th, 2009 at 3:50 pm&lt;/a&gt; on my DAO blog.

6. AFAIK, JPA doesn&#039;t have something similar to &lt;a href=&quot;http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#load(java.lang.Class, java.io.Serializable)&quot; rel=&quot;nofollow&quot;&gt;&lt;tt&gt;Session.load&lt;/tt&gt;&lt;/a&gt; so that is opportunity for performance you don&#039;t get with JPA.

7. Yup, we also use ValueType objects, a.k.a. &lt;a href=&quot;http://java.sun.com/javaee/5/docs/api/javax/persistence/Embedded.html&quot; rel=&quot;nofollow&quot;&gt;embedded&lt;/a&gt; objects, where ever we can. They make life a lot easier: no DAO to write, no lifecycle to worry about.

8. Actually, I think having a very flexibly DAO search interface makes the code harder to read. I&#039;d rather have a number of specific finder methods for all the different ways my app needs to &lt;a href=&quot;/2009/04/03/jpa-implementation-patterns-retrieving-entities/ rel=&quot;nofollow&quot;&gt;find entities&lt;/a&gt;. Then again, if your app needs to provide ad-hoc search capabilities to the end user, such an interface might be very beneficial.

9. (from your second comment) I&#039;m not really sure what you mean here. Could you give an example? Having all entities extend from a base class seem a bit EJB2-ish to me. It would also &quot;waste an inheritace&quot;, something you object to when it comes to DAOs.

10. Hmm, the package scope methods (I did not mentiond protected methods) in our code does work. I&#039;ve also heard about problems with using field access (my preference) versus property access when it comes to Hibernate proxies. I have a feeling that the proxies created for JPA work slightly differently than those created for Hibernate. The fact that JPA by default eagerly loads to-one associations probably helps here too. This is something I am going to investigate for my next blog on lazy loading.

Thanks again for attending. And for your long reply! Regards, Vincent.


</description>
		<content:encoded><![CDATA[<p><b>@Ed</b>: Thanks for attending my J-Spring 2009 talk. I&#8217;ll remember to bring my own water next time. <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I&#8217;m not going to translate your questions, but as this blog is usually in English, I will reply to your questions in English. If you don&#8217;t mind.</p>
<p>1. When starting out with JPA, I started using more of the modern ideas, doing away with DAO&#8217;s and DTO&#8217;s, etc. Only to discover that these abstractions do have a place in the architecture. But I would love to hear other peoples&#8217; innovations on JPA.</p>
<p>2. Acually, I don&#8217;t think injecting your DAO into your domain objects is a good idea. They are in fact two different things: a domain object represents one, euh, thing in your domain, while a DAO represents a collection of those things. So I think having a non-static findOrder method in OrderDao is nicer than having a static findOrder in the Order class. The single responsibility principle applies here, I think.<br />
But if a domain object needs access to other services, injecting them with those other services is very needed to prevent your domain model from being anemic. In fact that is what we do in our application. Most of our logic is in our domain objects; the services only load the right objects by invoking the DAO and then invoke the right methods on those objects. This is something I will revisit in a later blog.</p>
<p>3 I have looked at Dozer and it looks very nice. The only reason we haven&#8217;t used it yet, is because the code we had to write to copy properties from DO to DTO and back was not that much. Introducing another framework for this did not seem like something that would pay off. The whole team would have to know about the framework, we could run into bugs in that framework, etc.</p>
<p>4. I didn&#8217;t mention any JPA 2.0 features because I have no real-life experience with them. Once I do, I will probably be writing a few more blogs. I&#8217;m really interested to see how the Criteria thing works out.</p>
<p>5. Using delegation instead of implementation inheritance is the thing to do these days. Then again, these DAO&#8217;s are so small that I feel that implementation inheritance is simpler to understand. See also <a href="http://blog.xebia.com/2009/03/09/jpa-implementation-patterns-data-access-objects/#comment-91561" rel="nofollow">my comment dated April 19th, 2009 at 3:50 pm</a> on my DAO blog.</p>
<p>6. AFAIK, JPA doesn&#8217;t have something similar to <a href="http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#load(java.lang.Class, java.io.Serializable)" rel="nofollow"><tt>Session.load</tt></a> so that is opportunity for performance you don&#8217;t get with JPA.</p>
<p>7. Yup, we also use ValueType objects, a.k.a. <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Embedded.html" rel="nofollow">embedded</a> objects, where ever we can. They make life a lot easier: no DAO to write, no lifecycle to worry about.</p>
<p>8. Actually, I think having a very flexibly DAO search interface makes the code harder to read. I&#8217;d rather have a number of specific finder methods for all the different ways my app needs to <a href="/2009/04/03/jpa-implementation-patterns-retrieving-entities/ rel="nofollow">find entities</a>. Then again, if your app needs to provide ad-hoc search capabilities to the end user, such an interface might be very beneficial.</p>
<p>9. (from your second comment) I&#8217;m not really sure what you mean here. Could you give an example? Having all entities extend from a base class seem a bit EJB2-ish to me. It would also &#8220;waste an inheritace&#8221;, something you object to when it comes to DAOs.</p>
<p>10. Hmm, the package scope methods (I did not mentiond protected methods) in our code does work. I&#8217;ve also heard about problems with using field access (my preference) versus property access when it comes to Hibernate proxies. I have a feeling that the proxies created for JPA work slightly differently than those created for Hibernate. The fact that JPA by default eagerly loads to-one associations probably helps here too. This is something I am going to investigate for my next blog on lazy loading.</p>
<p>Thanks again for attending. And for your long reply! Regards, Vincent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91560</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Sun, 19 Apr 2009 14:35:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-91560</guid>
		<description>&lt;strong&gt;@Andrew&lt;/strong&gt;: Yes, the relation between OrderLine and Order will be mapped by a foreign key. But no, a constraint is not added by default. One way to signal these orphans when they occur is to add set &lt;tt&gt;optional=false&lt;/tt&gt; on the relation from OrderLine to Order:&lt;pre lang=&quot;java&quot;&gt;
@ManyToOne(optional=false)
private Order order;
&lt;/pre&gt;

If you do that, Hibernate will throw this exception when you try and commit the transaction in which you created that orphan:&lt;br/&gt;
&lt;tt&gt;org.hibernate.PropertyValueException: not-null property references a null or transient value: com.xebia.jpaip.order.OrderLine.order&lt;/tt&gt;</description>
		<content:encoded><![CDATA[<p><strong>@Andrew</strong>: Yes, the relation between OrderLine and Order will be mapped by a foreign key. But no, a constraint is not added by default. One way to signal these orphans when they occur is to add set <tt>optional=false</tt> on the relation from OrderLine to Order:
<pre lang="java">
@ManyToOne(optional=false)
private Order order;
</pre>
<p>If you do that, Hibernate will throw this exception when you try and commit the transaction in which you created that orphan:<br />
<tt>org.hibernate.PropertyValueException: not-null property references a null or transient value: com.xebia.jpaip.order.OrderLine.order</tt></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ed</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91549</link>
		<dc:creator>ed</dc:creator>
		<pubDate>Thu, 16 Apr 2009 08:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-91549</guid>
		<description>BTW: wat me nog te binnen schoot net (mijn schermpie staat nog open).
Als je je Entity laat extenden van een gemeenschappelijkde EntityBase class, kan je daar allerlei handige functionaliteit in stoppen zoals:
- Visitor pattern (gebaseerd op reflectie). Dit heb je nodig als je correct met proxies om wil gaan.
- Validators met Error return object via Observer pattern.
- Observer pattern die listeners afvuurt voor/na save, remove etc... Dit werkt erg prettig en kan je gebruiken om bijvoorbeeld een datum te updaten voordat het de db in gaat, etc...

Nog wat: Pas op met protected methods in Domain objecten. Je zei op ten duur in je presentatie dat je die setInternal* method protected kon maken. DIT KAN NIET als je wilt dat je proxies (met lazy loading) goed werken. Dan moet dit nl public zijn om je proxies correct te triggeren. Dus pas hier mee op.
Maar goed: proxies in domain objecten is ook een heel apart onderwerp waardoor vaak vele bugs in projecten zitten omdat het niet correct wordt begrepen. 
Bijvoorbeeld: het gebruik van instanceof en getClass() method in equals() van domain object is uit ten boze en kan tot raare fouten leiden. Zie de bijbel voor meer uitleg.
Ik zelf heb altijd standaard testen die ik op domain objecten los laat om te testen of ze proxy-safe zijn.


Ik ga weer snel verder....
-- Ed</description>
		<content:encoded><![CDATA[<p>BTW: wat me nog te binnen schoot net (mijn schermpie staat nog open).<br />
Als je je Entity laat extenden van een gemeenschappelijkde EntityBase class, kan je daar allerlei handige functionaliteit in stoppen zoals:<br />
- Visitor pattern (gebaseerd op reflectie). Dit heb je nodig als je correct met proxies om wil gaan.<br />
- Validators met Error return object via Observer pattern.<br />
- Observer pattern die listeners afvuurt voor/na save, remove etc&#8230; Dit werkt erg prettig en kan je gebruiken om bijvoorbeeld een datum te updaten voordat het de db in gaat, etc&#8230;</p>
<p>Nog wat: Pas op met protected methods in Domain objecten. Je zei op ten duur in je presentatie dat je die setInternal* method protected kon maken. DIT KAN NIET als je wilt dat je proxies (met lazy loading) goed werken. Dan moet dit nl public zijn om je proxies correct te triggeren. Dus pas hier mee op.<br />
Maar goed: proxies in domain objecten is ook een heel apart onderwerp waardoor vaak vele bugs in projecten zitten omdat het niet correct wordt begrepen.<br />
Bijvoorbeeld: het gebruik van instanceof en getClass() method in equals() van domain object is uit ten boze en kan tot raare fouten leiden. Zie de bijbel voor meer uitleg.<br />
Ik zelf heb altijd standaard testen die ik op domain objecten los laat om te testen of ze proxy-safe zijn.</p>
<p>Ik ga weer snel verder&#8230;.<br />
&#8211; Ed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ed</title>
		<link>http://blog.xebia.com/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91548</link>
		<dc:creator>ed</dc:creator>
		<pubDate>Thu, 16 Apr 2009 08:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=976#comment-91548</guid>
		<description>He Vincent,

Ik was gisteren bij je JSpring 2009 voordracht.
Hastikke goed gedaan, lekker rustig en duidelijk. Alleen het eind was een beetje rommelig, maar dat komt vast nog een keer goed ;).

Anyway: ik vond het prettig om herkenbare problement te zien, maar had wel het gevoel alsof ik 5 jaar terug in tijd gng. Ik had gehoopt meer innovatieve oplossingen te zien.
Een paar dingetjes (zeker niet compleet):

- Inject je Dao in je domein objecten (met Spring bijvoorbeeld). Je gebruikt het Anemic Domain pattern wat echt not-done is met de huidige technieken en tijd. Stop gewoon je remove, save, etc... operaties direct in je domain objecten (ik vroeg hier ook naar tijdens je voordracht). Zie: http://www.theserverside.com/news/thread.tss?thread_id=38047

- Waarom je eigen DTO converter schrijven als er tools als Dozer zijn die dit reeds netjes voor je doen?

- Waarom niet dingen van JPA 2.0 reeds in je voordracht gebruiken?

- Ik zou die DAO implementaties niet laten exenden van je DAO base class waarin je get/find, etc... methods zitten maar ik zou deze laatste als een Persister class injecten in je DAO implementatie class. Dit werkt prettiger (ik had het eerste exact zoals jij het schetste) en scheelt een inherance, en je weet dat die zeldzaam zijn want je heb er maar 1 (dus: gebruik delegator pattern).

- Ik weet niet precies of JPA dat nu goed ondersteund, maar maak ook meer gebruikt van de hibernate load/get i.p.v. alles via de get laten lopen.
Voorbeeld: als je een nieuw adres aanmaakt en deze persist, en stop daarin een Country object waarvan je zeker weet dat hij bestaat in de db, gebruik dan load voor het country object. Dit scheelt een query en bij grote loads, kan dat een behoorlijke performance boost zijn.

- Je refereerde naar de bekende Bijbel van Gavin King en Christian. Dan ben je op de hoogte van Entity en ValueType objecten waar ze steeds onderscheid in maken.
Samengevat: Entity object: heeft eigen levenscyclus en ValueType object niet en die hangt altijd aan een Entity object. 
Voorbeeld:
Entity -&gt; Member object.
ValueType -&gt; Email object.
Member heeft eigen methods zoals remove/save, etc... en Email niet, die volgt het gedrag van zijn Member (als Component in HIbernate termen).
Dit werkt bijzonder prettig en ik heb hier op diverse grote enterprise projecten goede ervaringen mee. D.w.z.: Categoriseer al je domain ojbecten in deze 2 (m.u.v. een mix voor performance redenen maar dat is een technisch feesie).

- Ik mis een flexible DoaSearch interface (naast de DAO interface). Voorbeeld van 1 van zijn methods:
public List findEntities(J persistenceClass, SearchCriteria search, SortCriteria sort)

Zoals je ziet kan je hiermee felxibel queries bouwen (SQL, HQL of JPA achtig afhankelijk van je implementatie die je inschiet).
Dit werkt er prettig omdat je hiermee in het Criteria object aangeeft op welke velden je van een Member wil zoeken en vervolgens maakt de query builder automatisch via een specifieke Query appender (via het observer pattern) de query voor je en klaar is kees. Deze appenders schiet je in via Spring, en het toevoegen van een find is dus puur configuratie in de backend, het schrijven de de nieuwe appender en criteria.


Euuwwww.. dit was het wel even, de rest ben ik alweer vergeten.

Misschien heb je er wat aan (ik wilde je eigenlijk paar dingetjes mailen, maar het zijn er toch meer geworden :( )....
Als je wat wil weten, hoor ik het wel.
Cheers,
Ed
PS: vergeet voortaan je water niet :)</description>
		<content:encoded><![CDATA[<p>He Vincent,</p>
<p>Ik was gisteren bij je JSpring 2009 voordracht.<br />
Hastikke goed gedaan, lekker rustig en duidelijk. Alleen het eind was een beetje rommelig, maar dat komt vast nog een keer goed <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Anyway: ik vond het prettig om herkenbare problement te zien, maar had wel het gevoel alsof ik 5 jaar terug in tijd gng. Ik had gehoopt meer innovatieve oplossingen te zien.<br />
Een paar dingetjes (zeker niet compleet):</p>
<p>- Inject je Dao in je domein objecten (met Spring bijvoorbeeld). Je gebruikt het Anemic Domain pattern wat echt not-done is met de huidige technieken en tijd. Stop gewoon je remove, save, etc&#8230; operaties direct in je domain objecten (ik vroeg hier ook naar tijdens je voordracht). Zie: <a href="http://www.theserverside.com/news/thread.tss?thread_id=38047" rel="nofollow">http://www.theserverside.com/news/thread.tss?thread_id=38047</a></p>
<p>- Waarom je eigen DTO converter schrijven als er tools als Dozer zijn die dit reeds netjes voor je doen?</p>
<p>- Waarom niet dingen van JPA 2.0 reeds in je voordracht gebruiken?</p>
<p>- Ik zou die DAO implementaties niet laten exenden van je DAO base class waarin je get/find, etc&#8230; methods zitten maar ik zou deze laatste als een Persister class injecten in je DAO implementatie class. Dit werkt prettiger (ik had het eerste exact zoals jij het schetste) en scheelt een inherance, en je weet dat die zeldzaam zijn want je heb er maar 1 (dus: gebruik delegator pattern).</p>
<p>- Ik weet niet precies of JPA dat nu goed ondersteund, maar maak ook meer gebruikt van de hibernate load/get i.p.v. alles via de get laten lopen.<br />
Voorbeeld: als je een nieuw adres aanmaakt en deze persist, en stop daarin een Country object waarvan je zeker weet dat hij bestaat in de db, gebruik dan load voor het country object. Dit scheelt een query en bij grote loads, kan dat een behoorlijke performance boost zijn.</p>
<p>- Je refereerde naar de bekende Bijbel van Gavin King en Christian. Dan ben je op de hoogte van Entity en ValueType objecten waar ze steeds onderscheid in maken.<br />
Samengevat: Entity object: heeft eigen levenscyclus en ValueType object niet en die hangt altijd aan een Entity object.<br />
Voorbeeld:<br />
Entity -&gt; Member object.<br />
ValueType -&gt; Email object.<br />
Member heeft eigen methods zoals remove/save, etc&#8230; en Email niet, die volgt het gedrag van zijn Member (als Component in HIbernate termen).<br />
Dit werkt bijzonder prettig en ik heb hier op diverse grote enterprise projecten goede ervaringen mee. D.w.z.: Categoriseer al je domain ojbecten in deze 2 (m.u.v. een mix voor performance redenen maar dat is een technisch feesie).</p>
<p>- Ik mis een flexible DoaSearch interface (naast de DAO interface). Voorbeeld van 1 van zijn methods:<br />
public List findEntities(J persistenceClass, SearchCriteria search, SortCriteria sort)</p>
<p>Zoals je ziet kan je hiermee felxibel queries bouwen (SQL, HQL of JPA achtig afhankelijk van je implementatie die je inschiet).<br />
Dit werkt er prettig omdat je hiermee in het Criteria object aangeeft op welke velden je van een Member wil zoeken en vervolgens maakt de query builder automatisch via een specifieke Query appender (via het observer pattern) de query voor je en klaar is kees. Deze appenders schiet je in via Spring, en het toevoegen van een find is dus puur configuratie in de backend, het schrijven de de nieuwe appender en criteria.</p>
<p>Euuwwww.. dit was het wel even, de rest ben ik alweer vergeten.</p>
<p>Misschien heb je er wat aan (ik wilde je eigenlijk paar dingetjes mailen, maar het zijn er toch meer geworden <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  )&#8230;.<br />
Als je wat wil weten, hoor ik het wel.<br />
Cheers,<br />
Ed<br />
PS: vergeet voortaan je water niet <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
