I have two entities, User and Operation and both entities have a join among them:
@Entity
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long userId;
@Basic
private String username;
private String password;
//Getters and Setters
}
@Entity
public class Operation implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long userId;
@ManyToOne
@JoinColumn(name = "user_id")
User user;
//Getters and Setters
}
Both Entities has a Repository too.
In my context the User entity is loadded in Session scope (HttpSession) when user (operator) has been logged. For each operation of user on system the app register that operation throug the Operation Repository.
My question is: How can I set User entity (getting on session) to operation before the register in Database?
Is possible override the Repository method?
EDIT 1:
The operation is saved through the web interface using HTTP POST method. I need to keep using the URI to save. Like:
URI: http: // localhost: 9874 / operations DATA: { "name": "operation-name" }
Thanks!