Search in sources :

Example 1 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.<Connection>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 2 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.<Connection>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 3 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 4 with SQLDeleteClause

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

the class SerializationTest method delete_with_subQuery_exists.

@Test
public void delete_with_subQuery_exists() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLDeleteClause delete = new SQLDeleteClause(connection, SQLTemplates.DEFAULT, survey1);
    delete.where(survey1.name.eq("XXX"), selectOne().from(employee).where(survey1.id.eq(employee.id)).exists());
    assertEquals("delete from SURVEY\n" + "where SURVEY.NAME = ? and exists (select 1\n" + "from EMPLOYEE e\n" + "where SURVEY.ID = e.ID)", delete.toString());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 5 with SQLDeleteClause

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

the class DeleteBase method delete_with_subQuery_exists2.

@Test
public void delete_with_subQuery_exists2() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLDeleteClause delete = delete(survey1);
    delete.where(survey1.name.eq("XXX"), query().from(employee).where(survey1.name.eq(employee.lastname)).exists());
    assertEquals(0, delete.execute());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

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