Search in sources :

Example 6 with SQLUpdateClause

use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.

the class UpdateBase method update_with_subQuery_notExists.

@Test
public void update_with_subQuery_notExists() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(query().from(employee).where(survey1.id.eq(employee.id)).notExists());
    assertEquals(0, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 7 with SQLUpdateClause

use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.

the class AbstractBaseTest method update.

protected SQLUpdateClause update(RelationalPath<?> e) {
    SQLUpdateClause sqlUpdateClause = new SQLUpdateClause(connection, configuration, e);
    sqlUpdateClause.addListener(new TestLoggingListener());
    return sqlUpdateClause;
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause)

Example 8 with SQLUpdateClause

use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.

the class SerializationTest method update.

@Test
public void update() {
    SQLUpdateClause updateClause = new SQLUpdateClause(connection, SQLTemplates.DEFAULT, survey);
    updateClause.set(survey.id, 1);
    updateClause.set(survey.name, (String) null);
    assertEquals("update SURVEY\nset ID = ?, NAME = ?", updateClause.toString());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) Test(org.junit.Test)

Example 9 with SQLUpdateClause

use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.

the class SQLServer2012TemplatesTest method update_limit.

@Test
public void update_limit() {
    SQLUpdateClause clause = new SQLUpdateClause(null, createTemplates(), survey1);
    clause.set(survey1.name, "Bob");
    clause.limit(5);
    assertEquals("update top 5 SURVEY\n" + "set NAME = ?", clause.toString());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) Test(org.junit.Test)

Example 10 with SQLUpdateClause

use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.

the class UpdateBase method batch.

@Test
public void batch() throws SQLException {
    assertEquals(1, insert(survey).values(2, "A", "B").execute());
    assertEquals(1, insert(survey).values(3, "B", "C").execute());
    SQLUpdateClause update = update(survey);
    update.set(survey.name, "AA").where(survey.name.eq("A")).addBatch();
    assertEquals(1, update.getBatchCount());
    update.set(survey.name, "BB").where(survey.name.eq("B")).addBatch();
    assertEquals(2, update.getBatchCount());
    assertEquals(2, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) Test(org.junit.Test)

Aggregations

SQLUpdateClause (com.querydsl.sql.dml.SQLUpdateClause)11 Test (org.junit.Test)10 QEmployee (com.querydsl.sql.domain.QEmployee)4 QSurvey (com.querydsl.sql.domain.QSurvey)4 Param (com.querydsl.core.types.dsl.Param)1 SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)1