0

I have a super class called userDetailsSuper which is mapped to another table called 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
{
}

When I try to insert into the child table, data is inserted in the child class and super class but not in the mapped address class.

I think I'm missing some mapping... Kindly help

zessx
  • 68,042
  • 28
  • 135
  • 158
user2768984
  • 57
  • 1
  • 11

1 Answers1

0

Define this in your "UserDetailsSuper" Entity.

@OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="USER_DETAILS_SUPER_ID")

Follow this example http://viralpatel.net/blogs/hibernate-one-to-many-annotation-tutorial/)

JLP
  • 311
  • 2
  • 3
  • 12