Hibernate @ManyToOne - Only One Referral Relationship

I have classes:

@Entity @Table(name="users") public class User{ private Integer id; private String name; private Address address; } 

and

  @Entity @Table(name="adress") public class Adress{ private Integer id; private String street; (...) } 

In any case, how to map the @ManyToOne relation (many users can have the same address), BUT I don't want to have the List <User> users property in my Address class?

+4
source share
1 answer

Add the @ManyToOne annotation to the address field. The problem is solved. See the Hibernate Reference Guide for more information on how this can be configured. Usually you use

 @ManyToOne @JoinColumn(name = "addressId") private Address address; 
+8
source

All Articles