Reputation: 1339
I got 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;
(...)
}
Any way how to map relation @ManyToOne (many users can have the same adres), BUT I don't want to have property List< User > users in my Address class?
Upvotes: 7
Views: 9525
Reputation: 692281
Add the annotation @ManyToOne
to the address field. Problem solved. For details on how this can be customized, see the Hibernate reference manual. Typically you would use
@ManyToOne
@JoinColumn(name = "addressId")
private Address address;
Upvotes: 14