Reverse engineering - Problem with char columns [message #1008334] |
Mon, 11 February 2013 18:14  |
Eclipse User |
|
|
|
I generated some entities from my DB, that is an AS400 db which has lot of char fields. The problem is that the generated entity does not provide the @Column annotation specifying that it is char column and a length attribute.
For example, a char column should be mapped like this:
@Column(name = "CHAR_COLUMN", columnDefinition = "CHAR", length = 3)
private String charColumn;
But when using the JPA tools from eclipse and using the Generate entities from tables... option it generates something like this:
private String charColumn;
So when trying to run the application in the server it will throw an exception in the hibernate schema validation phase, like this:
org.hibernate.HibernateException: Wrong column type in mydb.myschema.mytable for column charColumn. Found: char, expected: varchar(255)
at org.hibernate.mapping.Table.validateColumns(Table.java:283)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1343)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:378)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
Is there a way to configure the Dali plugin in order to add the proper @Column annotation?
Thanks.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04381 seconds