我在CREATE TABLE
INSERT 0 4
PREPARE
name | age | salary
-------+-----+--------
Alice | 13 | 3
(1 row)
name | age | salary
-------+-----+--------
Alice | 13 | 3
(1 row)
和function Pyth(lat1,lat2,lng1,lng2){
x = toRad(lng2-lng1) ;
y = toRad(lat2-lat1);
R = 6371000; // gives d in metres
d = sqrt(x*x + y*y) * R;
return d;
}
表之间有多对多的关系。
人:
Person
地址:
Address
我有一个名为@Entity
@Table(name = "PERSON_MTM", schema = "Examples")
public class Person
{
@Id
@Column(name = "PERSON_ID")
private String personId;
@Column(name = "PERSON_NAME")
private String personName;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "PERSON_ADDRESS", schema = "KunderaExamples",joinColumns = { @JoinColumn(name = "PERSON_ID") }, inverseJoinColumns = { @JoinColumn(name = "ADDRESS_ID") })
private Set<AddressMTM> addresses;
//setters and getters
}
的 joinTable 。
注意:我的问题不在于
@Entity @Table(name = "ADDRESS_MTM", schema = "Examples") public class Address { @Id @Column(name = "ADDRESS_ID") private String addressId; @Column(name = "STREET") private String street; // setters and getters }
。我在问 代表PERSON_ADDRESS
答案 0 :(得分:0)
您可以使用多个JoinColumms,例如包括PERSON_NAME(如果这对您的逻辑有意义)
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(
name = "PERSON_ADDRESS",
schema = "KunderaExamples",
joinColumns = {
@JoinColumn(name="PERSON_NAME"),
@JoinColumn(name = "PERSON_ID") },
inverseJoinColumns = {
@JoinColumn(name = "ADDRESS_ID") })
private Set<AddressMTM> addresses;