SQLite - No Dialect mapping for JDBC type: 0 (Hibernate)

前端 未结 2 972
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 03:43

I have a SQLite Datatable with string value as id and a BLOB value for a picture.

I want to know if some entry with a specific id exists in the table.

Qu         


        
相关标签:
2条回答
  • 2021-01-29 04:13

    JDBC type: 0 means Null in java.sql.Types. The resultSet must contains null value, but hibernate could not support this datatype for SQLite. So you should set this mapping in your customize at.beko.rainstar2.dialect.SQLiteDialect.

    public class SQLiteDialect extends Dialect {
        public SQLiteDialect() {
            super();
            ...
            ...
            ...
            registerColumnType(Types.NULL, "null");
            registerHibernateType(Types.NULL, "null");
        }
        ...
        ...
    }
    
    0 讨论(0)
  • 2021-01-29 04:32

    I had a similar issue, in where my SQL query was normalising multiple rows into one column, giving;

    org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
    

    So I had to wrap the XML result in a converter to convert it to varchar.

    e.g. changed from

    STUFF((select '   ' + RFID as [text()] from InnerTable inner 
           where inner.id = outer.id for XML PATH ('')), 1, 1, '') 
    as RFIDs
    

    to

    CONVERT(varchar(100), 
    STUFF((select '   ' + RFID as [text()] from InnerTable inner 
           where inner.id = outer.id for XML PATH ('')), 1, 1, '')
    ) as RFIDs
    
    0 讨论(0)
提交回复
热议问题