Search in sources :

Example 11 with Girl

use of jodd.db.oom.tst.Girl in project jodd by oblac.

the class DbEntitySqlTest method testDelete.

@Test
public void testDelete() {
    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.delete(g);
    assertEquals("delete from GIRL where (GIRL.ID=:girl.id and GIRL.NAME=:girl.name and GIRL.SPECIALITY=:girl.speciality)", b.generateQuery());
    checkGirl(b);
    BadGirl bg = new BadGirl(Integer.valueOf(2), null, ".net");
    b = DbEntitySql.delete(bg);
    assertEquals("delete from GIRL where (GIRL.ID=:badGirl.fooid and GIRL.SPECIALITY=:badGirl.foospeciality)", b.generateQuery());
    checkBadGirl1(b);
    b = DbEntitySql.deleteByAll(bg);
    assertEquals("delete from GIRL where (GIRL.ID=:badGirl.fooid and GIRL.NAME=:badGirl.fooname and GIRL.SPECIALITY=:badGirl.foospeciality)", b.generateQuery());
    checkBadGirl2(b);
    b = DbEntitySql.deleteById(bg);
    assertEquals("delete from GIRL where (GIRL.ID=:badGirl.fooid)", b.generateQuery());
    checkBadGirl3(b);
    b = DbEntitySql.deleteById(bg, 2);
    assertEquals("delete from GIRL where GIRL.ID=:p0", b.generateQuery());
    checkBadGirl4(b);
}
Also used : BadGirl(jodd.db.oom.tst.BadGirl) BadGirl(jodd.db.oom.tst.BadGirl) Girl(jodd.db.oom.tst.Girl) Test(org.junit.Test)

Example 12 with Girl

use of jodd.db.oom.tst.Girl in project jodd by oblac.

the class DbEntitySqlTest method testTruncate.

@Test
public void testTruncate() {
    Girl g = new Girl(1, "sanja", "c++");
    assertEquals("delete from GIRL", DbEntitySql.truncate(g).generateQuery());
    assertEquals("delete from GIRL", DbEntitySql.truncate(Girl.class).generateQuery());
}
Also used : BadGirl(jodd.db.oom.tst.BadGirl) Girl(jodd.db.oom.tst.Girl) Test(org.junit.Test)

Aggregations

Girl (jodd.db.oom.tst.Girl)12 Test (org.junit.Test)12 BadGirl (jodd.db.oom.tst.BadGirl)8 DbSession (jodd.db.DbSession)3 DbThreadSession (jodd.db.DbThreadSession)3 DbSqlBuilder (jodd.db.oom.sqlgen.DbSqlBuilder)2 BadBoy (jodd.db.oom.tst.BadBoy)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 DbQuery (jodd.db.DbQuery)1 ParameterValue (jodd.db.oom.sqlgen.ParameterValue)1 Boy2 (jodd.db.oom.tst.Boy2)1 Girl2 (jodd.db.oom.tst.Girl2)1 IdName (jodd.db.oom.tst.IdName)1