title: Hibernate - BigDecimal column mapping for Custom Dialect
body: <p>I'm using Hibernate as our Object-Relational Mapping, with a custom dialect for an obscure database.</p>
  
  <p>The Entity I'm retrieving from this database has a column thus:</p>
  
  <pre><code>    @Column(name = "GROSS_WEIGHT", precision = 9, scale = 3)
      private BigDecimal grossWeight;
  </code></pre>
  
  <p>The database has this column defined as numeric with a precision of 9 and a scale of 3.</p>
  
  <p>I can see the SQL that Hibernate generates to retrieve the data, and when I perform the same Query using the database query tool it returns '9.68' for the GROSS_WEIGHT column.</p>
  
  <p>However, in the Entity that is retrieved by Hibernate, the 'grossWeight' field contains the value '10', with a <code>scale</code> of 0 and <code>precision</code> of 2!</p>
  
  <p>in the custom dialect class I'm using I've tried overriding the following Column Types:</p>
  
  <pre><code>        registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
          registerColumnType( Types.DOUBLE, "numeric($p,$s)" );
          registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
  </code></pre>
  
  <p>but it stills returns just the (rounded) whole number.</p>
  
  <p>This has worked elsewhere in the application where we retrieve objects from Postgres using the Postgres dialect.</p>
  
  <p>Any idea what I should be doing in the dialect so I can get Hibernate to correctly set the precision/scale of the BigDecimal retrieved?</p>