hibernate中的异常问题

zhanglongnihao 2009-07-23 06:14:44
IllegalArgumentException in class: com.pro.entity.DeviceInformation, getter method of property: id
org.hibernate.PropertyAccessException:
IllegalArgumentException occurred calling getter of com.pro.entity.DeviceInformation.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:67)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:147)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:457)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:113)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:87)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at com.pro.utils.HibernateSessionFactory.openSession(HibernateSessionFactory.java:24)
at com.pro.utils.Test.main(Test.java:11)

在数据库中DeviceInformation设置的主键ID为varchar型。有另外一个类其采用复合主键的方式,与DeviceInformation存在 多对一的关系
<composite-id name="id" class="PortConfigurationPK">
<key-many-to-one
name="device"
class="com.pro.entity.DeviceInformation"
column="Device_Id"
/>
<key-property
name="portNumber"
column="Port_Number"
type="string"
/>
</composite-id>
请高手解决一下,要怎么处理这个异常
...全文
84 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanglongnihao 2009-08-01
  • 打赏
  • 举报
回复
已解决谢啦
  • 打赏
  • 举报
回复
采用插件吧
sunjianqiang1986 2009-07-23
  • 打赏
  • 举报
回复
同意楼上
APOLLO_TS 2009-07-23
  • 打赏
  • 举报
回复
还有多对一的符合主键?那还叫主键么?开玩笑吧!!
<composite-id name="id" class="com.po.TAclId">
<key-property name="priType" type="java.lang.Integer">
<column name="PRI_TYPE" />
</key-property>
<key-property name="accId" type="java.lang.Integer">
<column name="ACC_ID" />
</key-property>
<key-property name="roleId" type="java.lang.Integer">
<column name="ROLE_ID" />
</key-property>
<key-property name="modId" type="java.lang.Integer">
<column name="MOD_ID" />
</key-property>
</composite-id>
zhanglongnihao 2009-07-23
  • 打赏
  • 举报
回复
有没有人能回答呀?我都弄了一天了,怎么也找不出来数据库字段与Java字段对应有问题。但是如果采用插件生成的又没有问题,奇怪得很

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