mapTables(如onetomany)在Spring Data JPA中具有两个不同模式之间的父子关系?

时间:2018-06-14 14:20:50

标签: spring spring-data-jpa

我尝试映射来自不同架构的两个表。为每个架构创建了2个数据源。但是在映射时遇到错误。

public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "duty_type_id")
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "customerId")
    private Long id;
    @Column(nullable = false)
    private String firstName;
    @Column(nullable = false)
    private String lastName;
}

public class Order implements Serializable {

private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue
    private Long id;

    @Column(nullable = false)
    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "duty_type_id", nullable = false)
    private Customer customerId;
}

它的工作没有@mapping注释,(意味着我可以创建没有外键约束的表)。但我需要映射这些表

0 个答案:

没有答案