When working with class that has @Context defined and with a simple data property (Instant):
Updating attribute on managed instance from native query saves the value to default context.
Example class (customized version copied from Jopa integration tests)
Steps to reproduce:
- Create a class with
@Context defined
- Create a new entity in a standalone transaction (and commit it)
- Everything is saved correctly in the defined context
- Start a new transaction
- Acquire managed instance with native query
- Update value of an attribute
- (optional) merge the entity (explicitly calling entity manager merge makes no diference)
- Commit transaction
- The triple of the attribute is saved to default database context, not in the entity context (the original triple is removed from the entity context)
Expected result: the updated triple should be stored in the entity context
Observations:
a. detaching the entity first and then explicitly calling merge saves the update to correct context
b. updating instance from entity manager find saves the update to correct context
Demo:
https://github.com/lukaskabc/GraphDB-Graph-Transaction/blob/entity_merging_default_context/src/main/java/com/example/demo/TestRunner.java#L34
https://github.com/lukaskabc/GraphDB-Graph-Transaction/blob/entity_merging_default_context/src/main/java/com/example/demo/TransactionExecutor.java#L46
When working with class that has
@Contextdefined and with a simple data property (Instant):Updating attribute on managed instance from native query saves the value to default context.
Example class (customized version copied from Jopa integration tests)
Steps to reproduce:
@ContextdefinedExpected result: the updated triple should be stored in the entity context
Observations:
a. detaching the entity first and then explicitly calling merge saves the update to correct context
b. updating instance from entity manager find saves the update to correct context
Demo:
https://github.com/lukaskabc/GraphDB-Graph-Transaction/blob/entity_merging_default_context/src/main/java/com/example/demo/TestRunner.java#L34
https://github.com/lukaskabc/GraphDB-Graph-Transaction/blob/entity_merging_default_context/src/main/java/com/example/demo/TransactionExecutor.java#L46