java - HibernateException: Wrong column type:x, expected: y on Sybase -
i don't have much background on technologies below help appreciated. please sense free inquire questions if something's not clear.
i'm working on migration project wherein we're updating number of technologies including:
sybase - 12.x 15.7 jconnect - several versions 7.0.7_sp130now, our apps deployed on jboss 4.x , utilize hibernate 3.2.4.sp1. in old db, have number of custom datatypes (sorry, have loved set in table format, don't know how here...) :
custom datatype: type1, base datatype: image custom datatype: type2, base datatype: tinyintsome columns in our ddl utilize custom datatypes:
create table y ( our_column_name type1, ... ); when server started up, next error message:
... javax.persistence.persistenceexception: org.hibernate.hibernateexception: wrong column type: our_column_name, expected: image
which not happens in old setup. take note of custom datatypes we've defined, image , tinyint have issues; others recognized , throw no error.
we've run trace on jconnect driver , appears it's retrieving right datatype, why i'm focusing on hibernateexception. i've seen couple of posts similar 1 (occurring on different dbs), basically, gave similar workarounds:
one site this one, it's suggested alter db table's column utilize base of operations datatype instead of custom datatype. we've done changing our_column_name's datatype image. 1 time done , server restarted, error goes away. however, not explain why or caused issue.
this suggested utilize of jpa annotations' @column(columndefinition='image'). we've tried well, doesn't seem have effect on startup (i.e. error still occurred).
in same link #2, suggested sql dialect extended. however, don't think feasible - 2 custom datatypes (image , tinyint) seem causing problems on our end may overkill.
this site suggests removal of hibernate.hbm2ddl.auto=validate persistence.xml. have not tried need validation in place.
use datatype "lob" instead
i've tried checking out hibernate's code since exception thrown here - org.hibernate.mapping.table.validatecolumns(table.java:261), pretty much points line:
boolean typesmatch = (col.getsqltype(dialect, mapping).startswith(columninfo.gettypename().tolowercase())) || (columninfo.gettypecode() == col.getsqltypecode(mapping)); however, hibernate's api documentation little wanting in details i'm having difficulty in tracing @ moment...
any ideas on what's causing exception? if it's working in old version, wondering on changes in hibernate (or sybase matter) can cause this?
this document suggests hibernate tested against sybase 15.7 i'm @ loss go on looking. , #1 above best workaround? if so, ideas why base of operations types should used instead of custom datatypes (which would, in essence, render custom datatypes useless...)
thanks 1 time again in advance!
edit:
tried following:
if@column(columndefinition='my_custom_datatype') used, error goes away. if hibernate.hbm2ddl.auto=validate removed persistence.xml, error goes away. i'm suspecting it's hibernate issue...
this similar in nature this question on so i.e. typesmatch in code in query above false because values beingness returned col , columninfo different - 1 returning base of operations datatype, other returning custom user type.
so, deal it, number of workarounds possible (and i've mentioned in post above) -
removehibernate.hbm2ddl.auto=validate if can. change column datatypes straight in db, think next fastest approach. use @column(columndefinition='my_custom_datatype') in java class. java hibernate sybase
No comments:
Post a Comment