java - PreUpdate listener triggered during empty update -


i have entity last modified attribute:

@temporal(temporaltype.timestamp) private date lastmodified;  @preupdate @prepersist protected void onupdate() {     lastmodified = new date(); } 

and named jpql update query, sets attributes old entities:

update entity e set ... e.lastmodified < :threshold 

the onupdate() method called entities, has not been modified, event if:

entitymanager.createquery("...").executeupdate(); 

returns 0 number of updated entities.

can update old entities without touching recent ones? threshold parameter not known in updated entity, cannot move update onupdate() method. can native query me in this?

why don't replace @preupdate/@prepersist mechanism @version on lastmodified field ? way updated entity have field set (and updated ones).

it should make job expect if understood case.


Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -