I have an insert query performed by spring boot jpa. The insert query triggers a DB trigger, which updates a column, slug
. Is there a way to get the updated value as part of the same jpa transaction (instead of reading the record again from the DB or using a Stored procedure)?
Following code simplified for question sake.
@RestController
@RequestMapping(value = "user")
public class UserController {
@PostMapping
public Invite saveUser(@Validated @RequestBody User user) {
// user.slug is null
User newUser = userRepo.save(user);
// DB insert
// DB trigger has logic to update user.slug column in DB
// newUser.slug is null; in spite of DB having a value for the slug column
}
}
Note: I tried what's suggested here and it didn't work.