<?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>demetrio.it blog &#187; java mysql seam jpa bigdecimal decimal hbm2java tips</title>
	<atom:link href="http://blog.demetrio.it/tag/java-mysql-seam-jpa-bigdecimal-decimal-hbm2java-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.demetrio.it</link>
	<description>nessun limite all'immaginazione</description>
	<lastBuildDate>Thu, 15 Jul 2010 15:42:55 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hibernate hbm2java and generated BigDecimal from MySQL decimal(10,2) type</title>
		<link>http://blog.demetrio.it/2009/02/02/hibernate-hbm2java-and-generated-bigdecimal-from-mysql-decimal102-type/</link>
		<comments>http://blog.demetrio.it/2009/02/02/hibernate-hbm2java-and-generated-bigdecimal-from-mysql-decimal102-type/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 12:19:12 +0000</pubDate>
		<dc:creator>Demetrio Filocamo</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[java mysql seam jpa bigdecimal decimal hbm2java tips]]></category>

		<guid isPermaLink="false">http://blog.demetrio.it/?p=106</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I had a little problem while working on a JBoss Seam project: I used the MySQL decimal(10,2) type for price value but, while running seam tests, the hbm2ddl schema validator gave me this error:</p>
<p style="padding-left: 30px;">Caused by: org.hibernate.HibernateException: Wrong column type: shippingCost, expected: numeric(10,0)<br />
[testng]     at org.hibernate.mapping.Table.validateColumns(Table.java:261)<br />
[testng]     at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)<br />
[testng]     at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)<br />
[testng]     at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:317)<br />
[testng]     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)<br />
[testng]     at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:918)<br />
[testng]     at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:656)<br />
[testng]     &#8230; 68 more</p>
<p>The problem is that hbm2java usa a wrong column definition for the entity property, in fact the @Column annotation on the property was:</p>
<p style="padding-left: 30px;">@Column(name = &#8220;shippingCost&#8221;, nullable = false, precision = 10)</p>
<p>The solution is simple, just change it to:</p>
<p style="padding-left: 30px;">@Column(name = &#8220;shippingCost&#8221;, nullable = false, precision = 10<strong>, scale=2, columnDefinition=&#8221;decimal(10,2)&#8221;</strong>)</p>
<p>Now the type is correctly defined and the schema validator doesn&#8217;t return any error.</p>
<p>Demetrio</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.demetrio.it/2009/02/02/hibernate-hbm2java-and-generated-bigdecimal-from-mysql-decimal102-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
