一方:
<id name= "collectId " type= "java.lang.Long ">
<column name= "COLLECT_ID " precision= "10 " scale= "0 " />
<generator class= "sequence ">
<param name= "sequence "> SQ_TOGE_ADDRESS_COLL_ID </param>
</generator>
</id>
<bag name= "addressGroups " cascade= "all " inverse= "true " lazy= "true ">
<key column= "COLLECT_ID "> </key>
<one-to-many class= "TogeAddressGroup "/>
</bag>
多方:
<id name= "groupId " type= "java.lang.Long ">
<column name= "GROUP_ID " precision= "10 " scale= "0 " />
<generator class= "sequence ">
<param name= "sequence "> SQ_TOGE_ADDRESS_GROUP_ID </param>
</generator>
</id>
<many-to-one name= "togeAddressColl " column= "COLLECT_ID " class= "TogeAddressColl "> </many-to-one>
其中多方主键的setter,getter方法
private Long groupId;
public Long getGroupId() {
return this.groupId;
}
public void setGroupId(Long groupId) {
this.groupId = groupId;
}
错误:
ERROR org.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: com.TogeAddressGroup, getter method of property: groupId
数据库是oracle,主键的id均为number(10,0)
向各位请教
------解决方案--------------------
你还是吧2个表的SQL, XML, 类 都贴出来吧! 可能会有人帮你解决!
一对多联级不应该用many-to-one吧,这个不是一对一唯一外键关联时用的吗?
单向一对多关联:
例如: 一个用户可能存在多个地址. 在用户类中 用Set类型定义用户地址.
主控方XML: <set name= "addresses " table= "被控方表名 " cascade= "all " order-by= "被控方某列 ">
<key column= "主控方 '一 '关系的列名,如user_id "> </key>
<one-to-many class= "被控方类名 "/> 在one-to-many关系中, 将many设置成主控方inverse= "false "可以提高性能.
不知道能不能帮到你!