HibernateTransactionObject.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 2k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  3.  * 
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  * 
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  * 
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */ 
  16. package org.springframework.orm.hibernate;
  17. import net.sf.hibernate.FlushMode;
  18. import org.springframework.jdbc.datasource.JdbcTransactionObjectSupport;
  19. /**
  20.  * Hibernate transaction object, representing a SessionHolder.
  21.  * Used as transaction object by HibernateTransactionManager.
  22.  *
  23.  * <p>Derives from JdbcTransactionObjectSupport to inherit the capability
  24.  * to manage JDBC 3.0 Savepoints for underlying JDBC Connections.
  25.  *
  26.  * <p>Note: This is an SPI class, not intended to be used by applications.
  27.  *
  28.  * @author Juergen Hoeller
  29.  * @since 02.05.2003
  30.  * @see HibernateTransactionManager
  31.  * @see SessionHolder
  32.  */
  33. public class HibernateTransactionObject extends JdbcTransactionObjectSupport {
  34. private SessionHolder sessionHolder;
  35. private boolean newSessionHolder;
  36. protected void setSessionHolder(SessionHolder sessionHolder, boolean newSessionHolder) {
  37. this.sessionHolder = sessionHolder;
  38. this.newSessionHolder = newSessionHolder;
  39. }
  40. public SessionHolder getSessionHolder() {
  41. return sessionHolder;
  42. }
  43. public boolean isNewSessionHolder() {
  44. return newSessionHolder;
  45. }
  46. public boolean hasTransaction() {
  47. return (this.sessionHolder != null && this.sessionHolder.getTransaction() != null);
  48. }
  49. public boolean isRollbackOnly() {
  50. return getSessionHolder().isRollbackOnly();
  51. }
  52. }