Some background, I use JPA/Hibernaate/Spring in my web application I also use org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter and an extended persistence context to handle my entities.
The problem:
user clicks the edit link for an entity
Entity is loaded from the database using find methods and entity gets stored in session
user makes changes to entity and hits save
user changes are reflected on the entity stored in session (in the controller)
entity is sent to a method (annotated with @Transactional) in a service class
no changes to the entity (or any other entity) happens in the service class (it does some other none persistence related stuff)
no changes are flushed to the database after the service method is done!!!?
NOTE: The service class is a spring component, I debugged the spring proxy created for it, when calling the service method annotated with @Transactional I saw spring create a NEW transaction before service method call and I also saw it commit the transaction successfully. From my understanding that even though the changes to the entity didn't happen in transaction boundaries it still should be flushed to the database. why is the changes are not being flushed?!