在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

解决方案 »

  1.   

    你用load方法时,要确保数据库中有这一条记录,不然,就会抛出异常
    bianhao对应是你的表的主键,而你表的主键好像是Integer的
    你把bianhao改成Integer.valueOf(bianhao)试看看
      

  2.   

    注意异常的这句话:
    org.hibernate.type.IntegerType.set(IntegerType.java:41) 
    单纯从异常说明就看出来了,把String当参数来调用org.hibernate.type.IntegerType.set(IntegerType)方法是不行的。
      

  3.   

    文档说明如下:
    Note that load() will throw an unrecoverable exception if there is no matching database row. 
    所以ClassCastException不表示数据库中没有记录