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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -