use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method complex1.
@Test
public void complex1() {
// related to #584795
QSurvey survey = new QSurvey("survey");
QEmployee emp1 = new QEmployee("emp1");
QEmployee emp2 = new QEmployee("emp2");
SQLInsertClause insert = insert(survey);
insert.columns(survey.id, survey.name);
insert.select(select(survey.id, emp2.firstname).from(survey).innerJoin(emp1).on(survey.id.eq(emp1.id)).innerJoin(emp2).on(emp1.superiorId.eq(emp2.superiorId), emp1.firstname.eq(emp2.firstname)));
assertEquals(0, insert.execute());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_with_keys_listener.
@Test
@ExcludeIn({ CUBRID, SQLSERVER })
public void insert_with_keys_listener() throws SQLException {
final AtomicBoolean result = new AtomicBoolean();
SQLListener listener = new SQLBaseListener() {
@Override
public void end(SQLListenerContext context) {
result.set(true);
}
};
SQLInsertClause clause = insert(survey).set(survey.name, "Hello World");
clause.addListener(listener);
ResultSet rs = clause.executeWithKeys();
assertFalse(result.get());
assertTrue(rs.next());
assertTrue(rs.getObject(1) != null);
rs.close();
assertTrue(result.get());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method replace.
@Test
@IncludeIn(MYSQL)
@SkipForQuoted
public void replace() {
SQLInsertClause clause = mysqlReplace(survey);
clause.columns(survey.id, survey.name).values(3, "Hello");
assertEquals("replace into SURVEY (ID, NAME) values (?, ?)", clause.toString());
clause.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method like_with_escape.
@Test
public void like_with_escape() {
SQLInsertClause insert = insert(survey);
insert.set(survey.id, 5).set(survey.name, "aaa").addBatch();
insert.set(survey.id, 6).set(survey.name, "a_").addBatch();
insert.set(survey.id, 7).set(survey.name, "a%").addBatch();
assertEquals(3, insert.execute());
assertEquals(1L, query().from(survey).where(survey.name.like("a|%", '|')).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.like("a|_", '|')).fetchCount());
assertEquals(3L, query().from(survey).where(survey.name.like("a%")).fetchCount());
assertEquals(2L, query().from(survey).where(survey.name.like("a_")).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.startsWith("a_")).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.startsWith("a%")).fetchCount());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_with_subQuery_Via_Constructor.
@Test
// too slow
@ExcludeIn(FIREBIRD)
public void insert_with_subQuery_Via_Constructor() {
int count = (int) query().from(survey).fetchCount();
SQLInsertClause insert = insert(survey, query().from(survey2));
insert.set(survey.id, survey2.id.add(20));
insert.set(survey.name, survey2.name);
assertEquals(count, insert.execute());
}
Aggregations