java - Hibernate - 如何删除关联表中的冗余列
问题描述
我有两个实体:Intersection 和 Agent。
- 一个交集有一个id和一组代理;
- 代理具有由交集 id和代理 id组成的复合id ;
生成的表intersection_agents具有树列:intersection_id、agents_agents_id和agents_intersection_id。intersection_id和agents_intersection_id
是多余
的。消除这种冗余的正确方法是什么?
编辑1:
交叉口.java
@Entity
public class Intersecion {
@Id
private String id;
@OneToMay
private Set<Agent> agents;
...
}
代理.java
@Entity
public class Agent {
@EmbbededId
private PrimaryKey key;
@Embeddable
public static class PrimaryKey {
String intersectionId;
Long agentId;
}
}
解决方案
推荐阅读
- java - 带有类型参数的方法和泛型方法类型参数声明之间的理论区别是什么
- javascript - 如何根据网站中的反应路由删除不需要的 CSS?
- applescript - 使用 AppleScript 移动整个文件夹
- python - 如何将 2D 列表 python 转换为一个列表并连接它们
- ios - Fabric 回答 SDK 在 [Fabric with:@[ [Answers class] ]] 上崩溃;
- java - 边界半径 css 不适用于飞碟
- javascript - 期望一个赋值或函数调用,而是在 React 中看到一个表达式 no-unused-expressions 错误
- mysql - 如何检查返回多于 1 行的子查询中是否存在值?
- signal-processing - 女声基频
- c# - 为什么我在 XAML 中声明的元素无法从 C# 代码访问?