<?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>Rob@Rojotek &#187; Hibernate</title>
	<atom:link href="http://www.rojotek.com/blog/blog/hibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rojotek.com/blog</link>
	<description>Software Development in Brisbane</description>
	<lastBuildDate>Wed, 25 Jan 2012 10:34:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Fixing Intermittent Table Not Found Errors with JUnit when Using Hibernate SchemaExport and H2</title>
		<link>http://www.rojotek.com/blog/2008/05/25/fixing-intermittent-table-not-found-errors-with-junit-when-using-hibernate-schemaexport-and-h2/</link>
		<comments>http://www.rojotek.com/blog/2008/05/25/fixing-intermittent-table-not-found-errors-with-junit-when-using-hibernate-schemaexport-and-h2/#comments</comments>
		<pubDate>Sun, 25 May 2008 22:00:58 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/2008/05/25/fixing-intermittent-table-not-found-errors-with-junit-when-using-hibernate-schemaexport-and-h2/</guid>
		<description><![CDATA[As a part of my test suite, I run a series of tests using Hibernate and the h2 database (h2 seems to be the most lightweight java in memory database around at the moment). These tests run in memory and perform realively quickly, so are a part of my pre-commit build. In order to move [...]]]></description>
			<content:encoded><![CDATA[<p>       As a part of my test suite, I run a series of tests using Hibernate and the <a href="http://www.h2database.com/">h2 database</a> (h2 seems to be the most lightweight java in memory database around at the moment). These tests run in memory and perform realively quickly, so are a part of my pre-commit build.    </p>
<p>       In order to move to a spot where the application upgrades work well, I’ve just removed the hbm2ddl.auto create-drop statements from my hibernate.xml file, and wanted to move to a programmatic use of the SchemaExport tool. This was more pain than expected, so I’m documenting what I had to do here.    </p>
<p>       From the javadoc, and Java Persistence with Hibernate, it looks like you can get away with the following code:    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">1: Configuration configuration = new Configuration().configure();&lt;br /&gt; &nbsp; &nbsp; &nbsp; 2: SchemaExport schemaExport = new SchemaExport(configuration);&lt;br /&gt; &nbsp; &nbsp; &nbsp; 3: schemaExport.create(false, true);&lt;br /&gt;</div></td></tr></tbody></table></div>
</p>
<p>       Unfortunately I found that this didn’t quite work. It seems that the connection/transactionality/connection pool combination of concerns would cause this kind of code to fail at various degrees. After much gnashing of teeth I ended up with the following code:    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">1: Configuration configuration = new Configuration().configure();&lt;br /&gt; &nbsp; &nbsp; &nbsp; 2: SessionFactory sessionFactory =</div></td></tr></tbody></table></div>
<p>       &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">configuration.buildSessionFactory();&lt;br /&gt; &nbsp; &nbsp; &nbsp; 3: Session session = sessionFactory.openSession();&lt;br /&gt; &nbsp; &nbsp; &nbsp; 4: Connection connection = session.connection();&lt;br /&gt; &nbsp; &nbsp; &nbsp; 5: SchemaExport schemaExport =</div></td></tr></tbody></table></div>
<p>       &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">new SchemaExport(configuration, connection);&lt;br /&gt; &nbsp; &nbsp; &nbsp; 6: schemaExport.execute(false, true, false, true);&lt;br /&gt; &nbsp; &nbsp; &nbsp; 7: session.close();</div></td></tr></tbody></table></div>
</p>
<p>       the critical differences are:    </p>
<p>       In lines 2-4 we are obtaining a connection to the database which is then used by the schema export tool. In line 6 we do the export using the execute command, passing in a bunch of booleans. This tell it execute command:    </p>
<ul>
<li>        don’t output the sql to the console,      </li>
<li>        do execute on the database,      </li>
<li>        don’t execute drop statements, and      </li>
<li>        do execute create statements.      </li>
</ul>
<p>       Finally in line 7, we close the session, ensuring jdbc connection is released and cleaned up. Now any intermittent problems caused by using schema export with h2 database should be avoided.    </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2008/05/25/fixing-intermittent-table-not-found-errors-with-junit-when-using-hibernate-schemaexport-and-h2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Howto Keep Version History in a Single Table Using Hibernate</title>
		<link>http://www.rojotek.com/blog/2007/12/07/howto-keep-version-history-in-a-single-table-using-hibernate/</link>
		<comments>http://www.rojotek.com/blog/2007/12/07/howto-keep-version-history-in-a-single-table-using-hibernate/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 20:43:00 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/2007/12/07/howto-keep-version-history-in-a-single-table-using-hibernate/</guid>
		<description><![CDATA[&#160; Problem: Keeping a history of data in a single table in hibernate, where all versions are treated as first class objects. That is to say that every record in the database will be immutable. New records will be created with a new version number, but the old versions will never change. They are kept [...]]]></description>
			<content:encoded><![CDATA[<p>
       &#160;
    </p>
<p>
       <strong>Problem:</strong>
    </p>
<p>
       Keeping a history of data in a single table in hibernate, where all versions are treated as first class objects.
    </p>
<p>
       That is to say that every record in the database will be immutable. New records will be created with a new version number, but the old versions will never change. They are kept as the history of changes.
    </p>
<p>
       <strong>Solution:</strong>
    </p>
<p>
       When querying objects from hibernate ensure that they are initialised, and then detach them from the session:
    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Hibernate.initialize(result);</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">session.evict(result);</div></td></tr></tbody></table></div>
</p>
<p>
       Then when saving the objects, ensure that the ID is null, and call the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">session.save(businessObject)</div></td></tr></tbody></table></div>
<p>to save them.
    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">//set the id to null to ensure that a new record is stored in the database.</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">businessObject.setId(null);</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">incrementVersion(businessObject);</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">session.save(businessObject);</div></td></tr></tbody></table></div>
</p>
<p>
       The final part of the puzzle is to ensure that the class has it’s persistence properties set correctly, either by setting the annotations or configuring the xml file.
    </p>
<p>
       The important settings are:
    </p>
<ol>
<li>
        To help prevent updates, and improve performance set the mutable attribute on the class to false.
      </li>
<li>
        The collection objects on the class have the lazy attribute set to false (ensuring that they are loaded when the object is retrieved, and the evicted object will work).
      </li>
</ol>
<p>
       Following these steps will provide you with a versioned business object. It will be possible to retrive, and store the object to the database using the Hibernate search functionality.
    </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2007/12/07/howto-keep-version-history-in-a-single-table-using-hibernate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Storing Large Strings with Hibernate 3</title>
		<link>http://www.rojotek.com/blog/2007/11/15/storing-large-strings-with-hibernate-3/</link>
		<comments>http://www.rojotek.com/blog/2007/11/15/storing-large-strings-with-hibernate-3/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 22:32:17 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.rojotek.com/blog/2007/11/15/storing-large-strings-with-hibernate-3/</guid>
		<description><![CDATA[If you want to store a large string in hibernate 3 in a relatively transparent way, the 1text &#160;mapping type is your friend. &#160;This will allow you to map a java String type to a database clob type, and store arbitary length large content items. &#160;In previous versions (according to google) this took a fair [...]]]></description>
			<content:encoded><![CDATA[<p>
       If you want to store a large string in hibernate 3 in a relatively transparent way, the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">text</div></td></tr></tbody></table></div>
<p>&#160;mapping type is your friend. &#160;This will allow you to map a java String type to a database clob type, and store arbitary length large content items. &#160;In previous versions (according to google) this took a fair bit of fiddling around, and required custom types (which required much magic to work in a cross platform manner). &#160;Thankfully the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">text</div></td></tr></tbody></table></div>
<p>mapping type exists, making life much easier.
    </p>
<p>
       &#160;
    </p>
<p>
       So in the old school pre 1.5 annotation world, we can take the class with a long string and map it using the code and mapping below:
    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class Profile {</div></td></tr></tbody></table></div>
<p>
       &#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...&amp;#160;&amp;#160;</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;#160;&amp;#160;private String bio;</div></td></tr></tbody></table></div>
<p>
       &#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...&amp;#160;&amp;#160;</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;#160;&amp;#160;public String getBio(){&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;return bio;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;}</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;#160;&amp;#160;public void setBio(String bio){&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;this.bio=bio;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;}</div></td></tr></tbody></table></div>
<p></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">}</div></td></tr></tbody></table></div>
</p>
<p>
       and the mapping file:
    </p>
<p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;#60;?xml version=&amp;quot;1.0&amp;quot;?&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#60;!DOCTYPE hibernate-mapping PUBLIC</div></td></tr></tbody></table></div>
<p>
       &#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&amp;quot;</div></td></tr></tbody></table></div>
<p>
       &#160;&#160;&#160;&#160;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&amp;quot;&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#60;hibernate-mapping&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;class name=&amp;quot;Profile&amp;quot; table=&amp;quot;profiles&amp;quot;&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;...&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;property name=&amp;quot;bio&amp;quot; type=&amp;quot;text&amp;quot; length=&amp;quot;</div></td></tr></tbody></table></div>
<p>10485760</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;quot;/&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;/class&amp;#62;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&amp;#60;/hibernate-mapping&amp;#62;</div></td></tr></tbody></table></div>
</p>
<p>
       This will let you store a large string in hibernate, automatically handling the mapping between clob data and string data. &#160;The important parts of the xml snippet above are the type and length attributes. &#160;Both are required to ensure that the clob will be created of the right length. &#160;The default for the length is 255, which is great when you are storing shortish strings in a varchar, but not so good when you want a large string in a clob.
    </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rojotek.com/blog/2007/11/15/storing-large-strings-with-hibernate-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

