use of com.querydsl.sql.dml.SQLMergeClause in project querydsl by querydsl.
the class MergeBase method mergeBatch_templates.
@Test
@IncludeIn(H2)
public void mergeBatch_templates() {
SQLMergeClause merge = merge(survey).keys(survey.id).set(survey.id, 5).set(survey.name, Expressions.stringTemplate("'5'")).addBatch();
merge.keys(survey.id).set(survey.id, 6).set(survey.name, Expressions.stringTemplate("'6'")).addBatch();
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_listener.
@Test
public void merge_listener() {
final AtomicInteger calls = new AtomicInteger(0);
SQLListener listener = new SQLBaseListener() {
@Override
public void end(SQLListenerContext context) {
if (context.getData(AbstractSQLQuery.PARENT_CONTEXT) == null) {
calls.incrementAndGet();
}
}
};
SQLMergeClause clause = merge(survey).keys(survey.id).set(survey.id, 5).set(survey.name, "Hello World");
clause.addListener(listener);
assertEquals(1, clause.execute());
assertEquals(1, calls.intValue());
}
Aggregations