Oracle 数据库:
Hibernate annotation :
@Column(name="NUMBERS",columnDefinition="NUMBER(20,3) default 0 ")
public BigDecimal getNumbers() {
return numbers;
}
异常:
Caused by: org.hibernate.HibernateException: Wrong column type: NUMBERS, expected: NUMBER(20,3) default 0
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
... 122 more
解决方法:
@Column(name="NUMBERS",columnDefinition="number(20,3) default 0 ")
public BigDecimal getNumbers() {
return numbers;
}
原因:hibernate 在列定义选项中,数据库中的所有类型应为小写number. hibernate在此直接面对数据库,所以区分大小写.
posted on 2011-12-05 09:21
紫蝶∏飛揚↗ 阅读(10258)
评论(1) 编辑 收藏 所属分类:
Hibernate 、
数据库