-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: hbm2java columnDefinition
PostPosted: Tue Jun 05, 2007 3:52 pm 
Newbie

Joined: Thu Dec 28, 2006 5:24 pm
Posts: 14
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!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 4:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Two issues here:

1) hbm2java could possibly (in most cases) include the column definition if it is different from the default mapping.

2) schema validator should be adjusted so it does not complain when not needed ( p.s. I don't understand why you are running shcemavalidator when you are using reveng ;)

I would say #1 is the easiest thing to do, but it would also be wrong since the char(1) is actually a perfect valid mapping for a char (same is varchar2(1))

#2 is what is needed to be fixed since it should check the compability of the type and not the "exactness" of the type.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: hbm2java columnDefinition
PostPosted: Fri Apr 11, 2008 7:42 am 
Newbie

Joined: Fri Apr 11, 2008 7:33 am
Posts: 3
As max noted in his reply, schema validator needed to be fixed. Until now, April 2008, this is not yet done, isn't it?

I experienced same problem. Should I report an bug in JIRA?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.