So here is the thing. I have 2 tables in the database: User and Client.
A user can add one or many clients in the database. So what I want is when a user will add a client - the function will retrieve the id of the logged in User and add it as a foreign key in the client table.
I have already done the OneToMany
Mapping.
Here is my controller:
@RequestMapping(value = "/postficheclient", method = RequestMethod.POST)
public ResponseEntity<?> createClient(@RequestBody Client newClient) {
// newClient.setUser(user);
return new ResponseEntity<Client>(clientservices.save(newClient), HttpStatus.CREATED);
}
With that function, it adds a null
value in the Client
table.
Can someone help me, please?
PS: I use the spring security system.