Java Doc for TransactionDefinition.java in  » J2EE » spring-framework-2.0.6 » org » springframework » transaction » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.transaction 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.transaction.TransactionDefinition

All known Subclasses:   org.springframework.transaction.support.DefaultTransactionDefinition,
TransactionDefinition
public interface TransactionDefinition (Code)
Interface that defines Spring-compliant transaction properties. Based on the propagation behavior definitions analogous to EJB CMT attributes.

Note that isolation level and timeout settings will not get applied unless an actual new transaction gets started. As only TransactionDefinition.PROPAGATION_REQUIRED , TransactionDefinition.PROPAGATION_REQUIRES_NEW and TransactionDefinition.PROPAGATION_NESTED can cause that, it usually doesn't make sense to specify those settings in other cases. Furthermore, be aware that not all transaction managers will support those advanced features and thus might throw corresponding exceptions when given non-default values.

The TransactionDefinition.isReadOnly() read-only flag applies to any transaction context, whether backed by an actual resource transaction or operating non-transactionally at the resource level. In the latter case, the flag will only apply to managed resources within the application, such as a Hibernate Session.
author:
   Juergen Hoeller
since:
   08.05.2003
See Also:   PlatformTransactionManager.getTransaction(TransactionDefinition)
See Also:   org.springframework.transaction.support.DefaultTransactionDefinition
See Also:   org.springframework.transaction.interceptor.TransactionAttribute



Field Summary
 intISOLATION_DEFAULT
     Use the default isolation level of the underlying datastore.
 intISOLATION_READ_COMMITTED
     Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
 intISOLATION_READ_UNCOMMITTED
     Indicates that dirty reads, non-repeatable reads and phantom reads can occur.

This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read").

 intISOLATION_REPEATABLE_READ
     Indicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
 intISOLATION_SERIALIZABLE
     Indicates that dirty reads, non-repeatable reads and phantom reads are prevented.
 intPROPAGATION_MANDATORY
     Support a current transaction; throw an exception if no current transaction exists.
 intPROPAGATION_NESTED
     Execute within a nested transaction if a current transaction exists, behave like TransactionDefinition.PROPAGATION_REQUIRED else.
 intPROPAGATION_NEVER
     Do not support a current transaction; throw an exception if a current transaction exists.
 intPROPAGATION_NOT_SUPPORTED
     Do not support a current transaction; rather always execute non-transactionally. Analogous to the EJB transaction attribute of the same name.

NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers.

 intPROPAGATION_REQUIRED
     Support a current transaction; create a new one if none exists.
 intPROPAGATION_REQUIRES_NEW
     Create a new transaction, suspending the current transaction if one exists. Analogous to the EJB transaction attribute of the same name.

NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers.

 intPROPAGATION_SUPPORTS
     Support a current transaction; execute non-transactionally if none exists. Analogous to the EJB transaction attribute of the same name.

NOTE: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scope that synchronization might apply to. As a consequence, the same resources (a JDBC Connection, a Hibernate Session, etc) will be shared for the entire specified scope.

 intTIMEOUT_DEFAULT
     Use the default timeout of the underlying transaction system, or none if timeouts are not supported.


Method Summary
 intgetIsolationLevel()
     Return the isolation level.
 StringgetName()
     Return the name of this transaction.
 intgetPropagationBehavior()
     Return the propagation behavior.
 intgetTimeout()
     Return the transaction timeout.
 booleanisReadOnly()
     Return whether to optimize as a read-only transaction.

The read-only flag applies to any transaction context, whether backed by an actual resource transaction ( TransactionDefinition.PROPAGATION_REQUIRED / TransactionDefinition.PROPAGATION_REQUIRES_NEW ) or operating non-transactionally at the resource level ( TransactionDefinition.PROPAGATION_SUPPORTS ).


Field Detail
ISOLATION_DEFAULT
int ISOLATION_DEFAULT(Code)
Use the default isolation level of the underlying datastore. All other levels correspond to the JDBC isolation levels.
See Also:   java.sql.Connection



