title: How do I map a BigDecimal in Hibernate so I get back the same scale I put in?
body: <p>In Java, <code>new BigDecimal("1.0") != new BigDecimal("1.00")</code> i.e., <a href="https://blogs.oracle.com/darcy/entry/notions_of_floating_point_equality" rel="nofollow">scale matters</a>.</p>
  
  <p>This is apparently not true for Hibernate/SQL Server, however. If I set the scale on a BigDecimal to a particular value, save the BigDecimal to the database via Hibernate and then re-inflate my object, I get back a BigDecimal with a different scale.</p>
  
  <p>For instance, a value of 1.00 is coming back as 1.000000, I assume because we're mapping BigDecimals to a column defined as <code>NUMERIC(19,6)</code>. I can't just define the column as the required scale as I need to store both Dollar and Yen values (for example) in the same column. We need to represent the BigDecimals as numeric types in the database for the benefit of external reporting tools. </p>
  
  <p>Does there exist a Hibernate UserType which maps BigDecimal "properly", or do I have to write my own?</p>