use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method deleteWithoutAlias.
private void deleteWithoutAlias(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.DELETE_WITHOUT_ALIAS_SQL));
preparedStatement.setInt(1, i * 100 + j);
preparedStatement.setInt(2, i);
preparedStatement.setString(3, "init");
assertThat(preparedStatement.executeUpdate(), is(1));
}
}
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForSelectTest method assertSelectBetweenWithSingleTable.
@Test
public void assertSelectBetweenWithSingleTable() throws SQLException, DatabaseUnitException {
String sql = SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.SELECT_BETWEEN_WITH_SINGLE_TABLE_SQL);
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectBetweenWithSingleTable.xml", new HintShardingValueHelper(Lists.newArrayList(10, 12), ShardingOperator.BETWEEN, Lists.newArrayList(1001, 1200), ShardingOperator.BETWEEN), each.getValue().getConnection(), sql, each.getKey(), 10, 12, 1001, 1200);
assertDataSet("integrate/dataset/Empty.xml", new HintShardingValueHelper(Lists.newArrayList(10, 12), ShardingOperator.BETWEEN, Lists.newArrayList(1309, 1408), ShardingOperator.BETWEEN), each.getValue().getConnection(), sql, each.getKey(), 10, 12, 1309, 1408);
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForSelectTest method assertSelectEqualsWithSingleTable.
@Test
public void assertSelectEqualsWithSingleTable() throws SQLException, DatabaseUnitException {
String sql = SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.SELECT_EQUALS_WITH_SINGLE_TABLE_SQL);
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectEqualsWithSingleTable_0.xml", new HintShardingValueHelper(10, 1000), each.getValue().getConnection(), sql, each.getKey(), 10, 1000);
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectEqualsWithSingleTable_1.xml", new HintShardingValueHelper(12, 1201), each.getValue().getConnection(), sql, each.getKey(), 12, 1201);
assertDataSet("integrate/dataset/Empty.xml", new HintShardingValueHelper(12, 1000), each.getValue().getConnection(), sql, each.getKey(), 12, 1000);
}
}
use of io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForSelectTest method assertSelectInWithSingleTable.
@Test
public void assertSelectInWithSingleTable() throws SQLException, DatabaseUnitException {
String sql = SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.SELECT_IN_WITH_SINGLE_TABLE_SQL);
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectInWithSingleTable_0.xml", new HintShardingValueHelper(Lists.newArrayList(10, 12, 15), ShardingOperator.IN, Lists.newArrayList(1000, 1201), ShardingOperator.IN), each.getValue().getConnection(), sql, each.getKey(), 10, 12, 15, 1000, 1201);
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectInWithSingleTable_1.xml", new HintShardingValueHelper(Lists.newArrayList(10, 12, 15), ShardingOperator.IN, Lists.newArrayList(1000, 1101), ShardingOperator.IN), each.getValue().getConnection(), sql, each.getKey(), 10, 12, 15, 1000, 1101);
assertDataSet("integrate/dataset/Empty.xml", new HintShardingValueHelper(Lists.newArrayList(10, 12, 15), ShardingOperator.IN, Lists.newArrayList(1309, 1408), ShardingOperator.IN), each.getValue().getConnection(), sql, each.getKey(), 10, 12, 15, 1309, 1408);
}
}
Aggregations