ISOLATION_READ_COMMITTED
int ISOLATION_READ_COMMITTED(Code)
Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.

This level only prohibits a transaction from reading a row with uncommitted changes in it.
See Also:   java.sql.Connection.TRANSACTION_READ_COMMITTED




ISOLATION_READ_UNCOMMITTED
int ISOLATION_READ_UNCOMMITTED(Code)
Indicates that dirty reads, non-repeatable reads and phantom reads can occur.

This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read"). If any of the changes are rolled back, the second transaction will have retrieved an invalid row.
See Also:   java.sql.Connection.TRANSACTION_READ_UNCOMMITTED




ISOLATION_REPEATABLE_READ
int ISOLATION_REPEATABLE_READ(Code)
Indicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.

This level prohibits a transaction from reading a row with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the first transaction rereads the row, getting different values the second time (a "non-repeatable read").
See Also:   java.sql.Connection.TRANSACTION_REPEATABLE_READ




ISOLATION_SERIALIZABLE
int ISOLATION_SERIALIZABLE(Code)
Indicates that dirty reads, non-repeatable reads and phantom reads are prevented.

This level includes the prohibitions in TransactionDefinition.ISOLATION_REPEATABLE_READ and further prohibits the situation where one transaction reads all rows that satisfy a WHERE condition, a second transaction inserts a row that satisfies that WHERE condition, and the first transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.
See Also:   java.sql.Connection.TRANSACTION_SERIALIZABLE




PROPAGATION_MANDATORY
int PROPAGATION_MANDATORY(Code)
Support a current transaction; throw an exception if no current transaction exists. Analogous to the EJB transaction attribute of the same name.

Note that transaction synchronization within a PROPAGATION_MANDATORY scope will always be driven by the surrounding transaction.




PROPAGATION_NESTED
int PROPAGATION_NESTED(Code)
Execute within a nested transaction if a current transaction exists, behave like TransactionDefinition.PROPAGATION_REQUIRED else. There is no analogous feature in EJB.

NOTE: Actual creation of a nested transaction will only work on specific transaction managers. Out of the box, this only applies to the JDBC org.springframework.jdbc.datasource.DataSourceTransactionManager when working on a JDBC 3.0 driver. Some JTA providers might support nested transactions as well.
See Also:   org.springframework.jdbc.datasource.DataSourceTransactionManager




PROPAGATION_NEVER
int PROPAGATION_NEVER(Code)
Do not support a current transaction; throw an exception if a current transaction exists. Analogous to the EJB transaction attribute of the same name.

Note that transaction synchronization is not available within a PROPAGATION_NEVER scope.




PROPAGATION_NOT_SUPPORTED
int PROPAGATION_NOT_SUPPORTED(Code)
Do not support a current transaction; rather always execute non-transactionally. Analogous to the EJB transaction attribute of the same name.

NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to org.springframework.transaction.jta.JtaTransactionManager , which requires the javax.transaction.TransactionManager to be made available it to it (which is server-specific in standard J2EE).

Note that transaction synchronization is not available within a PROPAGATION_NOT_SUPPORTED scope. Existing synchronizations will be suspended and resumed appropriately.
See Also:   org.springframework.transaction.jta.JtaTransactionManager.setTransactionManager




PROPAGATION_REQUIRED
int PROPAGATION_REQUIRED(Code)
Support a current transaction; create a new one if none exists. Analogous to the EJB transaction attribute of the same name.

This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.




PROPAGATION_REQUIRES_NEW
int PROPAGATION_REQUIRES_NEW(Code)
Create a new transaction, suspending the current transaction if one exists. Analogous to the EJB transaction attribute of the same name.

NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to org.springframework.transaction.jta.JtaTransactionManager , which requires the javax.transaction.TransactionManager to be made available it to it (which is server-specific in standard J2EE).

