首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

hibernate多对多中间表的保存有关问题

2013-03-27 
hibernate多对多中间表的保存问题1. 表的设计a. 角色表b. 权限表c. 角色_权限表2.代码RoleAuthority roleA

hibernate多对多中间表的保存问题
1. 表的设计
   a. 角色表
   b. 权限表
   c. 角色_权限表

2.代码

  RoleAuthority roleAuthority = new RoleAuthority();  roleAuthority.getAuthority().setAuthorityId(authorityId);  roleAuthority.getRole().setRoleId(roleId);  this.saveOrUpdateEntity(roleAuthority); 

以直报空指针错,发现roleAuthority.getAuthority()为空
然后想新new的对象的子对象怎么样才能不为空,只有在初始化的时候
/** default constructor */public YbRoleAuthority() {this.ybRole = new YbRole();this.ybAuthority = new YbAuthority();}

这样才能正常保存

热点排行