1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2018 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.
@@ -108,7 +108,7 @@ public DefaultTransactionDefinition(int propagationBehavior) {
108
108
* Set the propagation behavior by the name of the corresponding constant in
109
109
* TransactionDefinition, e.g. "PROPAGATION_REQUIRED".
110
110
* @param constantName name of the constant
111
- * @exception IllegalArgumentException if the supplied value is not resolvable
111
+ * @throws IllegalArgumentException if the supplied value is not resolvable
112
112
* to one of the {@code PROPAGATION_} constants or is {@code null}
113
113
* @see #setPropagationBehavior
114
114
* @see #PROPAGATION_REQUIRED
@@ -123,8 +123,16 @@ public final void setPropagationBehaviorName(String constantName) throws Illegal
123
123
/**
124
124
* Set the propagation behavior. Must be one of the propagation constants
125
125
* in the TransactionDefinition interface. Default is PROPAGATION_REQUIRED.
126
- * @exception IllegalArgumentException if the supplied value is not
127
- * one of the {@code PROPAGATION_} constants
126
+ * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
127
+ * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
128
+ * transactions. Consider switching the "validateExistingTransactions" flag to
129
+ * "true" on your transaction manager if you'd like isolation level declarations
130
+ * to get rejected when participating in an existing transaction with a different
131
+ * isolation level.
132
+ * <p>Note that a transaction manager that does not support custom isolation levels
133
+ * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
134
+ * @throws IllegalArgumentException if the supplied value is not one of the
135
+ * {@code PROPAGATION_} constants
128
136
* @see #PROPAGATION_REQUIRED
129
137
*/
130
138
public final void setPropagationBehavior (int propagationBehavior ) {
@@ -143,7 +151,7 @@ public final int getPropagationBehavior() {
143
151
* Set the isolation level by the name of the corresponding constant in
144
152
* TransactionDefinition, e.g. "ISOLATION_DEFAULT".
145
153
* @param constantName name of the constant
146
- * @exception IllegalArgumentException if the supplied value is not resolvable
154
+ * @throws IllegalArgumentException if the supplied value is not resolvable
147
155
* to one of the {@code ISOLATION_} constants or is {@code null}
148
156
* @see #setIsolationLevel
149
157
* @see #ISOLATION_DEFAULT
@@ -158,8 +166,16 @@ public final void setIsolationLevelName(String constantName) throws IllegalArgum
158
166
/**
159
167
* Set the isolation level. Must be one of the isolation constants
160
168
* in the TransactionDefinition interface. Default is ISOLATION_DEFAULT.
161
- * @exception IllegalArgumentException if the supplied value is not
162
- * one of the {@code ISOLATION_} constants
169
+ * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
170
+ * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
171
+ * transactions. Consider switching the "validateExistingTransactions" flag to
172
+ * "true" on your transaction manager if you'd like isolation level declarations
173
+ * to get rejected when participating in an existing transaction with a different
174
+ * isolation level.
175
+ * <p>Note that a transaction manager that does not support custom isolation levels
176
+ * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
177
+ * @throws IllegalArgumentException if the supplied value is not one of the
178
+ * {@code ISOLATION_} constants
163
179
* @see #ISOLATION_DEFAULT
164
180
*/
165
181
public final void setIsolationLevel (int isolationLevel ) {
@@ -177,6 +193,11 @@ public final int getIsolationLevel() {
177
193
/**
178
194
* Set the timeout to apply, as number of seconds.
179
195
* Default is TIMEOUT_DEFAULT (-1).
196
+ * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
197
+ * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
198
+ * transactions.
199
+ * <p>Note that a transaction manager that does not support timeouts will throw
200
+ * an exception when given any other timeout than {@link #TIMEOUT_DEFAULT}.
180
201
* @see #TIMEOUT_DEFAULT
181
202
*/
182
203
public final void setTimeout (int timeout ) {
@@ -194,6 +215,16 @@ public final int getTimeout() {
194
215
/**
195
216
* Set whether to optimize as read-only transaction.
196
217
* Default is "false".
218
+ * <p>The read-only flag applies to any transaction context, whether backed
219
+ * by an actual resource transaction ({@link #PROPAGATION_REQUIRED}/
220
+ * {@link #PROPAGATION_REQUIRES_NEW}) or operating non-transactionally at
221
+ * the resource level ({@link #PROPAGATION_SUPPORTS}). In the latter case,
222
+ * the flag will only apply to managed resources within the application,
223
+ * such as a Hibernate {@code Session}.
224
+ * <p>This just serves as a hint for the actual transaction subsystem;
225
+ * it will <i>not necessarily</i> cause failure of write access attempts.
226
+ * A transaction manager which cannot interpret the read-only hint will
227
+ * <i>not</i> throw an exception when asked for a read-only transaction.
197
228
*/
198
229
public final void setReadOnly (boolean readOnly ) {
199
230
this .readOnly = readOnly ;
0 commit comments