use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_dates.
@Test
// https://bitbucket.org/xerial/sqlite-jdbc/issue/133/prepstmtsetdate-int-date-calendar-seems
@ExcludeIn({ CUBRID, SQLITE })
public void insert_dates() {
QDateTest dateTest = QDateTest.qDateTest;
LocalDate localDate = new LocalDate(1978, 1, 2);
Path<LocalDate> localDateProperty = ExpressionUtils.path(LocalDate.class, "DATE_TEST");
Path<DateTime> dateTimeProperty = ExpressionUtils.path(DateTime.class, "DATE_TEST");
SQLInsertClause insert = insert(dateTest);
insert.set(localDateProperty, localDate);
insert.execute();
Tuple result = query().from(dateTest).select(dateTest.dateTest.year(), dateTest.dateTest.month(), dateTest.dateTest.dayOfMonth(), dateTimeProperty).fetchFirst();
assertEquals(Integer.valueOf(1978), result.get(0, Integer.class));
assertEquals(Integer.valueOf(1), result.get(1, Integer.class));
assertEquals(Integer.valueOf(2), result.get(2, Integer.class));
DateTime dateTime = result.get(dateTimeProperty);
if (target == CUBRID) {
// XXX Cubrid adds random milliseconds for some reason
dateTime = dateTime.withMillisOfSecond(0);
}
assertEquals(localDate.toDateTimeAtStartOfDay(), dateTime);
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_nulls_in_batch.
@Test
@ExcludeIn(ORACLE)
public void insert_nulls_in_batch() {
// QFoo f= QFoo.foo;
// SQLInsertClause sic = new SQLInsertClause(c, new H2Templates(), f);
// sic.columns(f.c1,f.c2).values(null,null).addBatch();
// sic.columns(f.c1,f.c2).values(null,1).addBatch();
// sic.execute();
SQLInsertClause sic = insert(survey);
sic.columns(survey.name, survey.name2).values(null, null).addBatch();
sic.columns(survey.name, survey.name2).values(null, "X").addBatch();
assertEquals(2, sic.execute());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_batch_Templates.
@Test
public void insert_batch_Templates() {
SQLInsertClause insert = insert(survey).set(survey.id, 5).set(survey.name, Expressions.stringTemplate("'55'")).addBatch();
insert.set(survey.id, 6).set(survey.name, Expressions.stringTemplate("'66'")).addBatch();
assertEquals(2, insert.execute());
assertEquals(1L, query().from(survey).where(survey.name.eq("55")).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.eq("66")).fetchCount());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_nulls_in_batch2.
@Test
@Ignore
@ExcludeIn({ DERBY })
public void insert_nulls_in_batch2() {
Mapper<Object> mapper = DefaultMapper.WITH_NULL_BINDINGS;
// QFoo f= QFoo.foo;
// SQLInsertClause sic = new SQLInsertClause(c, new H2Templates(), f);
// Foo f1=new Foo();
// sic.populate(f1).addBatch();
// f1=new Foo();
// f1.setC1(1);
// sic.populate(f1).addBatch();
// sic.execute();
QEmployee employee = QEmployee.employee;
SQLInsertClause sic = insert(employee);
Employee e = new Employee();
sic.populate(e, mapper).addBatch();
e = new Employee();
e.setFirstname("X");
sic.populate(e, mapper).addBatch();
assertEquals(0, sic.execute());
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class InsertBase method insert_batch_to_bulk.
@Test
public void insert_batch_to_bulk() {
SQLInsertClause insert = insert(survey);
insert.setBatchToBulk(true);
insert.set(survey.id, 5).set(survey.name, "55").addBatch();
assertEquals(1, insert.getBatchCount());
insert.set(survey.id, 6).set(survey.name, "66").addBatch();
assertEquals(2, insert.getBatchCount());
assertEquals(2, insert.execute());
assertEquals(1L, query().from(survey).where(survey.name.eq("55")).fetchCount());
assertEquals(1L, query().from(survey).where(survey.name.eq("66")).fetchCount());
}
Aggregations