-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensible transaction definition #159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the expected use for a custom driver with unique transaction requirements to create our own version of TransactionDefinition
, and not to reuse IsolationLevel
?
@@ -70,6 +70,18 @@ public static IsolationLevel valueOf(String sql) { | |||
return CONSTANTS.valueOf(sql, false); | |||
} | |||
|
|||
@Override | |||
public <T> T getAttribute(String name, Class<T> type) { | |||
Assert.requireNonNull(name, "sql must not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/sql/name
I'm not exactly sure about this. From the perspective of how one works with a driver, they basically don't want to touch driver-specific API in their client library. So a client library would provide a From a driver perspective, it could make sense to provide a |
The revised proposal changes are now available in this PR. The API surface is reduced to a callback interface for |
TransactionDefinition exposes transaction attributes to be applied when starting a new transaction. Its interface form allows for vendor-specific extensions to apply properties that apply to individual databases.
Reuse Option constants as attribute identifiers. Remove getIsolationLevel and isReadOnly methods. Introduce constants for commonly used attributes. Add specification.
e271b5f
to
e42efbd
Compare
We now expose a
Connection.beginTransaction
method accepting aTransactionDefinition
that can report various transaction attributes. Drivers can choose to provide a vendor-specific extension to specify attributes that apply to their database.Transaction attributes are optional and expected to be set when starting a transaction when one or more attribute is configured. The callback mechanism allows for a simplified extension model so a library can provide a generic
TransactionDefinition
implementation that is configured with attributes required for a database without the need to depend on vendor-specific classes.Todo: