我有一个名为的超类userDetailsSuper
,它映射到另一个名为Address
.
@Entity
@Table (name = "USER_DETAILS_SUPER")
@Inheritance (strategy = InheritanceType.JOINED )
public class UserDetailsSuper
{
private long userDetailsSuperID;
private long phone;
private Set<Address> addressSet;
@OneToMany (mappedBy = "userDetailsSuper")
public Set<Address> getAddressSet() {
return addressSet;
}
public void setAddressSet(Set<Address> addressSet)
{
this.addressSet = addressSet;
}
}
Address table:
@Entity
@Table(name="ADDRESS")
public class Address
{
private long address_ID;
private UserDetailsSuper userDetailsSuper;
@ManyToOne
@JoinColumn (name = "USER_DETAILS_SUPER_ID", nullable = false)
public UserDetailsSuper getUserDetailsSuper() {
return userDetailsSuper;
}
public void setUserDetailsSuper(UserDetailsSuper userDetailsSuper) {
this.userDetailsSuper = userDetailsSuper;
}
}
//sub class
public UserDetails extends UserDetailsSuper
{
}
当我尝试插入子表时,数据被插入到子类和超类中,但不在映射地址类中。
我想我错过了一些映射......请帮忙