Spring加入复合键的单列

时间:2017-06-11 02:11:57

标签: java spring hibernate jpa composite

控制台错误:从com.api.tracker.pojo.Tracker引用com.api.subscriber.pojo.MapperSubscriberTracker的外键具有错误的列数。应该是2

passd = input("Please enter your password: ").lower()

我也尝试了以下方法,但错误相同:

public class MapperSubscriberTracker implements Serializable {
    @Id
    @Column(name = "tracker_id")
    private int trackerID;

    @ManyToOne
    @Id
    @JoinColumn(name = "subscriber_id")
    @JsonBackReference
    private Subscriber subscriber;

   @OneToMany(fetch = FetchType.EAGER,mappedBy = "mapperSubscriberTracker", cascade = CascadeType.ALL)
    @JsonManagedReference
    private Set<Tracker> trackers;
    ...
}



public class Tracker {
    @Id
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;

    @ManyToOne
    @JoinColumn(name = "subscriber_id")
    @JsonBackReference
    private MapperSubscriberTracker mapperSubscriberTracker;

    ...
}

据我所知,由于复合键,它需要2个键加入,但我不想这样做。有没有办法强制它加入一列?

0 个答案:

没有答案