<?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: Understanding and writing Hibernate custom user types</title>
	<atom:link href="http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/</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: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-94190</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Tue, 23 Feb 2010 15:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-94190</guid>
		<description>&lt;em&gt;@Prashant:&lt;/em&gt; I assume &quot;data load from flat files&quot; means you&#039;re importing the data without using Hibernate, i.e. via the DB2 or some other SQL client. 
If you&#039;re having problems populating the version column at this stage the most advisable thing would seem to be to investigate why &quot;DB2 ignores the default value&quot; and see if you can either fix that or run some cleanup SQL after the import (a trigger would be another obvious option but you mentioned that you wanted to avoid that).

You &lt;em&gt;could&lt;/em&gt; try using &lt;tt&gt;nullSafeGet&lt;/tt&gt; in a &lt;a href=&quot;http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/usertype/UserVersionType.html&quot; rel=&quot;nofollow&quot;&gt;UserVersionType&lt;/a&gt; to work around this problem, but even though I think it could work I wouldn&#039;t recommend it. For one, you&#039;re changing your application code to deal with a data problem that only occurs during import, not normal application operation. This way, you risk missing real data problems unless you find a way to change the &lt;tt&gt;nullSafeGet&lt;/tt&gt; behaviour at runtime. 

You are also going to have to remove the non-nullable constraint on the column, which again weakens your defences against data corruption. Hibernate can&#039;t help you there (again, I&#039;m assuming here that your flat file import is going straight to the DB, not via Hibernate).</description>
		<content:encoded><![CDATA[<p><em>@Prashant:</em> I assume &#8220;data load from flat files&#8221; means you&#8217;re importing the data without using Hibernate, i.e. via the DB2 or some other SQL client.<br />
If you&#8217;re having problems populating the version column at this stage the most advisable thing would seem to be to investigate why &#8220;DB2 ignores the default value&#8221; and see if you can either fix that or run some cleanup SQL after the import (a trigger would be another obvious option but you mentioned that you wanted to avoid that).</p>
<p>You <em>could</em> try using <tt>nullSafeGet</tt> in a <a href="http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/usertype/UserVersionType.html" rel="nofollow">UserVersionType</a> to work around this problem, but even though I think it could work I wouldn&#8217;t recommend it. For one, you&#8217;re changing your application code to deal with a data problem that only occurs during import, not normal application operation. This way, you risk missing real data problems unless you find a way to change the <tt>nullSafeGet</tt> behaviour at runtime. </p>
<p>You are also going to have to remove the non-nullable constraint on the column, which again weakens your defences against data corruption. Hibernate can&#8217;t help you there (again, I&#8217;m assuming here that your flat file import is going straight to the DB, not via Hibernate).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-94185</link>
		<dc:creator>Prashant</dc:creator>
		<pubDate>Mon, 22 Feb 2010 13:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-94185</guid>
		<description>I have a couple of table each of which are having version column. These tables are populated with data load from flat files. Flat files data load does not populate version column. Don&#039;t know how to populate version column value. I have however 2 cases:

Case 1:

version property as nullable and setting default value as 1. After data migration value becomes as null (dont know why DB2 ignores default value).

Case 2:

version property as not nullable. In this case null pointer exception is coming as migrated data does not contain version value.

We are having DB2 database and don&#039;t want to change flat files also (I don&#039;t want any kind of trigger solution).

Is Version UserType of any help here?</description>
		<content:encoded><![CDATA[<p>I have a couple of table each of which are having version column. These tables are populated with data load from flat files. Flat files data load does not populate version column. Don&#8217;t know how to populate version column value. I have however 2 cases:</p>
<p>Case 1:</p>
<p>version property as nullable and setting default value as 1. After data migration value becomes as null (dont know why DB2 ignores default value).</p>
<p>Case 2:</p>
<p>version property as not nullable. In this case null pointer exception is coming as migrated data does not contain version value.</p>
<p>We are having DB2 database and don&#8217;t want to change flat files also (I don&#8217;t want any kind of trigger solution).</p>
<p>Is Version UserType of any help here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-94132</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Tue, 16 Feb 2010 12:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-94132</guid>
		<description>&lt;em&gt;@Miguel:&lt;/em&gt; getting an entity manager that may or may not be using the same session from inside a session persistence operation like &lt;tt&gt;nullSafeSet&lt;/tt&gt; is indeed likely to get you into trouble.
Without a more detailed picture of how Hibernate is set up in your case it&#039;s difficult to guess what precisely might be wrong. You might have more luck using &lt;a href=&quot;http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/usertype/CompositeUserType.html&quot; rel=&quot;nofollow&quot;&gt;CompositeUserType&lt;/a&gt;, whose &lt;tt&gt;nullSafeSet&lt;/tt&gt; method takes an additional &lt;tt&gt;session&lt;/tt&gt; parameter which you can use for your queries.

Good luck!</description>
		<content:encoded><![CDATA[<p><em>@Miguel:</em> getting an entity manager that may or may not be using the same session from inside a session persistence operation like <tt>nullSafeSet</tt> is indeed likely to get you into trouble.<br />
Without a more detailed picture of how Hibernate is set up in your case it&#8217;s difficult to guess what precisely might be wrong. You might have more luck using <a href="http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/usertype/CompositeUserType.html" rel="nofollow">CompositeUserType</a>, whose <tt>nullSafeSet</tt> method takes an additional <tt>session</tt> parameter which you can use for your queries.</p>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel Cohnen</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-94071</link>
		<dc:creator>Miguel Cohnen</dc:creator>
		<pubDate>Mon, 08 Feb 2010 12:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-94071</guid>
		<description>Hi, thank you for this great post, it really helped a lot. But I&#039;m finding a strange problem. I&#039;m using Seam Framework, and inside my nullSafeSet I need to do some queries to the database. To do so, I grab my entityManager using Component.getInstance(&quot;entityManager&quot;). This works fine if What I&#039;m doing is merging an existent entity. But If I create a new one using persist, and I use the entityManager inside nullSafeSet method, I always get this error:
ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in com.amadeus.websolutions.irmap.model.Airport entry (don&#039;t flush the Session after an exception occurs)
	at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55)

I know it has to be something related to hibernate sessions, but I can not imagine what...

Can you provide some help here? 

Thank you!</description>
		<content:encoded><![CDATA[<p>Hi, thank you for this great post, it really helped a lot. But I&#8217;m finding a strange problem. I&#8217;m using Seam Framework, and inside my nullSafeSet I need to do some queries to the database. To do so, I grab my entityManager using Component.getInstance(&#8221;entityManager&#8221;). This works fine if What I&#8217;m doing is merging an existent entity. But If I create a new one using persist, and I use the entityManager inside nullSafeSet method, I always get this error:<br />
ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)<br />
org.hibernate.AssertionFailure: null id in com.amadeus.websolutions.irmap.model.Airport entry (don&#8217;t flush the Session after an exception occurs)<br />
	at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55)</p>
<p>I know it has to be something related to hibernate sessions, but I can not imagine what&#8230;</p>
<p>Can you provide some help here? </p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-93759</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Thu, 07 Jan 2010 10:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-93759</guid>
		<description>&lt;em&gt;@Attila:&lt;/em&gt; Seems the mapping file you tried to submit was filtered out. Could you paste it to &lt;a href=&quot;http://ideone.com/&quot; target=&quot;_new&quot; rel=&quot;nofollow&quot;&gt;ideone.com&lt;/a&gt; or so? I can then try to include it in your comment.</description>
		<content:encoded><![CDATA[<p><em>@Attila:</em> Seems the mapping file you tried to submit was filtered out. Could you paste it to <a href="http://ideone.com/" target="_new" rel="nofollow">ideone.com</a> or so? I can then try to include it in your comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Attila</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-93745</link>
		<dc:creator>Attila</dc:creator>
		<pubDate>Tue, 05 Jan 2010 16:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-93745</guid>
		<description>Thanks for the tutorial.

I&#039;m having problems defining the mapping required to use UserType as a composite element when trying to persist the element within a MAP. My mapping files has the following code:

Every time I try to run the code Hibernate keeps looking for the setter/getter for the component properties in the AttributeUserType which ofcourse do not exists as AttributeUserType is a class that extends UserType (your equivalent to your ReadableStringBuilderUserType).

I hope you could help with this issue.</description>
		<content:encoded><![CDATA[<p>Thanks for the tutorial.</p>
<p>I&#8217;m having problems defining the mapping required to use UserType as a composite element when trying to persist the element within a MAP. My mapping files has the following code:</p>
<p>Every time I try to run the code Hibernate keeps looking for the setter/getter for the component properties in the AttributeUserType which ofcourse do not exists as AttributeUserType is a class that extends UserType (your equivalent to your ReadableStringBuilderUserType).</p>
<p>I hope you could help with this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/comment-page-1/#comment-93036</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 10 Nov 2009 00:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=3395#comment-93036</guid>
		<description>I know Hibernate and ActiveRecord really well, and I understand their complexity.  Articles like this highlight them.  

I expect the noSQL movement to make real traction because of this complexity.</description>
		<content:encoded><![CDATA[<p>I know Hibernate and ActiveRecord really well, and I understand their complexity.  Articles like this highlight them.  </p>
<p>I expect the noSQL movement to make real traction because of this complexity.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
