use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class MergeBase method mergeBatch.
@Test
@IncludeIn(H2)
public void mergeBatch() {
SQLMergeClause merge = merge(survey).keys(survey.id).set(survey.id, 5).set(survey.name, "5").addBatch();
assertEquals(1, merge.getBatchCount());
assertFalse(merge.isEmpty());
merge.keys(survey.id).set(survey.id, 6).set(survey.name, "6").addBatch();
assertEquals(2, merge.getBatchCount());
assertEquals(2, merge.execute());
assertEquals(1L, query().from(survey).where(survey.name.eq("5")).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.eq("6")).fetchCount());
}
use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class MergeBase method merge_with_templateExpression_in_batch.
@Test
@IncludeIn(H2)
public void merge_with_templateExpression_in_batch() {
SQLMergeClause merge = merge(survey).keys(survey.id).set(survey.id, 5).set(survey.name, Expressions.stringTemplate("'5'")).addBatch();
assertEquals(1, merge.execute());
}
use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class MergeBase method mergeBatch_with_subquery.
@Test
@IncludeIn(H2)
public void mergeBatch_with_subquery() {
SQLMergeClause merge = merge(survey).keys(survey.id).columns(survey.id, survey.name).select(query().from(survey2).select(survey2.id.add(20), survey2.name)).addBatch();
merge(survey).keys(survey.id).columns(survey.id, survey.name).select(query().from(survey2).select(survey2.id.add(40), survey2.name)).addBatch();
assertEquals(1, merge.execute());
}
use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class AbstractBaseTest method merge.
protected SQLMergeClause merge(RelationalPath<?> e) {
SQLMergeClause sqlMergeClause = new SQLMergeClause(connection, configuration, e);
sqlMergeClause.addListener(new TestLoggingListener());
return sqlMergeClause;
}
use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class MergeBase method merge_with_keys_listener.
@Test
@ExcludeIn({ H2, CUBRID, SQLSERVER })
public void merge_with_keys_listener() throws SQLException {
final AtomicBoolean result = new AtomicBoolean();
SQLListener listener = new SQLBaseListener() {
@Override
public void end(SQLListenerContext context) {
result.set(true);
}
};
SQLMergeClause clause = merge(survey).keys(survey.id).set(survey.id, 7).set(survey.name, "Hello World");
clause.addListener(listener);
ResultSet rs = clause.executeWithKeys();
assertTrue(rs.next());
assertTrue(rs.getObject(1) != null);
rs.close();
assertTrue(result.get());
}
Aggregations