Announcement Announcement Module
Collapse
No announcement yet.
hibernate flush for find Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hibernate flush for find

    Hi, I'am using a pre-update event listener to modify my domain modifiedDate property.

    public class TrackingPreUpdateEventListener implements PreUpdateEventListener{

    public boolean onPreUpdate(PreUpdateEvent preUpdateEvent) {

    Object objectToInsert = preUpdateEvent.getEntity();
    if (objectToInsert instanceof Tracking) {
    Tracking tracking = (Tracking) objectToInsert;
    int version = tracking.getVersion();
    if (version > 0) {
    tracking.setUpdatedDate(getCurrentDate());
    }
    }
    return false;
    }

    /**
    * Returns the current date
    * @return
    */
    protected Date getCurrentDate() {
    return Calendar.getInstance().getTime();
    }

    I have observed that in each select or find query there are some update calls going on. When I debug I came to know that hibernate flush after the find query.So the flush in tern calls all the listeners registered.

    Is there any thing that I can avoid this.
    I know that i can set the flush mode , is there any way to set the flush mode in the spring context it self.

    Appriciate any solution on this.

  • #2
    Flush is called before some operations to prevent dirty reads. I would be relucant to play with the flush mode. Couldn't you use a different listener?
    http://www.hibernate.org/hib_docs/v3...state-flushing

    Comment


    • #3
      Listeners

      Hi could u name one of them . That would be very helpfull.Thanks for the reply.

      Comment

      Working...
      X