Hibernate-如何删除关联表中的冗余列

时间:2018-11-14 21:07:10

标签: java mysql hibernate

我有两个实体:Intersection和Agent。

  • 一个路口有一个 id 和一个一组代理人
  • 代理人的组合ID 交叉点ID 代理人ID 组成;

生成的表 intersection_agents 具有树列: intersection_id agents_agents_id agents_intersection_id
< br /> intersection_id agents_intersection_id 是多余的。删除此冗余的正确方法是什么?

编辑1:

Intersection.java

@Entity
public class Intersecion {

    @Id
    private String id;

    @OneToMay
    private Set<Agent> agents;

    ...

}

Agent.java

@Entity
public class Agent {

    @EmbbededId
    private PrimaryKey key;

    @Embeddable
    public static class PrimaryKey {
        String intersectionId;
        Long agentId;
    }

}

0 个答案:

没有答案