We are using OBD with Spring and transactions are managed by Spring. Our spring service interfaces take list of objects and persist them and the interface service is marked as @Transactional.
We iterate through the list apply business validations and persist them one by one in a loop. ( Using Spring Data)
We have noticed that in a loop 1st object is persisted and then we if lookup the same object we don't get it back on lookup.
This is with transactions we are not able to retrieve the persisted object within the same transaction. It is only available after transaction commit. Ideally the lookup is also part of same transaction so it should be aware of the persisted object.
The logic works fine if i remove @Transactional attribute from my service method.
is this desirable behavior of ODB ? I thought in the same transaction if i do a lookup on persisted object I should be able to get the reference. Thanks for your help.