mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
test insert in hibernate
This commit is contained in:
parent
42f2846740
commit
a1df2054df
@ -32,6 +32,7 @@ import com.querydsl.jpa.domain.Cat;
|
||||
import com.querydsl.jpa.domain.QCat;
|
||||
import com.querydsl.jpa.hibernate.HibernateDeleteClause;
|
||||
import com.querydsl.jpa.hibernate.HibernateQuery;
|
||||
import com.querydsl.jpa.hibernate.HibernateInsertClause;
|
||||
import com.querydsl.jpa.hibernate.HibernateUpdateClause;
|
||||
import com.querydsl.jpa.hibernate.HibernateUtil;
|
||||
import com.querydsl.jpa.testutil.HibernateTestRunner;
|
||||
@ -98,6 +99,11 @@ public class IntegrationBase extends ParsingTest implements HibernateTest {
|
||||
return new HibernateUpdateClause(session, entity);
|
||||
}
|
||||
|
||||
private HibernateInsertClause insert(EntityPath<?> entity) {
|
||||
return new HibernateInsertClause(session, entity);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void scroll() {
|
||||
session.save(new Cat("Bob",10));
|
||||
@ -112,6 +118,20 @@ public class IntegrationBase extends ParsingTest implements HibernateTest {
|
||||
results.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insert() {
|
||||
session.save(new Cat("Bob",10));
|
||||
|
||||
QCat cat = QCat.cat;
|
||||
long amount = insert(cat)
|
||||
.set(cat.name, "Bobby")
|
||||
.set(cat.alive, false)
|
||||
.execute();
|
||||
assertEquals(1, amount);
|
||||
|
||||
assertEquals(1L, query().from(cat).where(cat.name.eq("Bobby")).fetchCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update() {
|
||||
session.save(new Cat("Bob",10));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user