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

陌路散爱 提交于 2019-12-06 09:21:31
callie16

This is similar in nature to this question on SO i.e. typesMatch in the code in my query above will be false because the values being returned by col and columnInfo are different - one is returning the base datatype, the other is returning the custom user type.

So, to deal with it, a number of workarounds are possible (and I've mentioned it in my post above) -

  1. Remove hibernate.hbm2ddl.auto=validate if you can.
  2. Change the column datatypes directly in DB, which I think is the next fastest approach.
  3. Use @Column(columnDefinition='my_custom_datatype') in the Java class.

If you use @DiscriminatorColumn remember to put there too. Like this:

@DiscriminatorColumn(name = "MyTableName", discriminatorType = DiscriminatorType.STRING, columnDefinition = "char")

and into the attribute

    @Column(name="MyColumnName",nullable = true, insertable = true, updatable = true, length = 1, columnDefinition = "char")
    private String type;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!