JPA Commit issues with Oracle
I am having issues with Oracle database. I am trying to update an entity
and pass the updated entity to another method in the same transaction.
This works using mysql database but doesn't work in Oracle database.
Entity Class
public class EntityA
{
private Long id;
@Version
private Integer versionNo;
//getters and setters
}
@Transactional //From Spring
public class EntityService
{
@Inject
@Named("myService")
private MyService service;
public void modify(final EntityA data)
{
EntityA entity = persistenceManager.merge(data);
service.serializeEntity(entity);
}
}
So the problem is that, before persistenceManager.merge(data); is called,
the versionNo field is still zero. After the call to
persistenceManager.merge(data);, the value of versionNo field in the
returned object i.e. entity is still zero. This object is then passed to
service.serializeEntity(entity); which serialized the object with
versionNo zero. But after the method i.e. update returns, the versionNo in
the database changes to 1. Is there a way of getting the uncommitted
modified EntityA before passing it to service.serializeEntity(entity);
because i need to serialize the modified object.
No comments:
Post a Comment