use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.
the class CustomTypesTest method insert_query_update.
@Test
public void insert_query_update() {
QPerson person = QPerson.person;
// insert
SQLInsertClause insert = new SQLInsertClause(connection, configuration, person);
insert.set(person.id, 10);
insert.set(person.firstname, "Bob");
insert.set(person.gender, Gender.MALE);
assertEquals(1L, insert.execute());
// query
SQLQuery<?> query = new SQLQuery<Void>(connection, configuration);
assertEquals(Gender.MALE, query.from(person).where(person.id.eq(10)).select(person.gender).fetchOne());
// update
SQLUpdateClause update = new SQLUpdateClause(connection, configuration, person);
update.set(person.gender, Gender.FEMALE);
update.set(person.firstname, "Jane");
update.where(person.id.eq(10));
update.execute();
// query
query = new SQLQuery<Void>(connection, configuration);
assertEquals(Gender.FEMALE, query.from(person).where(person.id.eq(10)).select(person.gender).fetchOne());
}
use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.
the class SerializationTest method update_where.
@Test
public void update_where() {
SQLUpdateClause updateClause = new SQLUpdateClause(connection, SQLTemplates.DEFAULT, survey);
updateClause.set(survey.id, 1);
updateClause.set(survey.name, (String) null);
updateClause.where(survey.name.eq("XXX"));
assertEquals("update SURVEY\nset ID = ?, NAME = ?\nwhere SURVEY.NAME = ?", updateClause.toString());
}
use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.
the class UpdateBase method update_with_subQuery_exists2.
@Test
public void update_with_subQuery_exists2() {
QSurvey survey1 = new QSurvey("s1");
QEmployee employee = new QEmployee("e");
SQLUpdateClause update = update(survey1);
update.set(survey1.name, "AA");
update.where(selectOne().from(employee).where(survey1.name.eq(employee.lastname)).exists());
assertEquals(0, update.execute());
}
use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.
the class UpdateBase method update_with_subQuery_exists_Params.
@Test
public void update_with_subQuery_exists_Params() {
QSurvey survey1 = new QSurvey("s1");
QEmployee employee = new QEmployee("e");
Param<Integer> param = new Param<Integer>(Integer.class, "param");
SQLQuery<?> sq = query().from(employee).where(employee.id.eq(param));
sq.set(param, -12478923);
SQLUpdateClause update = update(survey1);
update.set(survey1.name, "AA");
update.where(sq.exists());
assertEquals(0, update.execute());
}
use of com.querydsl.sql.dml.SQLUpdateClause in project querydsl by querydsl.
the class UpdateBase method update_with_subQuery_exists.
@Test
public void update_with_subQuery_exists() {
QSurvey survey1 = new QSurvey("s1");
QEmployee employee = new QEmployee("e");
SQLUpdateClause update = update(survey1);
update.set(survey1.name, "AA");
update.where(selectOne().from(employee).where(survey1.id.eq(employee.id)).exists());
assertEquals(1, update.execute());
}
Aggregations