Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Reverse engineering - Problem with char columns(When creating a bean from the DB, the char columns need to be annotated with @column with the attributes columnDefinition and length )
Reverse engineering - Problem with char columns [message #1008334] Mon, 11 February 2013 23:14 Go to next message
Ramiro Serrato is currently offline Ramiro Serrato
Messages: 2
Registered: February 2013
Junior Member
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.
Re: Reverse engineering - Problem with char columns [message #1008544 is a reply to message #1008334] Tue, 12 February 2013 22:20 Go to previous messageGo to next message
Neil Hauge is currently offline Neil Hauge
Messages: 469
Registered: July 2009
Senior Member
Entity generation for a CHAR[3] column "CHAR_COLUMN" would result in the following generated code:

@Column(name = "CHAR_COLUMN")
private String charColumn;

Dali Entity Generation does not currently support further specification of the column type via columnDefinition. You may want to try disabling schema validation and see if that helps.

Neil
Re: Reverse engineering - Problem with char columns [message #1008546 is a reply to message #1008544] Tue, 12 February 2013 22:29 Go to previous message
Ramiro Serrato is currently offline Ramiro Serrato
Messages: 2
Registered: February 2013
Junior Member
Thanks for the response Neil
Previous Topic:JPA Entity Not Found
Next Topic:Missing join table in database using JPA Tools -> Generate Tables from Entities
Goto Forum:
  


Current Time: Sat Oct 25 16:15:44 GMT 2014

Powered by FUDForum. Page generated in 0.01905 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software