I have a user class looking like this:
@Entity
public class User{
@Id
private Long id;
@Column(name = "FIRST_NAME")
private String firstName;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name="GROUP_ID")
private Set groups = new HashSet();
//... and all the other getters and setters
}
@Entity
public class Group{
@Id
private Long id;
private String name;
//.. and many others plus their getters and setters
}
When I try to fill a user and add some groups, and then persist I get the following exception:
java.lang.RuntimeException: Null Getter for: com.company.rcde.entity.annotation.Group.RCDE_USER.
It seems like it is expecting a User to be defined and mapped in the Group class which is not what I want to achieve. I need just a unidirectional oneToMany mapping.
It is very frustrating such a simple mapping is not working. Or am I doing something wrong here?
I have to add that I'm not a newbie here. I have done several Hibernate-annotations mapping in the past.