title: How to map BigInteger in Hibernate to DB2
body: <p>I've got a class that is generated through JAXB that I am trying to use as an entity in Hibernate. There are numeric fields that are defined as Java BigIntegers. No matter what I define the column as in DB2, Hibernate complains with some variation of:</p>
  
  <p>Wrong column type .... for column MY_COLUMN Found: decimal, expected: numeric(19,2).</p>
  
  <p>I've tried DB2 bigints, I've tried numeric (19,2), etc.</p>
  
  <p>I am letting Hibernate choose the dialect. It is choosing the DB2 dialect. How can I define the column in DB2 so that Hibernate will allow me to use it to store a Java BigInteger?</p>
  
  <p>If I define it as a big_integer in Hibernate, and as a bigint in DB2, I get:</p>
  
  <p>Wrong column type .... for column MY_COLUMN Found: bigint, expected: numeric(19,2)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So I changed hibernate.hbm2ddl.auto from validate to create and let Hibernate create the schema itself. From the log I could see that is was generating the create table statement using a definition of numeric(19,2). In DB2, once the table was created, the definition was decimal(19,2). The app started up OK.</p>
  
  <p>Then I shut down the app, recompiled setting hibernate.hbm2ddl.auto back to validate, and restarted.</p>
  
  <p>Hibernate errored out with:
  Found: decimal, expected: numeric(19,2)</p>
  
  <p>So Hibernate can't validate a schema it just created itself?</p>