Java Code Examples for org.apache.shardingsphere.transaction.core.TransactionType#XA
The following examples show how to use
org.apache.shardingsphere.transaction.core.TransactionType#XA .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 5 votes |
/** * process failure, XA transaction will be rollback. */ @Override @ShardingTransactionType(TransactionType.XA) @Transactional public void processFailure() { springPojoService.processFailure(); }
Example 2
Source File: ShardingSphereConnectionTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test public void assertXATransactionOperation() throws SQLException { connection = new ShardingSphereConnection(dataSourceMap, schemaContexts, TransactionType.XA); connection.setAutoCommit(false); assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.BEGIN)); connection.commit(); assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT)); connection.rollback(); assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.ROLLBACK)); }
Example 3
Source File: XAOrderService.java From shardingsphere with Apache License 2.0 | 5 votes |
/** * Execute XA with exception. * * @param count insert record count */ @Transactional @ShardingTransactionType(TransactionType.XA) public void insertFailed(final int count) { jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> { doInsert(count, preparedStatement); throw new SQLException("mock transaction failed"); }); }
Example 4
Source File: XAOrderService.java From shardingsphere with Apache License 2.0 | 5 votes |
/** * Execute XA. * * @param count insert record count * @return transaction type */ @Transactional @ShardingTransactionType(TransactionType.XA) public TransactionType insert(final int count) { return jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> { doInsert(count, preparedStatement); return TransactionTypeHolder.get(); }); }
Example 5
Source File: XAOrderService.java From shardingsphere with Apache License 2.0 | 5 votes |
/** * Execute XA with exception. * * @param count insert record count */ @Transactional @ShardingTransactionType(TransactionType.XA) public void insertFailed(final int count) { jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> { doInsert(count, preparedStatement); throw new SQLException("mock transaction failed"); }); }
Example 6
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 5 votes |
/** * process success, XA transaction will be committed. */ @Override @ShardingTransactionType(TransactionType.XA) @Transactional public void processSuccess() { springPojoService.processSuccess(); }
Example 7
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 4 votes |
/** * process failure, XA transaction will be rollback. */ @ShardingTransactionType(TransactionType.XA) @Transactional public void processFailure() { jpaCommonService.processFailure(); }
Example 8
Source File: ShardingTransactionalTestService.java From opensharding-spi-impl with Apache License 2.0 | 4 votes |
@ShardingTransactionType(TransactionType.XA) public void testChangeTransactionTypeToXA() { }
Example 9
Source File: ShardingTransactionalTestService.java From opensharding-spi-impl with Apache License 2.0 | 4 votes |
@ShardingTransactionType(TransactionType.XA) public void testChangeTransactionTypeToXA() { assertThat(TransactionTypeHolder.get(), is(TransactionType.XA)); }
Example 10
Source File: ShardingTransactionalTestService.java From opensharding-spi-impl with Apache License 2.0 | 4 votes |
@ShardingTransactionType(TransactionType.XA) public void testChangeTransactionTypeToXA() { assertThat(TransactionTypeHolder.get(), is(TransactionType.XA)); }
Example 11
Source File: ShardingTransactionalTestService.java From opensharding-spi-impl with Apache License 2.0 | 4 votes |
@ShardingTransactionType(TransactionType.XA) public void testChangeTransactionTypeToXA() { }
Example 12
Source File: XAShardingTransactionManager.java From shardingsphere with Apache License 2.0 | 4 votes |
@Override public TransactionType getTransactionType() { return TransactionType.XA; }
Example 13
Source File: ShardingTransactionManagerFixture.java From shardingsphere with Apache License 2.0 | 4 votes |
@Override public TransactionType getTransactionType() { return TransactionType.XA; }
Example 14
Source File: OtherShardingTransactionManagerFixture.java From shardingsphere with Apache License 2.0 | 4 votes |
@Override public TransactionType getTransactionType() { return TransactionType.XA; }
Example 15
Source File: JDBCDatabaseCommunicationEngine.java From shardingsphere with Apache License 2.0 | 4 votes |
private boolean isExecuteDDLInXATransaction(final SQLStatement sqlStatement) { BackendConnection connection = executeEngine.getBackendConnection(); return TransactionType.XA == connection.getTransactionType() && sqlStatement instanceof DDLStatement && ConnectionStatus.TRANSACTION == connection.getStateHandler().getStatus(); }
Example 16
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 4 votes |
/** * process success, XA transaction will be committed. */ @ShardingTransactionType(TransactionType.XA) @Transactional public void processSuccess() { jpaCommonService.processSuccess(); }
Example 17
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 4 votes |
/** * process failure, XA transaction will be rollback. */ @ShardingTransactionType(TransactionType.XA) @Transactional public void processFailure() { springPojoService.processFailure(); }
Example 18
Source File: XATransactionalService.java From opensharding-spi-impl-example with Apache License 2.0 | 4 votes |
/** * process success, XA transaction will be committed. */ @ShardingTransactionType(TransactionType.XA) @Transactional public void processSuccess() { springPojoService.processSuccess(); }
Example 19
Source File: ShardingSphereConnection.java From shardingsphere with Apache License 2.0 | 2 votes |
/** * Whether hold transaction or not. * * @return true or false */ public boolean isHoldTransaction() { return (TransactionType.LOCAL == transactionType && !getAutoCommit()) || (TransactionType.XA == transactionType && isInShardingTransaction()); }
Example 20
Source File: BackendConnection.java From shardingsphere with Apache License 2.0 | 2 votes |
/** * Whether execute SQL serial or not. * * @return true or false */ public boolean isSerialExecute() { return stateHandler.isInTransaction() && (TransactionType.LOCAL == transactionType || TransactionType.XA == transactionType); }