use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method assertInsertWithAllPlaceholders.
@Test
public void assertInsertWithAllPlaceholders() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintShardingValueHelper(i, i);
Connection connection = each.getValue().getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(DatabaseTestSQL.INSERT_ORDER_WITH_ALL_PLACEHOLDERS_SQL);
preparedStatement.setInt(1, i);
preparedStatement.setInt(2, i);
preparedStatement.setString(3, "insert");
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class RoutingDatabaseOnlyWithHintForDMLTest method assertInsertWithPartialPlaceholders.
@Test
public void assertInsertWithPartialPlaceholders() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintDatabaseShardingValueHelper(i);
Connection connection = each.getValue().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(String.format(DatabaseTestSQL.INSERT_WITH_PARTIAL_PLACEHOLDERS_SQL, i, i))) {
preparedStatement.setString(1, "insert");
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class RoutingDatabaseOnlyWithHintForDMLTest method deleteWithoutAlias.
private void deleteWithoutAlias(final Map.Entry<DatabaseType, ShardingDataSource> dataSourceEntry) throws SQLException, DatabaseUnitException {
for (int i = 10; i < 30; i++) {
for (int j = 0; j < 2; j++) {
try (HintShardingValueHelper helper = new HintDatabaseShardingValueHelper(i);
Connection connection = dataSourceEntry.getValue().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.DELETE_WITHOUT_ALIAS_SQL))) {
preparedStatement.setInt(1, i * 100 + j);
preparedStatement.setInt(2, i);
preparedStatement.setString(3, "init");
assertThat(preparedStatement.executeUpdate(), is(1));
}
}
}
assertDataSet(dataSourceEntry.getValue().getConnection(), dataSourceEntry.getKey(), "delete", "init");
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method updateWithoutAlias.
private void updateWithoutAlias(final Map.Entry<DatabaseType, ShardingDataSource> dataSourceEntry) throws SQLException {
for (int i = 10; i < 30; i++) {
for (int j = 0; j < 2; j++) {
try (HintShardingValueHelper helper = new HintShardingValueHelper(i, i * 100 + j);
Connection connection = dataSourceEntry.getValue().getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.UPDATE_WITHOUT_ALIAS_SQL));
preparedStatement.setString(1, "updated");
preparedStatement.setInt(2, i * 100 + j);
preparedStatement.setInt(3, i);
assertThat(preparedStatement.executeUpdate(), is(1));
}
}
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method assertInsertWithPartialPlaceholders.
@Test
public void assertInsertWithPartialPlaceholders() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintShardingValueHelper(i, i);
Connection connection = each.getValue().getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(String.format(DatabaseTestSQL.INSERT_WITH_PARTIAL_PLACEHOLDERS_SQL, i, i));
preparedStatement.setString(1, "insert");
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
Aggregations