AaronLau314 2017-09-01 01:07 采纳率: 0%
浏览 1090
已结题

Help!求助:Hibernate整合JPA后测试增、删、改、查报错

小弟新手,刚开始学习开发,最近出现一个问题,求各位大神指教,小弟万分感谢!
在做的是一个体系分级,已经实现了针对一级表的增、删、改、查,这里是正常的。
但是在做二级表时报错。二级表与一级表的区别只是:增加了一级主键ID。

下面图片是代码:
图片说明
图片说明
图片说明
图片说明
下面是数据表:标红框的地方是上级ID标识。
图片说明
下面是报错信息:
1. 保存报错:
非法参数异常发生
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.byebook.bean.study.CyYw1KP2.kpID
非法参数异常发生
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.byebook.bean.study.CyYw1KP2.kpID
对象不是声明类的实例。
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class

  1. 查询报错:

    javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID

    Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID

  2. 删除报错:
    javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID


    Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID

    Caused by: java.lang.IllegalArgumentException: argument type mismatch

  3. 更新报错:

    javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID

    Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID

    Caused by: java.lang.IllegalArgumentException: argument type mismatch

    求各位大神指教,小弟再次万分感谢!!!
    
  • 写回答

1条回答 默认 最新

  • ooo-ooo 2017-09-01 02:46
    关注
     @Column(name="KpId", insertable=false,updatetable=false)
    

    会不会是这个问题。还有,这个表设计貌似不太合理呀,既然是树结构(分级关系)为什么还要多建一个子级表呢,直接同一张表然后给一个父级列名就好啦。

    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题