无法转换为内部表示解决办法

来源:互联网 发布:php api接口开发文档 编辑:程序博客网 时间:2024/06/04 18:26

1.报错:

SQL Error: 17059, SQLState: null

[gamebang] ERROR [resin-tcp-connection-*:8080-2] JDBCExceptionReporter.logExceptions(72) |无法转换为内部表示

上网查询结果: 这个错误原因是:数据库里的字段类型与Java里映射该字段属性的类型不能对应转换,例如数据库里字段类型为Varchar2,而Java定义的类型为Long;或者数据库里为Number,而Java定义的对应属性类型为String。

根据提示检查了一遍那个类文件,没发现问题,最后查明是引用的一个外键类型不一致,引用位置类型定义为

String,但是原位置却是Integer,所以报错。例如:

Class A{

String id;

String bId;//外键,关联到B的主键,此处类型不一致,导致错误

}

Class B{

Integer id;

}

2.spring+hibernate怎么显示编译完的hql语句:

在applicationContext-hibernate.xml里配

<property name="hibernateProperties">
            <props>
                <prop key="hibernate.show_sql">true</prop>

            </props>

</property>

原创粉丝点击