I am using the Oracle9Dialect, 3.2.0.beta9a of Hibernate Tools, and am using JPA/EJB3 and Seam.
When reverse engineering Entity beans from the database, I have an annoying problem that I wonder if it could be fixed in Hibernate...
I have a few cases where the primary (or foreign) key of a table is a CHAR(x) field (typical for Country, Currency, etc.). When the Java code is generated, the columnDefinition is not overridden to be "char(x)", so upon deployment it breaks because Hibernate complains that the column is not what was expected (varchar2(x)):
Code:
ObjectName: persistence.units:ear=foo.ear,unitName=foo
State: FAILED
Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: code, expected: varchar2(2 char)
I Depend On:
jboss.jca:service=DataSourceBinding,name=fooDatasource
I was wondering if the hbm2java code could be enhanced such that it would check if the
columnDefinition matched the default
columnDefinition for the field, and if not it would explicitly define it.
Right now, I need to edit the generated java by hand (which is particularly painful when you want to run seam generate-entities over and over again because it keeps overwriting my edits). I have only seen this problem for CHAR fields. Also note that I had this problem using SQL Server too, so it isn't related to Oracle.
Thanks!