Reputation: 870
I know that this problem have made several posts but I'm facing this issue and no solutions from the others posts worked. I'm going crazy. This is the simple code :
@Override
public void delete(Module module) {
System.out.println(this.findById(module.getId()));
em.remove(em.contains(module) ? module : em.merge(module));
System.out.println(this.findById(module.getId()));
}
This is the output from the console :
com.btoc.flowrepository.domain.Module@746d23
null
But when i'm looking on the base side, the line is still there. Any idea why ?! And how to solve ?
PS : I'm using a shared EM, so I can't create a transaction on it to pass a delete request...
Thanks by advance.
Upvotes: 0
Views: 70
Reputation: 1652
ORM technologies operate on a two phase trasaction:
What you are seeing is the changes being made to the buffer, i.e. when you try to find the object after removing it you just get null, but then because you havent called commit, those changes are not reflected in the database.
The solution obviously is to make the operation transactional and call commit. If you think this should be an operation on its own, rather than part of a group of operations then you should think about refactoring your code. Without seeing more of what you have done, I cant really offer any more advice sorry!
Upvotes: 1