<?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: Mapping inheritance hierarchies</title>
	<atom:link href="http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/</link>
	<description></description>
	<lastBuildDate>Thu, 18 Mar 2010 13:27:36 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/comment-page-1/#comment-92478</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Fri, 18 Sep 2009 10:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2071#comment-92478</guid>
		<description>&lt;strong&gt;@Simon Massey:&lt;/strong&gt; Using the @Pre/@Post handlers is an even neater way to solve this than doing it in the getters/setters as I propose. Basically, you actually implemented the &quot;Clever use of the &lt;tt&gt;@PrePersist&lt;/tt&gt; and &lt;tt&gt;@PreUpdate&lt;/tt&gt; lifecycle hooks&quot; I mention. ;-)</description>
		<content:encoded><![CDATA[<p><strong>@Simon Massey:</strong> Using the @Pre/@Post handlers is an even neater way to solve this than doing it in the getters/setters as I propose. Basically, you actually implemented the &#8220;Clever use of the <tt>@PrePersist</tt> and <tt>@PreUpdate</tt> lifecycle hooks&#8221; I mention. <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Massey</title>
		<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/comment-page-1/#comment-92476</link>
		<dc:creator>Simon Massey</dc:creator>
		<pubDate>Thu, 17 Sep 2009 23:56:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2071#comment-92476</guid>
		<description>We use the &quot;clob/blob overflow column&quot; pattern extensively in some framework code. In our case it is an XML serialization of the subclass fields. The proprietary framework in question is a few years old now so it is hibernate not jpa with interceptors not @pre/@Post hooks but doing exactly the same thing. 

The framework allows for tens of thousands of custom types going into the same smallish set of entity tables. Our business users design new types on the fly from within the application and we use a custom class load to generate all the pojo classes at runtime on first use. So it has mega wide and mega deep hierarchies all generated at runtime.

The generated subclass types have unmapped properties fields with setters and getters. Within hibernate interceptor life cycle hooks we pack those unmapped subclass fields into the mapped xml base class blob to dehydrate the object to store it, then on rehydration unpack them from the xml to activate it. Once again you could do that with @pre/@post handlers. 

It has been a few years since the first version of our framework. Your suggestion here on this blog is the first time I have head of anyone else doing the same thing.</description>
		<content:encoded><![CDATA[<p>We use the &#8220;clob/blob overflow column&#8221; pattern extensively in some framework code. In our case it is an XML serialization of the subclass fields. The proprietary framework in question is a few years old now so it is hibernate not jpa with interceptors not @pre/@Post hooks but doing exactly the same thing. </p>
<p>The framework allows for tens of thousands of custom types going into the same smallish set of entity tables. Our business users design new types on the fly from within the application and we use a custom class load to generate all the pojo classes at runtime on first use. So it has mega wide and mega deep hierarchies all generated at runtime.</p>
<p>The generated subclass types have unmapped properties fields with setters and getters. Within hibernate interceptor life cycle hooks we pack those unmapped subclass fields into the mapped xml base class blob to dehydrate the object to store it, then on rehydration unpack them from the xml to activate it. Once again you could do that with @pre/@post handlers. </p>
<p>It has been a few years since the first version of our framework. Your suggestion here on this blog is the first time I have head of anyone else doing the same thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/comment-page-1/#comment-91921</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Mon, 22 Jun 2009 07:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2071#comment-91921</guid>
		<description>&lt;strong&gt;@Andrew, @Maarten:&lt;/strong&gt; As Maarten already guessed I perform the serialization/deserialization in the entity class to have more control over it. This way I can use different serialization mechanisms, set the blob field to be updatable, catch and handle ClassNotFoundExceptions and other serialization errors. Using a Hibernate UserType would have been nicer but does not work for all JPA providers.

The interesting thing with this and with other JPA implementation patterns (&lt;a href=&quot;/2009/03/16/jpa-implementation-patterns-bidirectional-assocations/&quot; rel=&quot;nofollow&quot;&gt;bidirectional associations&lt;/a&gt;, using &lt;a href=&quot;/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91525&quot; rel=&quot;nofollow&quot;&gt;@PreRemove&lt;/a&gt;, &lt;a href=&quot;/2009/05/25/jpa-implementation-patterns-bidirectional-associations-vs-lazy-loading/&quot; rel=&quot;nofollow&quot;&gt;bidirectional associations vs. lazy loading&lt;/a&gt;, &lt;a href=&quot;/2009/06/03/jpa-implementation-patterns-using-uuids-as-primary-keys/&quot; rel=&quot;nofollow&quot;&gt;using UUIDs as primary keys&lt;/a&gt;) is that they all &quot;pollute&quot; the entity class with their &quot;special JPA sauce&quot;. It would be nice if one could define an external &quot;persistence handler&quot; that takes care of all this nasty stuff. Something like a UserType but with more abilities. Instead of the @Pre/@Post lifecycle hooks with only invite you to do this kind of nasty stuff.

I guess this matches nicely with &lt;a href=&quot;/2009/03/09/jpa-implementation-patterns-data-access-objects/&quot; rel=&quot;nofollow&quot;&gt;my comment at the beginning of the series&lt;/a&gt; that the JPA abstraction, as it is today, is pretty leaky.</description>
		<content:encoded><![CDATA[<p><strong>@Andrew, @Maarten:</strong> As Maarten already guessed I perform the serialization/deserialization in the entity class to have more control over it. This way I can use different serialization mechanisms, set the blob field to be updatable, catch and handle ClassNotFoundExceptions and other serialization errors. Using a Hibernate UserType would have been nicer but does not work for all JPA providers.</p>
<p>The interesting thing with this and with other JPA implementation patterns (<a href="/2009/03/16/jpa-implementation-patterns-bidirectional-assocations/" rel="nofollow">bidirectional associations</a>, using <a href="/2009/04/09/jpa-implementation-patterns-removing-entities/comment-page-1/#comment-91525" rel="nofollow">@PreRemove</a>, <a href="/2009/05/25/jpa-implementation-patterns-bidirectional-associations-vs-lazy-loading/" rel="nofollow">bidirectional associations vs. lazy loading</a>, <a href="/2009/06/03/jpa-implementation-patterns-using-uuids-as-primary-keys/" rel="nofollow">using UUIDs as primary keys</a>) is that they all &#8220;pollute&#8221; the entity class with their &#8220;special JPA sauce&#8221;. It would be nice if one could define an external &#8220;persistence handler&#8221; that takes care of all this nasty stuff. Something like a UserType but with more abilities. Instead of the @Pre/@Post lifecycle hooks with only invite you to do this kind of nasty stuff.</p>
<p>I guess this matches nicely with <a href="/2009/03/09/jpa-implementation-patterns-data-access-objects/" rel="nofollow">my comment at the beginning of the series</a> that the JPA abstraction, as it is today, is pretty leaky.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maarten Winkels</title>
		<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/comment-page-1/#comment-91918</link>
		<dc:creator>Maarten Winkels</dc:creator>
		<pubDate>Mon, 22 Jun 2009 02:00:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2071#comment-91918</guid>
		<description>@Andrew: The default for JPA is to store a complex, non-entity property in a BLOB. It uses standard Java Serialization of course. Due to its limitations Vincent mentions in the blog, the serialization/deserialization is performed in the Entity class, I suppose.

+1 for using a UserType for this kind of transformation. But I think UserTypes are Hibernate specific and not JPA-ish.</description>
		<content:encoded><![CDATA[<p>@Andrew: The default for JPA is to store a complex, non-entity property in a BLOB. It uses standard Java Serialization of course. Due to its limitations Vincent mentions in the blog, the serialization/deserialization is performed in the Entity class, I suppose.</p>
<p>+1 for using a UserType for this kind of transformation. But I think UserTypes are Hibernate specific and not JPA-ish.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/06/21/jpa-implementation-patterns-mapping-inheritance-hierarchies/comment-page-1/#comment-91916</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Sun, 21 Jun 2009 20:23:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2071#comment-91916</guid>
		<description>Is it desirable to have to the &lt;tt&gt;serializedCommand&lt;/tt&gt; byte array as a member of your entity class? The transient &lt;tt&gt;command&lt;/tt&gt; object would appear to be the one that is the &quot;natural&quot; member of your domain model - the fact that it happens to be persisted as a byte array is purely an implementation detail, and probably not something you would want to leak into your API in this way.

Would a Hibernate user type not be more appropriate in this case - I think there might even be a &quot;Serializable2LobUserType&quot; out there already.</description>
		<content:encoded><![CDATA[<p>Is it desirable to have to the <tt>serializedCommand</tt> byte array as a member of your entity class? The transient <tt>command</tt> object would appear to be the one that is the &#8220;natural&#8221; member of your domain model &#8211; the fact that it happens to be persisted as a byte array is purely an implementation detail, and probably not something you would want to leak into your API in this way.</p>
<p>Would a Hibernate user type not be more appropriate in this case &#8211; I think there might even be a &#8220;Serializable2LobUserType&#8221; out there already.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
