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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations