• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

HibernateException: Wrong column type: x, expected: y on Sybase

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 (sorry, would have loved to put this in table format, but I don't know how to here...) :

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

  • Some columns in our DDL use the custom datatypes:

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

    ... 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:

  • 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 - org.hibernate.mapping.Table.validateColumns(Table.java:261), which pretty much points to this line:

    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...)

    Thanks again in advance!
    "Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
    Thread Boost feature
      Bookmark Topic Watch Topic
    • New Topic