spring mvc @manytomany的做法
来源:互联网 发布:java base64 编码jar 编辑:程序博客网 时间:2024/04/28 08:15
@manytomany的做法需要一些标准步骤,才能省工
下面主要目的是在多对多的情况下,一边建立表的关联关系,另一边建立数据的关联关系
以一条策略关联一大片规则为例子
1 建立关联表
Strategy一张表
Specification一张表
strategy-specification关联的一张表。表中列为stid, spid(分别是策略,规则id)
2 在策略类的处理
2.1 增加策略类的属性,包含规则列表(List<Sp> spList)
2.2 增加对规则列表的getter和setter
2.3 为getter增加修饰语句
@ManyToMany
@JoinTable(name="关联表名称“,joinColumn= { @JoinColumn(name= "stid策略id”}, inverseJoinColumn={ @JoinColumn(name= "spid规则id”} } )
3 在规则类的处理
3.1 增加规则类的属性,即策略列表(List<St>)
3.2 增加对策略列表的getter和setter
3.3 为getter增加修饰语句
@ManyToMany(mappedBy = "策略类里面规则列表的名字(spList)“)
这里mappedBy就是被谁谁映射,即两者发生关联的属性。
参考
1 http://docs.oracle.com/javaee/5/api/javax/persistence/ManyToMany.html
public abstract String mappedBy
- The field that owns the relationship. Required unless the relationship is unidirectional.
- Default:
- ""
0 0
- spring mvc @manytomany的做法
- 有关MVC的常见做法
- spring mvc 返回页面json数据一种做法
- ManyToMany
- @ManyToMany
- manytomany
- 避免Spring产生两个Context的做法
- 【原创】Hibernate的manytomany例子..
- manyTomany中遇到的问题
- django ManyToMany 使用的注意事项
- SpringBoot10-Spring MVC-Spring MVC的测试
- spring mvc的Controller
- spring的MVC配署
- Spring 的MVC框架
- Spring 的MVC @RequestMapping
- Spring MVC的配置
- Spring mvc的配置
- Spring MVC的主题
- vim 设置支持鼠标
- bzoj-3130 费用流
- 两个数组的交集,并集,差集。
- plateform driver and device
- MD5 为何会算不对?
- spring mvc @manytomany的做法
- windows 下nginx安装使用
- 有哪些好用的互联网数据抓取,数据采集,页面解析工具?
- 图片截取居中显示
- 如何删除word文档中的“小箭头↓”(手动换行符)
- iOS UTC秒数时间戳和日期的相互转换
- vector中erase用法注意事项
- SSL应用
- java.lang.IllegalArgumentException: Width (0) and height (560) cannot be <= 0