Wednesday, 14 August 2013

JPA transactional annotation behaves weird

JPA transactional annotation behaves weird

I have the following method:
@Transactional
public void onEmailMessage() {
this.departmentService.removeUserFromDepartments(user, depsids);
this.departmentService.getDepartmentUsers(user.id);
}
The weird thing when i invoke this method, the first line:
this.departmentService.removeUserFromDepartments(user, depsids);
is called but the DB is not changing at all and the user is still
connected to the deparment (many to many relation)
afterwards the method :
this.departmentService.getDepartmentUsers(user.id);
is called and returns users that are connected to the department including
the removed user from line#1.
when the method returns - if i check the DB the user i removed is actually
been removed from the table!
can i make the query return the actual updated values??

No comments:

Post a Comment