<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Decimal problem"]]></title>
		<link>http://forums.visual-paradigm.com/posts/32.html</link>
		<description><![CDATA[Latest messages posted in the topic "Decimal problem"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Decimal problem</title>
				<description><![CDATA[ Hi VP,<br> <br> I think this will be one of my last bug reports, because you are fixing all of them very quickly!! :) and my evaluation it is almost finished (your software and specially your support have a high punctuation, don't worry).<br> <br> But, today I had a problem with a "decimal" field.<br> <br> I think I have done it right (never used them before). Follow this short steps:<br> - Create new package "pack1"<br> - Create new class "class1"<br> - Add an attribute "att1: decimal"<br> <br> Then, as always, sync to erd and generate code (use XML mapping).<br> <br> Then, examine the class1.hbm.xml file:<br> ...<br> <property name="Att1" column="Att1" type=<b>"decimal, Base"</b> not-null="false"/><br> ...<br> ("Base" is my project's assembly)<br> <br> So, DBVA did not recognize the "decimal" type as NHibernate internal "Decimal" (<a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-types-basictypes" target="_new" rel="nofollow"> NHibernate Basic Types 5.2.2 </a>) and instead it thinks it is a user-defined type.<br> <br> Further on, look at the C# generated code:<br> ...class1.cs...<br> private <b>decimal?</b> __att1;<br> <br> So it declares it as a decimal (System.decimal) plus nullable! (using the ? sign NET 2.0 notation).<br> <br> And the DDL file:<br> create table class1 (ID int identity not null, <b>Att1 int null</b>, primary key (ID))<br> <br> Anyway, I think the main problem it is only with the class1.hbm.xml file.<br> <br> Am I doing something wrong? this is my "first time" with decimal type in DBVA, so I do not test it properly.<br> <br> Thanks for your info<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20000.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20000.html</link>
				<pubDate><![CDATA[Tue, 6 Nov 2007 07:10:45]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hello distansia,<br> <br> Thank you for your post once again. I will check this with our developers and let you know their feedback.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20006.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20006.html</link>
				<pubDate><![CDATA[Tue, 6 Nov 2007 08:47:58]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> The problem has been fixed. Please download and install the patch at:<br> <a href="http://files3.visual-paradigm.com/200711/Patch/sp1_20071116h/VP_Suite_Windows_3_1_sp1_20071116h.exe" target="_blank" rel="nofollow">http://files3.visual-paradigm.com/200711/Patch/sp1_20071116h/VP_Suite_Windows_3_1_sp1_20071116h.exe</a><br> <br> Enjoy!<br> <br> Best regards,<br> Jick<br> <br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20016.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20016.html</link>
				<pubDate><![CDATA[Tue, 6 Nov 2007 18:59:48]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ <table class="quote-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Jick wrote:</b></span></td>
		</tr>
		</table>
		
		<table class="quote-table" align="center">
		<tr>
		<td class="quote">The problem has been fixed. Please download and install the patch at:<br> <a href="http://files3.visual-paradigm.com/200711/Patch/sp1_20071116h/VP_Suite_Windows_3_1_sp1_20071116h.exe" target="_blank" rel="nofollow">http://files3.visual-paradigm.com/200711/Patch/sp1_20071116h/VP_Suite_Windows_3_1_sp1_20071116h.exe</a><br> <br> Enjoy!&nbsp;
		</td>
		</tr>
		</table><br> Sure I will  :P <br> <br> Many thanks again!!!]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20019.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20019.html</link>
				<pubDate><![CDATA[Wed, 7 Nov 2007 00:20:02]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Not completely fixed for NET code</title>
				<description><![CDATA[ Hi Jick,<br> <br> I am sorry but this one is not completely fixed, in case code is targeting the NET framework (C#, NHibernate).<br> <br> Yes, now the mapping file shows:<br> <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>
 &lt;property ... type="Decimal" precision="19" scale="0" ... &gt;
 </pre></td>
		</tr>
		</table><br> But in NHibernate, the <b>precision</b> and <b>scale</b> attributes are not in the XSD Schema, so they are not allowed.<br> <br> As stated in NHibernate Documentation (section 16.1.1):<br> <table class="quote-table" align="center">
		<tr>
		<td class="quote">Many NHibernate mapping elements define an optional attribute named length. You may set the length of a column with this attribute. (Or, for numeric/decimal data types, the precision.) &nbsp;
		</td>
		</tr>
		</table> <br> <br> So we can write:<br> <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>
 &lt;property ... type="Decimal" length="19" ... &gt;
 </pre></td>
		</tr>
		</table><br> <br> It works, but what about the scale?? We lost it!<br> <br> Not at all, Sergey Koshcheyev (NHibernate main coder) says:<br> <table class="quote-table" align="center">
		<tr>
		<td class="quote">You can use type="Decimal(precision, scale)" in the mapping files&nbsp;
		</td>
		</tr>
		</table><br> <br> Yes!! So, I tried with:<br> <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>
 &lt;property ... type="Decimal&#40;19,0&#41;" ... &gt;
 </pre></td>
		</tr>
		</table><br> And all ok!!  :D<br> <br> This is one of the little but annoying differences between Hibernate and NHibernate mapping files.<br> <br> Anyway, good job fixing this. Works in ORM Persistable and ORM components too.]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20022.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20022.html</link>
				<pubDate><![CDATA[Wed, 7 Nov 2007 01:33:29]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> Thanks for the tips. I will check with our team to see if we can change @type by following your suggestions.<br> <br> Best regards,<br> Jick]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20027.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20027.html</link>
				<pubDate><![CDATA[Wed, 7 Nov 2007 10:10:44]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> May I know more about your need of using precision? Normally NHibernate doesn't care about the precision of a field. In other words, length and precision in XML does not affect the result.  :?  :? <br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20034.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20034.html</link>
				<pubDate><![CDATA[Wed, 7 Nov 2007 18:20:00]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ <table class="quote-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Jick wrote:</b></span></td>
		</tr>
		</table>
		
		<table class="quote-table" align="center">
		<tr>
		<td class="quote">May I know more about your need of using precision? Normally NHibernate doesn't care about the precision of a field. In other words, length and precision in XML does not affect the result.  :?  :? &nbsp;
		</td>
		</tr>
		</table><br> <br> Well, I am using a "decimal" type to store a "9999.9" number. So I use a Decimal(5,1) --> translated to SQL Server numeric(5,1).<br> <br> The problem is that generated hbm.xml in NET does not correctly initialize NHibernate, because the "precision" and "scale" attributes are not defined in the mapping file NHibernate uses.<br> <br> Yes, they are defined in Hibernate, so it must work with it. But not on .NET (C#, NHibernate).<br> <br> The solution it is to change that behavior when generating for .NET and translate this attributes into the Decimal(x,y) notation.<br> <br> I do not know if NHibernate will skip this altogether when dealing with data, but sure it do not initialize correctly  :D <br> <br> And I can not use a "double" type to store that numeric value, because these are the requirements (Decimal with 9999.9 format).<br> <br> I do not know if I explain myself  :roll: Just ask me if in doubt]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20037.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20037.html</link>
				<pubDate><![CDATA[Wed, 7 Nov 2007 19:03:44]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Thanks distansia,<br> <br> I will tell our engineers about this.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20054.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20054.html</link>
				<pubDate><![CDATA[Thu, 8 Nov 2007 12:04:42]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> I have talked to our engineers. We would like to know what did you mean by <br> "does not correctly initialize NHibernate"? What operation will fail if not to change decimal to decimal(19,0) in xml?<br> <br> Best regards,<br> Jick]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20061.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20061.html</link>
				<pubDate><![CDATA[Thu, 8 Nov 2007 16:59:23]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ <table class="quote-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Jick wrote:</b></span></td>
		</tr>
		</table>
		
		<table class="quote-table" align="center">
		<tr>
		<td class="quote">I have talked to our engineers. We would like to know what did you mean by <br> "does not correctly initialize NHibernate"? What operation will fail if not to change decimal to decimal(19,0) in xml?<br> &nbsp;
		</td>
		</tr>
		</table><br> <br> Hi Jick,<br> <br> I am not with Visual Studio right now, but I will send you the error message when I will be.<br> <br> In the meanwhile, I remember something about "precission attribute not permitted" and "scale attribute not permitted". I think there is no problem if type="Decimal" and nothing else put. But I will report you.<br> <br> Anyway, this can be easily tested with this line of code:<br> <projectName>PersistentManager.Instance().GetSession().Close();<br> <br> It throws a persistent exception.<br> <br> (take care with the case, I can not test it with VS now)<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20063.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20063.html</link>
				<pubDate><![CDATA[Thu, 8 Nov 2007 17:53:24]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> Hmmm  :?  :?  Decimal should be no problem. Please let me know your finding. Thank you.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20067.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20067.html</link>
				<pubDate><![CDATA[Thu, 8 Nov 2007 19:09:56]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi Jick,<br> <br> Well my findings are:<br> <br> - If a Decimal field is inside a ORM Persistable class (and it is not a generalization), the hbm.xml generated is:<br>  <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>&lt;property name="Number" column="Number" type="Decimal" not-null="false"/&gt; </pre></td>
		</tr>
		</table> <br> <br> - If a Decimal field is inside a ORM Component class, the hbm.xml generated is:<br> <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>&lt;component name="comp1" class="pack1.comp1, Base" update="true" insert="true"&gt;
      &lt;property name="Number" column="Number" type="Decimal" precision="19" scale="0" not-null="false" &gt;
 &lt;/component&gt;
  </pre></td>
		</tr>
		</table><br> <br> - I forgot to test the case with a class being a generalization of another one (inheritance). You can test it if in doubt. I remember "joined-subclass" element had errors when generating code in previous builds.<br> <br> <br> The code needed to get the Component crazy  :shock: sorry, I mean, to get the NHibernate error when initializing is:<br> BasePersistentManager.Instance().GetSession().Close();<br> ('Base' is the name of my project and assembly)<br> <br> and the log4net log reports this error:<br> <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre> 
 &#91;544&#93; ERROR NHibernate.Cfg.Configuration &#91;&#40;null&#41;&#93; - pack1.class1.hbm.xml&#40;12,90&#41;: XML validation error: The 'precision' attribute is not declared.
 </pre></td>
		</tr>
		</table> <br> <br> BTW, I think it would be nice to be able to specify the decimal attributes in each case, not in general properties of the program. I mean, I have some decimal fields which are (5,1), other are (10,4), etc. Can I do this in the current build? To be honest I have not investigate this enough, and only found that general setting. So I manually change all definitions in DDL file before generating database.<br> <br> <br> Best regards]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20077.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20077.html</link>
				<pubDate><![CDATA[Fri, 9 Nov 2007 08:26:12]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> We'll fix the problems and reply you shortly.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20083.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20083.html</link>
				<pubDate><![CDATA[Fri, 9 Nov 2007 09:22:18]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi Jick,<br> <br> Sorry  :oops: , I forgot to add that in this case:<br> <br> <table class="quote-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>distansia wrote:</b></span></td>
		</tr>
		</table>
		
		<table class="quote-table" align="center">
		<tr>
		<td class="quote">- If a Decimal field is inside a ORM Persistable class (and it is not a generalization), the hbm.xml generated is:<br>  <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre>&lt;property name="Number" column="Number" type="Decimal" not-null="false"/&gt; </pre></td>
		</tr>
		</table> <br> &nbsp;
		</td>
		</tr>
		</table><br> <br> The generated code WORKS WELL. I mean, no persistent exception when initializing NHibernate. The problem is only when a decimal field is defined inside an ORM Component. Excuse me  :wink: ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20093.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20093.html</link>
				<pubDate><![CDATA[Fri, 9 Nov 2007 15:09:55]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
			<item>
				<title>Re:Decimal problem</title>
				<description><![CDATA[ Hi distansia,<br> <br> As I know the problem occurs only in ORM Component and has been fixed. Please download the patch at:<br> <a href="http://files3.visual-paradigm.com/200711/Patch/sp1_20071119/VP_Suite_Windows_3_1_sp1_20071119.exe" target="_blank" rel="nofollow">http://files3.visual-paradigm.com/200711/Patch/sp1_20071119/VP_Suite_Windows_3_1_sp1_20071119.exe</a><br> <br> Hope this helps!<br> <br> Best regards,<br> Jick]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2620#20133.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2620#20133.html</link>
				<pubDate><![CDATA[Mon, 12 Nov 2007 17:17:40]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
	</channel>
</rss>