Hibernate - Cascading problems using ManyToOne association
posted 6 years ago
I am working with Hibernate trying to get ManyToOne working. But problems of course since I am here...
I am working with two classes (Tables)
The users are unique and the identifier is "email". One user can have multiple incidents but one incident can only have one user. Though it is not a bi-directional relation, incident knows about the user but user doesn't know about the incident.
I am not getting any exceptions, the problem I am having is that only Incident table is updated and not the user table. Also, an extra column in the incident table is created named "USERS_EMAIL". I understand where I define this, but I didn't fully understand Hibernates instructions, perhaps handling it incorrect.
Shouldn't the cascading take care of updating my Users table automatically? Or do I have to explicitly persist my Users object? If that is the case, is there any point using @JoinColumn or at all defining the ManyToOne relation?
Any help would be most appreciated, especially as this seems to be the last big threshold for me applying Hibernate for real. Thanks in advance!
My Entity classes:
And from this class I am trying to save the data. The parameter data is coming in correctly, verified by System.out.println...