Skip to content

Instantly share code, notes, and snippets.

@hoangnt-2197
Created September 19, 2021 14:11
Show Gist options
  • Save hoangnt-2197/72403a657e0b2abb704010d468ff9e9c to your computer and use it in GitHub Desktop.
Save hoangnt-2197/72403a657e0b2abb704010d468ff9e9c to your computer and use it in GitHub Desktop.
public class TransactionRoutingDataSource
extends AbstractRoutingDataSource {
@Nullable
@Override
protected Object determineCurrentLookupKey() {
return TransactionSynchronizationManager
.isCurrentTransactionReadOnly() ?
DataSourceType.READ_ONLY :
DataSourceType.READ_WRITE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment