title: JPA mapping a Java Double to a SQL Number column
body: <p>I have the following SQL definition for a table which i can't change</p>
  
  <pre><code>CREATE TABLE network_model_property (
      id                NUMBER           NOT NULL PRIMARY KEY,
      name              VARCHAR2(100)    NOT NULL,
      ....        
      max               NUMBER(10),
      min               NUMBER(10),
      ....
  )
  </code></pre>
  
  <p>The JPA'ed class definition is as following</p>
  
  <pre><code>@Entity
  @Table(name = "network_model_property")
  @SequenceGenerator(name = "PropertySeq", sequenceName = "MODEL_PROPERTY_SEQUENCE")
  public class ModelProperty implements Serializable {
  
      static final long serialVersionUID = -3276944825572313129L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PropertySeq")
      @Column(name = "id")
      private Long id;
  
      @Column(name = "max")
      private Double max;
  
      @Column(name = "min")
      private Double min;
  
  
      public Double getMax() {
          return max;
      }
  
      public void setMax(Double max) {
          this.max = max;
      }
  
      public Double getMin() {
          return min;
      }
  
      public void setMin(Double min) {
          this.min = min;
      }
  </code></pre>
  
  <p>I'm running a simple test case which throws this exception when 'hibernate.hbm2ddl.auto=validate' is set</p>
  
  <pre><code>Caused by: javax.persistence.PersistenceException: [PersistenceUnit: assure] Unable to build EntityManagerFactory
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
      ... 33 more
  Caused by: org.hibernate.HibernateException: Wrong column type in POCOWN1.NETWORK_MODEL_PROPERTY for column max. Found: number, expected: double precision
      at org.hibernate.mapping.Table.validateColumns(Table.java:284)
      at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1116)
      at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
      at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:349)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
      at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
      ... 38 more
  </code></pre>
  
  <p>And i've tried</p>
  
  <pre><code>@Column(name = "max", columnDefinition="Decimal(10,2) default '100.00'")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Column(name = "max",precision=10, scale=2)
  </code></pre>