An advice may be an interceptor, a throws advice, before advice, introduction etc.
IPersistenceExceptionTranslator interface out of the box.
As a consequence, all that is usually needed to enable automatic exception
translation is marking all affected objects (such as DAOs) with the
Repository annotation, along with defining this post-processor
in the application context.
non-null on the first (if any) match.
null if the
exception could not be translated, as in this case it may result from
user code rather than an actual persistence problem)
null if the
exception could not be translated, as in this case it may result from
user code rather than an actual persistence problem)
Implementors should be marked as sealed, to make it clear that
concrete subclasses are not supposed to override this template method themselves.
Invoked after population of normal object properties but before an init
callback like
This exception will be thrown either by O/R mapping tools or by custom DAO implementations.
This exception will be thrown either by O/R mapping tools or by custom DAO implementations.
This exception will be thrown either by O/R mapping tools or by custom DAO implementations.
For example, this exception or a subclass might be thrown if an ADO.NET connection couldn't be closed after it had been used successfully.
Note that data access code might perform resource cleanup in a finally block and therefore log cleanup failure rather than rethrow it, to keep the original data access exception, if any.
Note that this is not purely a relational concept; unique primary keys are required by most database types.
This exception will be thrown either by O/R mapping tools or by custom DAO implementations.
This represents a problem in our data access framework, not the underlying data access infrastructure.
Thrown, for example, when we wanted to update 1 row in an RDBMS but actually updated 3.
Thrown for example on specifying bad SQL when using a RDBMS. Resource-specific subclasses will probably be supplied by data access packages.
This exception will be thrown either by O/R mapping tools or by custom DAO implementations.
All object definitions will have been loaded, but no objects will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing objects.
This method allows the object instance to perform the kind of initialization only possible when all of it's dependencies have been injected (set), and to throw an appropriate exception in the event of misconfiguration.
Please do consult the class level documentation for the
LogicalThreadContext.SetData(MultiDelegatingDbProvider.CURRENT_DBPROVIDER_SLOTNAME, "database1ProviderName"). The value
"database1ProviderName" must match a key in the provided TargetDbProviders dictionary.
<property> tag.
This method allows the object instance to perform the kind of initialization only possible when all of it's dependencies have been injected (set), and to throw an appropriate exception in the event of misconfiguration.
Please do consult the class level documentation for the
Provides the following workflow handling:
Transaction synchronization is a generic mechanism for registering callbacks that get invoked at transaction completion time. The same mechanism can also be used for custom synchronization efforts.
The state of this class is serializable. It's up to subclasses if
they wish to make their state to be serializable.
They should implement
Applications can use this directly, but it is not primarily meant as an API.
Typically, applications will work with either
For implementers,
Note that parameters like isolation level or timeout will only be applied to new transactions, and thus be ignored when participating in active ones. Furthermore, they aren't supported by every transaction manager: a proper implementation should throw an exception when custom values that it doesn't support are specified.
If the transaction has been marked rollback-only programmatically, perform a rollback.
If the transaction wasn't a new one, omit the commit to take part in the surrounding transaction properly.
If the transaction wasn't a new one, just set it rollback-only to take part in the surrounding transaction properly.
An implementation does not need to check the rollback-only flag.
Subclasses can override this to return false, causing a further
invocation of
AfterCompletion methods
immediately, passing in TransactionSynchronizationStatus.Unknown.
This is the best we can do if there's no chance to determine the actual
outcome of the outer transaction.
DoGetTransaction.
The lList of TransactionSynchronization objects.
This implementation handles propagation behavior.
Delegates to
Note that parameters like isolation level or timeout will only be applied to new transactions, and thus be ignored when participating in active ones. Furthermore, they aren't supported by every transaction manager: a proper implementation should throw an exception when custom values that it doesn't support are specified.
This implementation handles participating in existing transactions.
Delegates to
If the transaction wasn't a new one, just set it rollback-only to take part in the surrounding transaction properly.
Note that transaction synchronization isn't supported for multiple concurrent transactions by different transaction managers. Only one transaction manager is allowed to activate it at any time.
Typically initialized with an appropriate default by the concrete transaction manager subclass.
An implementation does not need to check the rollback-only flag.
Note that savepoints can only work within an active transaction.
Just use this programmatic savepoint handling for advanced needs;
else, a subtransaction with a
Note that most transaction managers will automatically release savepoints at transaction completion.
Note that most transaction managers will automatically release savepoints at transaction completion.
Implementations should fail as silently as possible if proper resource cleanup will still happen at transaction completion.
Autodetected by
Note that most transaction managers will automatically release savepoints at transaction completion.
Note that most transaction managers will automatically release savepoints at transaction completion.
Implementations should fail as silently as possible if proper resource cleanup will still happen at transaction completion.
Allows you to execute any number of operations on a IDbDataAdapter, for example to Fill a DataSet or other more advanced operations such as the transfering data between two different DataSets.
Note that the passed in IDbDataAdapter has been created by the framework and its SelectCommand will be populated with values for CommandType and Text properties along with Connection/Transaction properties based on the calling transaction context.
Allows you to execute any number of operations on a single IDbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in IDbCommand has been created by the framework.
Note that a RowMapper object is typically stateless and thus reusable; just the RowMapperResultSetExtractor adapter is stateful.
As an alternative consider subclassing MappingAdoQuery from the Spring.Data.Objects namespace: Instead of working with separate AdoTemplate and IRowMapper objects you can have executable query objects (containing row-mapping logic) there.
This interface is mainly used within the ADO.NET framework. An IResultSetExtractor is usually a simpler choice for result set (DataReader) processing, in particular a RowMapperResultSetExtractor in combination with a IRowMapper.
Allows you to execute any number of operations on a single IDbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in IDbCommand has been created by the framework and will have its Connection property set and the Transaction property set based on the transaction context.
As an alternative to using this interface you can use the delegate version which is particularly nice when using anonymous delegates for writing more terse code and having easy access to the variables in the calling class.
See
Allows you to execute any number of operations on a single DbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in DbCommand has been created by the framework and will have its Connection property set and the Transaction property set based on the transaction context.
Allows you to execute any number of operations on a single DbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in DbCommand has been created by the framework and will have its Connection property set and the Transaction property set based on the transaction context.
Allows you to execute any number of operations on a IDbDataAdapter, for example to Fill a DataSet or other more advanced operations such as the transfering data between two different DataSets.
Note that the passed in IDbDataAdapter has been created by the framework and its SelectCommand will be populated with values for CommandType and Text properties along with Connection/Transaction properties based on the calling transaction context.
Allows you to execute any number of operations on a single IDbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in DbCommand has been created by the framework and will have its Connection property set and the Transaction property set based on the transaction context.
This interface is mainly used within the ADO.NET framework. An IResultSetExtractor is usually a simpler choice for result set (DataReader) processing, in particular a RowMapperResultSetExtractor in combination with a IRowMapper.
Typically used for AdoTemplate's query methods (with RowMapperResultSetExtractor adapters). RowMapper objects are typically stateless and thus reusable; they are ideal choices for implementing row-mapping logic in a single place.
Alternatively, consider subclassing MappingSqlQuery from the Spring.Data.Object namespace: Instead of working with separate AdoTemplate and RowMapper objects, you can have executable query objects (containing row-mapping logic) there.
Note that a RowMapper object is typically stateless and thus reusable; just the RowMapperResultSetExtractor adapter is stateful.
As an alternative consider subclassing MappingAdoQuery from the Spring.Data.Objects namespace: Instead of working with separate AdoTemplate and IRowMapper objects you can have executable query objects (containing row-mapping logic) there.
Typically used for AdoTemplate's query methods (with RowMapperResultSetExtractor adapters). RowMapper objects are typically stateless and thus reusable; they are ideal choices for implementing row-mapping logic in a single place.
Alternatively, consider subclassing MappingSqlQuery from the Spring.Data.Object namespace: Instead of working with separate AdoTemplate and RowMapper objects, you can have executable query objects (containing row-mapping logic) there.
Features rollback-only support transactions. Can expire after a certain number of seconds or milliseconds, to determine transactional timeouts.
Rounds up eagerly, e.g. '9.00001' to '10'.
Supposed to unbind resources from
Supposed to rebind resources from
Can e.g. perform resource cleanup.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
Note that exceptions will get propagated to the commit or rollback caller, although they will not influence the outcome of the transaction.
Supposed to unbind resources from
Supposed to unbind resources from
Can flush transactional sessions to the database.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
Can e.g. perform resource cleanup.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
Note that exceptions will get propagated to the commit or rollback caller, although they will not influence the outcome of the transaction.
Supposed to unbind resources from
Supposed to unbind resources from
Can e.g. perform resource cleanup.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
Note that exceptions will get propagated to the commit or rollback caller, although they will not influence the outcome of the transaction.
Implementations can be generic (for example, ADO.NET Exceptions) or proprietary (for example, using SQL Server or Oracle error codes) for greater precision.
null to indicate that no exception match has been found and that
fallback translation should kick in.
null.
The error code extracted from the generic data access exception for
a particular provider.
The exception thrown from a data access operation.
public PrintGroupMappingDataSet FindAll()
{
PrintGroupMappingTableAdapter adapter = new PrintGroupMappingTableAdapter();
PrintGroupMappingDataSet printGroupMappingDataSet = new PrintGroupMappingDataSet();
printGroupMappingDataSet = AdoTemplate.Execute(delegate(IDbCommand command)
{
TypedDataSetUtils.ApplyConnectionAndTx(adapter, command);
adapter.Fill(printGroupMappingDataSet.PrintGroupMapping);
return printGroupMappingDataSet;
})
as PrintGroupMappingDataSet;
return printGroupMappingDataSet;
}
See http://www.code-magazine.com/articleprint.aspx?quickid=0605031 for a
more complete discussion.
Allows you to execute any number of operations on a single IDbCommand, for example a single ExecuteScalar call or repeated execute calls with varying parameters.
Used internally by AdoTemplate, but also useful for application code. Note that the passed in IDbCommand has been created by the framework and will have its Connection property set and the Transaction property set based on the transaction context.
For example, this callback can be used to set the AcceptChangesDuringFill property, register an event handler for the FillErrors event, set update batch sizes if your provider supports such functionality, set the ContinueUpdateOnError property, or in .NET 2.0 to set the property AcceptChangesDuringUpdate.
Downcast to the appropriate subtype to access vendor specific functionality.
The DataAdapter SelectCommand will be already be populated with values for CommandType and Text properties along with Connection/Transaction properties based on the calling transaction context.
The methods let you set various properties and invoke methods on the DataSet before and after it gets filled by a DataAdapter. For example, EnforceConstraints, BeginLoadData, and EndLoadData can be called to optimize the loading of large DataSets with many related tables.
Vendors may expose other propriety methods on their DataSet implementation, downcast to access this specific functionality.
proxy-target-type' attribute
order' property/attribute
<tx:advice> tag.
NamespaceParser allowing for the configuration of
declarative transaction management using either XML or using attributes.
This namespace handler is the central piece of functionality in the
Spring transaction management facilities and offers two appraoches
to declaratively manage transactions.
One approach uses transaction semantics defined in XML using the
<tx:advice> elements, the other uses attributes
in combination with the <tx:annotation-driven> element.
Both approached are detailed in the Spring reference manual.
advice' and
'attribute-driven' tags.
The default fallback policy applied by this class is:
Defaults to using class's transaction attribute if none is associated with the target method. Any transaction attribute associated with the target method completely overrides a class transaction attribute.
This implementation caches attributes by method after they are first used. If it's ever desirable to allow dynamic changing of transaction attributes (unlikely) caching could be made configurable. Caching is desirable because of the cost of evaluating rollback rules.
Implementations know how to source transaction attributes, whether from configuration, metadata attributes at source level, or anywhere else.
This is an
Must be implemented by a derived class in order to specify matching rules.
Base class for both
Note that isolation level, timeout and read-only settings will only
get applied when starting a new transaction. As only
Only makes sense in combination with
Note that a transaction manager that does not support custom isolation levels
will throw an exception when given any other level than
Must return a number of seconds, or -1.
Only makes sense in combination with
This just serves as hint for the actual transaction subsystem, it will not necessarily cause failure of write accesses.
Only makes sense in combination with
A transaction manager that cannot interpret the read-only hint
will not throw an exception when given
Only makes sense in combination with
Note that a transaction manager that does not support custom isolation levels
will throw an exception when given any other level than
Must return a number of seconds, or -1.
Only makes sense in combination with
This just serves as hint for the actual transaction subsystem, it will not necessarily cause failure of write accesses.
Only makes sense in combination with
A transaction manager that cannot interpret the read-only hint
will not throw an exception when given
The default behavior is to rollback on any exception.
Consistent with
The format matches the one used by the
Because the AOP framework caches advice calculations, this is normally
faster than just letting the
The format matches the one used by the
Only makes sense in combination with
Note that a transaction manager that does not support custom isolation levels
will throw an exception when given any other level than
Must return a number of seconds, or -1.
Only makes sense in combination with
This just serves as hint for the actual transaction subsystem, it will not necessarily cause failure of write accesses.
Only makes sense in combination with
A transaction manager that cannot interpret the read-only hint
will not throw an exception when given
The
The key values of the supplied
FQCN.methodName, Assembly.
MyNameSpace.MyClass.MyMethod, MyAssembly
Method names can end with "*" for matching multiple methods.
Multiple such rules can be applied to determine whether a transaction should commit or rollback after an exception has been thrown.
As always, the
The exception class must be
This is the preferred way to construct a
The
This enables the underlying Spring transaction infrastructure to be used to easily implement an aspect for any aspect system.
Subclasses are responsible for calling methods in this class in the correct order.
Uses the Strategy design pattern. A
A transaction aspect is serializable if its
The
Do nothing if we didn't create a transaction.
We may commit or roll back, depending on our configuration.
Internally, a
Subclasses must pass it back to method on this class, but not see its internals.
PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2
where only propagation code is required. For example:
PROPAGATION_MANDATORY,ISOLATION_DEFAULT
The tokens can be in any order. Propagation and isolation codes
must use the names of the values in the
A "+" before an exception name substring indicates that transactions should commit even if this exception is thrown; a "-" that they should roll back.
PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2
where only propagation code is required. For example:
PROPAGATION_MANDATORY,ISOLATION_DEFAULT
The tokens can be in any order. Propagation and isolation codes
must use the names of the values in the
A "+" before an exception name substring indicates that transactions should commit even if this exception is thrown; a "-" that they should roll back.
Because the AOP framework caches advice calculations, this is normally
faster than just letting the
This is an abstract class, and as such has no publicly visible constructors.
Strings must be specified in the following syntax:
FQCN.methodName=<transaction attribute string> (sans <>).
ExampleNamespace.ExampleClass.MyMethod=PROPAGATION_MANDATORY,ISOLATION_DEFAULT
This will register all overloaded methods for a given name. Does not support explicit registration of certain overloaded methods. Supports wildcard style mappings (in the form "xxx*"), e.g. "Notify*" for "Notify" and "NotifyAll".
That class contains the necessary calls into Spring.NET's underlying
transaction API: subclasses such as this are responsible for calling
superclass methods such as
Alternative to the standard AOP
This class is intended to cover the typical case of declarative transaction demarcation: namely, wrapping a (singleton) target object with a transactional proxy, proxying all the interfaces that the target implements.
Internally, a
The
The target may be any object, in which case a
If left null (the default), the AOP infrastructure works out which interfaces need proxying by analyzing the target, proxying all of the interfaces that the target object implements.
The various transaction attribute descriptors are parsed via
an instance of the
Internally, a
An example string (method name and transaction attributes) might be:
key = "myMethod", value = "PROPAGATION_REQUIRED,readOnly".
If specifying a
Note that this is just necessary if you rely on those interceptors in general.
Holds all status information that
Supports delegating savepoint-related methods to a transaction object
that implements the
Transactional code can use this to retrieve status information, and to programmatically request a rollback (instead of throwing an exception that causes an implicit rollback).
Derives from the
For transactions managed by a
Used to associate with the
For transactions managed by a
To be used with
Typically used to gather various calls to transaction-unaware low-level services into a higher-level method implementation with transaction demarcation.
null if onenull if oneTo be used with
Typically used to gather various calls to transaction-unaware low-level services into a higher-level method implementation with transaction demarcation.
Resource management code should check for thread-bound resources via GetResource(). It is normally not supposed to bind resources to threads, as this is the responsiblity of transaction managers. A further option is to lazily bind on first use if transaction synchronization is active, for performing transactions that span an arbitrary number of resources.
Transaction synchronization must be activated and deactivated by a transaction
manager via
Resource management code should only register synchronizations when this manager is active, and perform resource cleanup immediately else. If transaction synchronization isn't active, there is either no current transaction, or the transaction manager doesn't support synchronizations.
Note that this class uses following naming convention for the named 'data slots' for storage of thread local data, 'Spring.Transaction:Name' where Name is eitherNote that transaction synchronizations receive the read-only flag
as argument for the beforeCommit callback, to be able
to suppress change detection on commit. The present method is meant
to be used for earlier read-only checks, for example to set the
flush mode of a Hibernate Session to FlushMode.Never upfront.
The central methods are
Can be used within a service implementation via direct instantiation with a transaction manager reference, or get prepared in an application context and given to services as object reference.
Supports setting the propagation behavior and the isolation level by name, for convenient configuration in context definitions.
Mainly targeted at configuration by an object factory.
Mainly targeted at configuration by an object factory.
null if one
null if one
Analogous to System.EnterpriseServices.TransactionOption value of the same name. This is typically the default setting of a transaction definition.
Analogous to System.EnterpriseServices.TransactionOption.Supported.
No corresponding System.EnterpriseServices.TransactionOption value.
Analogous to System.EnterpriseServices.TransactionOption value of the same name.
Analogous to System.EnterpriseServices.TransactionOption value of the same name.
Analogous to System.EnterpriseServices.TransactionOption.Disabled.
There is no analogous feature in TransactionOption.