Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <strong><a href="http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/">Hibernate Documentation</a></strong> gives good examples of this. Also this <a href="http://blog.astradele.com/2005/09/24/hibernate-sessionevict-and-explicit-saving/">blog post</a> will give you some insight. I will add some line from there below.</p> <p>It is possible to re-load an object and all its collections at any time, using the <code>refresh()</code> method. This is useful when database triggers are used to initialize some of the properties of the object.</p> <pre><code>sess.save(cat); sess.flush(); //force the SQL INSERT sess.refresh(cat); //re-read the state (after the trigger executes) </code></pre> <p>see <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html#objectstate-loading">here</a> for more examples.</p> <p>Whenever you pass an object to <code>save(), update() or saveOrUpdate()</code>, and whenever you retrieve an object using <code>load(), get(), list(), iterate() or scroll()</code>, that object is added to the internal cache of the Session.</p> <p>When <code>flush()</code> is subsequently called, the state of that object will be synchronized with the database. If you do not want this synchronization to occur, or if you are processing a huge number of objects and need to manage memory efficiently, the <code>evict()</code> method can be used to remove the object and its collections from the first-level cache.</p> <pre><code>ScrollableResult cats = sess.createQuery("from Cat as cat").scroll(); //a huge result set while ( cats.next() ) { Cat cat = (Cat) cats.get(0); doSomethingWithACat(cat); sess.evict(cat); // (if gives the compile time error then use it: sess.evict(cat.getClass()); } </code></pre> <p>Read the complete example from <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-sessioncache">here</a>.</p> <p>Read about the session API <a href="http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/Session.html">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload