Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding Hibernate transactions
    primarykey
    data
    text
    <p>I understand that a transaction helps to rollback update operations if anything goes wrong such as a code exception or if the database is down. What I do not understand is the following:</p> <p>In <a href="http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch13.html#transactions-demarcation" rel="nofollow">this page</a>:</p> <blockquote> <p>13.2. Database transaction demarcation</p> <p>Database, or system, transaction boundaries are always necessary. No communication with the database can occur outside of a database transaction (this seems to confuse many developers who are used to the auto-commit mode). Always use clear transaction boundaries, even for read-only operations</p> </blockquote> <p>This one says that a transaction should be used in all cases, even for <strong>read-only operations</strong> !</p> <ul> <li>Why is it a must ? Shouldn't I do so only when I'm about to update the database ?</li> <li>If it's a must, why isn't it started automatically when a session is obtained ?</li> </ul> <p>Regarding the following quoted paragraph (On <a href="http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch02.html#architecture-overview" rel="nofollow">this page</a>).</p> <blockquote> <p>Transaction (org.hibernate.Transaction)</p> <p>(Optional) A single-threaded, short-lived object used by the application to specify atomic units of work. It abstracts the application from the underlying JDBC, JTA or CORBA transaction. A org.hibernate.Session might span several org.hibernate.Transactions in some cases. However, transaction demarcation, either using the underlying API or org.hibernate.Transaction, is never optional.</p> </blockquote> <p>What is meant by the first word <code>(Optional)</code> indicate ?</p> <p>And what does this statement mean too ?</p> <p><code>However, transaction demarcation, either using the underlying API or org.hibernate.Transaction, is never optional.</code> ?!</p> <p>Also I understand from <a href="http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch01.html" rel="nofollow">this page</a>, that whenever I open a Hibernate session whether to update or load an object, I <strong>must</strong> start a transaction.</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. 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