Hibernate version: 3.2.3
Database: Sybase 12.5
DBC Driver: jconn3 (jConnect for JDBC 3.0 version 6.0 Build (25828))
When the hibernate query retrieves the text column or the varchar column of size greater than 255, we get the following exception.
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:369)
It happens because the jdbc driver returns the sql type of column as -1 (LONGVARCHAR), but there is no mapping define in the file org.hibernate.dialect.SybaseDialect for the sql type -1.
In our hibernate mapping files, all these columns are mapped to Hibernate.STRING
We created our own Dialect which drives from org.hibernate.dialect.Sybase11Dialect. All we have in derived class is the constructor which contains the following:
super();
registerHibernateType( Types.LONGVARCHAR, Hibernate.STRING.getName() );
registerColumnType( Types.LONGVARCHAR, "varchar($l)" );
Basically we are treating the LONGVARCHAR same as VARCHAR.
We just wanted to find out if any one else is doing it or there is a better way.
Appreciate all responses
|