问题描述
<classname="User"table="user"><idname="userID"column="user_id"><generatorclass="native"/></id><propertyname="userName"column="user_name"type="string"not-null="true"></property><propertyname="password"column="password"type="string"not-null="true"></property><setname="groups"table="user_group"cascade="save-update"><keycolumn="user_id"></key><many-to-manycolumn="group_id"class="Group"></many-to-many></set></class>--------------------------------------------------------<classname="Group"table="t_group"><idname="groupID"column="group_id"><generatorclass="native"/></id><propertyname="groupName"column="group_name"type="string"not-null="true"></property><setname="users"table="user_group"inverse="true"cascade="save-update"><keycolumn="group_id"></key><many-to-manycolumn="user_id"class="User"></many-to-many></set><setname="privs"table="group_priv"cascade="save-update"><keycolumn="group_id"></key><many-to-manycolumn="priv_id"class="Privilege"></many-to-many></set></class>-----------------------------------------------------------页面:<s:selectname="user.groups"list="#request.groups_prepare"listValue="groupName"listKey="groupID"label="组"/>-----------------------------------------------------------action:Useru=newUser()u.setGroups(user.getGroups)this.getUserService.save(u)无法保存中间表,说什么groupID不能访问,我猜测group_id没有值!怎么解决insertintouser_group(user_id,group_id)values(?,?)----------------------------------------------------------我的DAO实现this.getHibernateTemplate.save(user);
解决方案
解决方案二:
org.springframework.orm.hibernate3.HibernateSystemException:IllegalArgumentExceptionoccurredcallinggetterofcom.gzfang.pojo.Group.groupID;
解决方案三:
跟struts2的类型转换有关吗? set集合
解决方案四:
该回复于2010-12-10 10:28:37被版主删除
解决方案五:
这种多对多设置很麻烦我从来都是之在数据库表建立外键字段自己程序控制