Quote:
If I want to only sync up session in memory objects that I called session.saveOrUpdate, not the in memory objects that I modified, how do I do that?
As far as I know, every attached object (meaning that the object obtained through the EntityManager) is going to be checked for changes at session flush time. So what's left for you is to detach the object. There are two ways to do that: use EntityManager.clear() to detach all objects; or get the Hibernate underlying session and evict() a single object. Call saveOrUpdate only
after detaching objects. Note that an evited object is not guaranteed to not be saved if it is in a cascade chain.
Quote:
the reason I want to do this is because I want to generate event on every save call
You can achieve that by implementing an entity listener or an entity lifecycle callback method. Piece of cake if you're using annotations.
Consider thoroughly your objective before choosing an approach (these or others).