Search in sources :

Example 6 with SQLDeleteClause

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

the class SQLSerializerTest method noSchemaInWhere.

@Test
public void noSchemaInWhere() {
    Configuration defaultWithPrintSchema = new Configuration(new SQLTemplates(Keywords.DEFAULT, "\"", '\\', false, false));
    defaultWithPrintSchema.getTemplates().setPrintSchema(true);
    QEmployee e = QEmployee.employee;
    SQLDeleteClause delete = new SQLDeleteClause(EasyMock.createNiceMock(Connection.class), defaultWithPrintSchema, e);
    delete.where(e.id.gt(100));
    assertEquals("delete from PUBLIC.EMPLOYEE\n" + "where EMPLOYEE.ID > ?", delete.toString());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) Connection(java.sql.Connection) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 7 with SQLDeleteClause

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

the class SQLSerializerTest method schemaInWhere.

@Test
public void schemaInWhere() {
    Configuration derbyWithPrintSchema = new Configuration(DerbyTemplates.builder().printSchema().build());
    QEmployee e = QEmployee.employee;
    SQLDeleteClause delete = new SQLDeleteClause(EasyMock.createNiceMock(Connection.class), derbyWithPrintSchema, e);
    delete.where(e.id.gt(100));
    assertEquals("delete from \"PUBLIC\".EMPLOYEE\n" + "where \"PUBLIC\".EMPLOYEE.ID > ?", delete.toString());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) Connection(java.sql.Connection) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 8 with SQLDeleteClause

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

the class SQLServer2012TemplatesTest method delete_limit.

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

Example 9 with SQLDeleteClause

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

the class AbstractBaseTest method delete.

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

Example 10 with SQLDeleteClause

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

the class DeleteBase method batch_templates.

@Test
@ExcludeIn({ CUBRID, SQLITE })
public void batch_templates() throws SQLException {
    insert(survey).values(2, "A", "B").execute();
    insert(survey).values(3, "B", "C").execute();
    SQLDeleteClause delete = delete(survey);
    delete.where(survey.name.eq(Expressions.stringTemplate("'A'"))).addBatch();
    delete.where(survey.name.eq(Expressions.stringTemplate("'B'"))).addBatch();
    assertEquals(2, delete.execute());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Aggregations

SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)10 Test (org.junit.Test)9 QEmployee (com.querydsl.sql.domain.QEmployee)6 QSurvey (com.querydsl.sql.domain.QSurvey)4 Connection (java.sql.Connection)2 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)1 Param (com.querydsl.core.types.dsl.Param)1