Home » tapestry-src-5.0.19 » org.apache.tapestry5.hibernate » [javadoc | source]

    1   // Copyright 2007 The Apache Software Foundation
    2   //
    3   // Licensed under the Apache License, Version 2.0 (the "License");
    4   // you may not use this file except in compliance with the License.
    5   // You may obtain a copy of the License at
    6   //
    7   //     http://www.apache.org/licenses/LICENSE-2.0
    8   //
    9   // Unless required by applicable law or agreed to in writing, software
   10   // distributed under the License is distributed on an "AS IS" BASIS,
   11   // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12   // See the License for the specific language governing permissions and
   13   // limitations under the License.
   14   
   15   package org.apache.tapestry5.hibernate;
   16   
   17   import org.hibernate.Session;
   18   
   19   /**
   20    * Manages the Hibernate session for the current thread. This includes creating the session as needed, allowing the
   21    * session to checkpoint (commit the current transaction and continue) and commit the transaction automatically at the
   22    * end of the request.
   23    * <p/>
   24    * Remember that in Tapestry, action requests and render requests are entirely separate, and you will see a separate
   25    * request and a separate transaction for each. Care should be taken to ensure that entity objects that are retained (in
   26    * the session, as persistent field values) between requests are handled correctly (they tend to become detached
   27    * instances).
   28    * <p/>
   29    * This implementation of this service is per-thread.
   30    */
   31   public interface HibernateSessionManager
   32   {
   33       /**
   34        * Gets the active session for this request, creating it as necessary. When the session is first created, a
   35        * transaction is started.
   36        *
   37        * @return the request's session
   38        * @see HibernateSessionSource
   39        */
   40       Session getSession();
   41   
   42       /**
   43        * Commits the current transaction (which will cause a flush of data to the database), then starts a new transaction
   44        * to replace it.
   45        */
   46       void commit();
   47   
   48       /**
   49        * Aborts the current transaction, and starts a new transaction to replace it.
   50        */
   51       void abort();
   52   }

Home » tapestry-src-5.0.19 » org.apache.tapestry5.hibernate » [javadoc | source]