Unanswered: HibernateException: Wrong column type:x, expected: y on Sybase
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 (not sure if I can insert a table yet so I'll do it this way first) :
Custom datatype: TYPE1, Base datatype: image Custom datatype: TYPE2, Base datatype: tinyint
Some columns in our DDL use the custom datatypes:
CREATE TABLE y (
When the server is started up, I get the following error message:
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:
One site like this one, it's suggested 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.
This 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).
In the same link as #2, 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.
This site suggests the removal of hibernate.hbm2ddl.auto=validate from persistence.xml. Have not tried this as we need the validation to be in place.
Use the datatype "LOB" instead
I've also tried checking out Hibernate's code since the exception was thrown here -
However, Hibernate's API documentation is a little wanting in details so I'm having some difficulty in 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?
This document 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...)