|
1 | 1 | /* |
2 | | - * Copyright 2002-2015 the original author or authors. |
| 2 | + * Copyright 2002-2016 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
28 | 28 | import org.springframework.transaction.support.DefaultTransactionStatus; |
29 | 29 | import org.springframework.transaction.support.ResourceTransactionManager; |
30 | 30 | import org.springframework.transaction.support.TransactionSynchronizationManager; |
| 31 | +import org.springframework.transaction.support.TransactionSynchronizationUtils; |
31 | 32 |
|
32 | 33 | /** |
33 | 34 | * {@link org.springframework.transaction.PlatformTransactionManager} |
|
47 | 48 | * |
48 | 49 | * <p>Application code is required to retrieve the JDBC Connection via |
49 | 50 | * {@link DataSourceUtils#getConnection(DataSource)} instead of a standard |
50 | | - * J2EE-style {@link DataSource#getConnection()} call. Spring classes such as |
| 51 | + * Java EE-style {@link DataSource#getConnection()} call. Spring classes such as |
51 | 52 | * {@link org.springframework.jdbc.core.JdbcTemplate} use this strategy implicitly. |
52 | 53 | * If not used in combination with this transaction manager, the |
53 | 54 | * {@link DataSourceUtils} lookup strategy behaves exactly like the native |
54 | 55 | * DataSource lookup; it can thus be used in a portable fashion. |
55 | 56 | * |
56 | 57 | * <p>Alternatively, you can allow application code to work with the standard |
57 | | - * J2EE-style lookup pattern {@link DataSource#getConnection()}, for example for |
| 58 | + * Java EE-style lookup pattern {@link DataSource#getConnection()}, for example for |
58 | 59 | * legacy code that is not aware of Spring at all. In that case, define a |
59 | 60 | * {@link TransactionAwareDataSourceProxy} for your target DataSource, and pass |
60 | 61 | * that proxy DataSource to your DAOs, which will automatically participate in |
|
87 | 88 | * DBCP connection pool). Switching between this local strategy and a JTA |
88 | 89 | * environment is just a matter of configuration! |
89 | 90 | * |
| 91 | + * <p>As of 4.3.4, this transaction manager triggers flush callbacks on registered |
| 92 | + * transaction synchronizations (if synchronization is generally active), assuming |
| 93 | + * resources operating on the underlying JDBC {@code Connection}. This allows for |
| 94 | + * setup analogous to {@code JtaTransactionManager}, in particular with respect to |
| 95 | + * lazily registered ORM resources (e.g. a Hibernate {@code Session}). |
| 96 | + * |
90 | 97 | * @author Juergen Hoeller |
91 | 98 | * @since 02.05.2003 |
92 | 99 | * @see #setNestedTransactionAllowed |
@@ -368,6 +375,13 @@ public void setRollbackOnly() { |
368 | 375 | public boolean isRollbackOnly() { |
369 | 376 | return getConnectionHolder().isRollbackOnly(); |
370 | 377 | } |
| 378 | + |
| 379 | + @Override |
| 380 | + public void flush() { |
| 381 | + if (TransactionSynchronizationManager.isSynchronizationActive()) { |
| 382 | + TransactionSynchronizationUtils.triggerFlush(); |
| 383 | + } |
| 384 | + } |
371 | 385 | } |
372 | 386 |
|
373 | 387 | } |
0 commit comments