简体   繁体   中英

Open Session In View (OSIV) and Hibernate Session flush

Following is a hypothetical situation on Spring 3.x and Hibernate3.x

I have a service layer in spring which invokes 3 DAOs to construct a model. The DAOs are transactional(@Transactional) and have lazy loaded hibernate collections.
The service method causes a few updates ,along with the fetch of data.

A typical DAO method will be as follows -

public O create(I entity) throws GenericException {
    getOrCreateSession().save(entity);
    return (O)entity;
}

I have the following questions around OSIV -
1.How many times is this session flushed(database update) in the default AUTO mode?
2.Can OSIV be made to extend the session beyond a single request (to a conversation)?

  1. The AUTO flush mode will execute the pending DML statements when:
  • the current transaction is committed
  • when a query might target an entity table, that's current enqueued for flushing
  1. Spring Webflow has support for long conversations .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM