在hibernate document中的10.3. Loading an object
中写道:
The load() methods of Session gives you a way to retrieve a persistent instance if you already know its identifier. load() takes a class object and will load the state into a newly instantiated instance of that class, in persistent state. identifier是Long型的(虽然没找到identifier一定是Long型的说明)但是把String当Long型用就一定会抛ClassCastException
中写道:
The load() methods of Session gives you a way to retrieve a persistent instance if you already know its identifier. load() takes a class object and will load the state into a newly instantiated instance of that class, in persistent state. identifier是Long型的(虽然没找到identifier一定是Long型的说明)但是把String当Long型用就一定会抛ClassCastException
解决方案 »
- Hibernate多对多单向出问题了
- instalanywhere 整合jdk和tomcat
- struts2的异常处理,这样是否够了?
- STRUTS Validator 关于日期项目的检查。
- 求数据处理层 屏蔽分层(变化) 详解~!
- Tomcat 5.5.9安装出现的问题?~~~~~~~
- sun One Application 7 的设置问题和JNDI name问题
- jdbc调存储过程的重大疑惑?(几十个网站尚无人给出答案!!)高分!
- 请问,JMS一般用在什么地方,一般的web项目用得上吗?
- 求解springboot项目打包问题
- J2EE到底是用来干什么的?
- Hibernate插入数据出错??求助
bianhao对应是你的表的主键,而你表的主键好像是Integer的
你把bianhao改成Integer.valueOf(bianhao)试看看
org.hibernate.type.IntegerType.set(IntegerType.java:41)
单纯从异常说明就看出来了,把String当参数来调用org.hibernate.type.IntegerType.set(IntegerType)方法是不行的。
Note that load() will throw an unrecoverable exception if there is no matching database row.
所以ClassCastException不表示数据库中没有记录