DATAJDBC-251 - Back-reference for dependent entity gets properly set.

If a parent DbAction does not offer a generated id, the id of the entity is used instead. This behavior was broken by DATAJDBC-241.

Related tickets: DATAJDBC-241.
Original pull request: #85.
This commit is contained in:
Jens Schauder
2018-08-20 13:08:17 +02:00
committed by Oliver Gierke
parent d158cd062d
commit 55c901b43b
4 changed files with 293 additions and 8 deletions

View File

@@ -171,7 +171,12 @@ class DefaultJdbcInterpreter implements Interpreter {
Object entity = dependingOn.getEntity();
if (dependingOn instanceof DbAction.WithGeneratedId) {
return ((DbAction.WithGeneratedId<?>) dependingOn).getGeneratedId();
Object generatedId = ((DbAction.WithGeneratedId<?>) dependingOn).getGeneratedId();
if (generatedId != null) {
return generatedId;
}
}
return persistentEntity.getIdentifierAccessor(entity).getIdentifier();