-->
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.  [ 1 post ] 
Author Message
 Post subject: HibernateException: Wrong column type:x,expected:y on Sybase
PostPosted: Thu Nov 06, 2014 4:52 am 
Newbie

Joined: Thu Nov 06, 2014 3:52 am
Posts: 1
Hi everyone,

I don't have much background on the technologies below so any help would be appreciated. Please feel free to ask questions if something's not clear.

I'm currently working on a migration project wherein we're updating a number of technologies including:

  • Sybase - from 12.x to 15.7
  • JConnect - from several versions to 7.0.7_SP130

Now, our apps are deployed on to JBoss 4.x and use Hibernate 3.2.4.sp1. In the old DB, we have a number of custom datatypes that look something like this:

  • Custom datatype: TYPE1, Base datatype: image
  • Custom datatype: TYPE2, Base datatype: tinyint

Some columns in our DDL use the custom datatypes:

Code:
CREATE TABLE y (
   our_column_name TYPE1,
   ...
);

When the server is started up, I get the following error message:

Quote:
... javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: our_column_name, expected: image

which is not what happens in the old setup. Do take note that of all the custom datatypes we've defined, only those with image and tinyint have issues; the others are recognized and throw no error.

We've run a trace on the JConnect driver and it appears that it's retrieving the correct datatype, which is why I'm now focusing on the HibernateException. I've seen a couple of posts similar to this one (occurring on different DBs), but basically, they gave similar workarounds (sorry, I can't post URLs yet so I'll just list them down):

    1. One suggests that we alter the DB table's column to use the base datatype instead of the custom datatype. We've done this by changing our_column_name's datatype to image. Once this was done and the server was restarted, the error goes away. However, it does not explain why or what caused the issue.
    2. Another suggested the use of JPA annotations' @Column(columnDefinition='image'). We've tried this as well, but it doesn't seem to have any effect on the startup (i.e. error still occurred).
    3. It was suggested that the SQL Dialect be extended. However, I don't think this is feasible - only 2 custom datatypes (image and tinyint) seem to be causing the problems on our end so this may be overkill.
    4. Another suggested the removal of hibernate.hbm2ddl.auto=validate from persistence.xml. Have not tried this as we need the validation to be in place.

I've also tried checking out Hibernate's code since the exception was thrown here - org.hibernate.mapping.Table.validateColumns(Table.java:261), which pretty much points to this line:

Code:
boolean typesMatch = (col.getSqlType(dialect, mapping).startsWith(columnInfo.getTypeName().toLowerCase())) || (columnInfo.getTypeCode() == col.getSqlTypeCode(mapping));


However, Hibernate's API documentation on Tables and Columns doesn't have enough details so I'm having some difficulty tracing this at the moment...

Any ideas on what's causing the exception? If it's working in the old version, was wondering on what changes in Hibernate (or Sybase for that matter) can cause this?

There's a JBoss Document maintained by the Hibernate community that suggests that Hibernate is tested against Sybase 15.7 so I'm at a loss where to continue looking. And would #1 above be the best workaround? If so, any ideas why base types should be used instead of custom datatypes (which would, in essence, render custom datatypes useless...)

Thanks again in advance!

Update:
Tried the following:

- If @Column(columnDefinition='my_custom_datatype') is used, then the error goes away.
- If hibernate.hbm2ddl.auto=validate is removed from persistence.xml, the error goes away.

I'm really suspecting it's a hibernate issue...


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

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.