A PROPAGATION_REQUIRES_NEW scope always defines its own transaction synchronizations. Existing synchronizations will be suspended and resumed appropriately.
See Also:   org.springframework.transaction.jta.JtaTransactionManager.setTransactionManager




PROPAGATION_SUPPORTS
int PROPAGATION_SUPPORTS(Code)
Support a current transaction; execute non-transactionally if none exists. Analogous to the EJB transaction attribute of the same name.

NOTE: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scope that synchronization might apply to. As a consequence, the same resources (a JDBC Connection, a Hibernate Session, etc) will be shared for the entire specified scope. Note that the exact behavior depends on the actual synchronization configuration of the transaction manager!

In general, use PROPAGATION_SUPPORTS with care! In particular, do not rely on PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW within a PROPAGATION_SUPPORTS scope (which may lead to synchronization conflicts at runtime). If such nesting is unavoidable, make sure to configure your transaction manager appropriately (typically switching to "synchronization on actual transaction").
See Also:   org.springframework.transaction.support.AbstractPlatformTransactionManager.setTransactionSynchronization
See Also:   org.springframework.transaction.support.AbstractPlatformTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION




TIMEOUT_DEFAULT
int TIMEOUT_DEFAULT(Code)
Use the default timeout of the underlying transaction system, or none if timeouts are not supported.





Method Detail
getIsolationLevel
int getIsolationLevel()(Code)
Return the isolation level.

Must return one of the ISOLATION_XXX constants defined on TransactionDefinition this interface .

Only makes sense in combination with TransactionDefinition.PROPAGATION_REQUIRED or TransactionDefinition.PROPAGATION_REQUIRES_NEW .

Note that a transaction manager that does not support custom isolation levels will throw an exception when given any other level than TransactionDefinition.ISOLATION_DEFAULT . the isolation level




getName
String getName()(Code)
Return the name of this transaction. Can be null.

This will be used as the transaction name to be shown in a transaction monitor, if applicable (for example, WebLogic's).

In case of Spring's declarative transactions, the exposed name must (and will) be the fully-qualified class name + "." + method name (by default). the name of this transaction
See Also:   org.springframework.transaction.interceptor.TransactionAspectSupport
See Also:   org.springframework.transaction.support.TransactionSynchronizationManager.getCurrentTransactionName




getPropagationBehavior
int getPropagationBehavior()(Code)
Return the propagation behavior.

Must return one of the PROPAGATION_XXX constants defined on TransactionDefinition this interface . the propagation behavior
See Also:   TransactionDefinition.PROPAGATION_REQUIRED
See Also:   org.springframework.transaction.support.TransactionSynchronizationManager.isActualTransactionActive




getTimeout
int getTimeout()(Code)
Return the transaction timeout.

Must return a number of seconds, or TransactionDefinition.TIMEOUT_DEFAULT .

Only makes sense in combination with TransactionDefinition.PROPAGATION_REQUIRED or TransactionDefinition.PROPAGATION_REQUIRES_NEW .

Note that a transaction manager that does not support timeouts will throw an exception when given any other timeout than TransactionDefinition.TIMEOUT_DEFAULT . the transaction timeout




isReadOnly
boolean isReadOnly()(Code)
Return whether to optimize as a read-only transaction.

The read-only flag applies to any transaction context, whether backed by an actual resource transaction ( TransactionDefinition.PROPAGATION_REQUIRED / TransactionDefinition.PROPAGATION_REQUIRES_NEW ) or operating non-transactionally at the resource level ( TransactionDefinition.PROPAGATION_SUPPORTS ). In the latter case, the flag will only apply to managed resources within the application, such as a Hibernate Session.

This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager that cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction. true if the transaction is to be optimized as read-only
See Also:   org.springframework.transaction.support.TransactionSynchronization.beforeCommit(boolean)
See Also:   org.springframework.transaction.support.TransactionSynchronizationManager.isCurrentTransactionReadOnly




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.