Search in sources :

Example 11 with Pet

use of test.po.Pet in project eweb4j-framework by laiweiwei.

the class TestDb method testBatchUpdate.

public void testBatchUpdate() throws Exception {
    Pet p1 = new Pet();
    p1.setPetId(14);
    p1.setName("name up 11");
    Pet p2 = new Pet();
    p2.setPetId(15);
    p2.setName("name up 22");
    Pet p3 = new Pet();
    p3.setPetId(16);
    p3.setName("name up 33");
    Pet p4 = new Pet();
    p4.setPetId(17);
    p4.setName("name up 44");
    Number[] rs = Db.batchUpdate(new Pet[] { p1, p2, p3, p4 }, "name");
    System.out.println(Arrays.asList(rs));
}
Also used : Pet(test.po.Pet)

Example 12 with Pet

use of test.po.Pet in project eweb4j-framework by laiweiwei.

the class TestDb method testBatchInsert.

public void testBatchInsert() throws Exception {
    Pet p1 = new Pet();
    p1.setName("pet_1");
    Pet p2 = new Pet();
    p2.setName("pet_2");
    Pet p3 = new Pet();
    p3.setName("pet_3");
    Pet p4 = new Pet();
    p4.setName("pet_4");
    //		Number[] ids = DAOFactory.getInsertDAO().batchInsert(p1, p2, p3, p4);
    //		System.out.println(Arrays.asList(ids));
    Db.batchInsert(new Pet[] { p1, p2, p3, p4 }, "name");
    System.out.println(CommonUtil.toJson(Arrays.asList(p1, p2, p3, p4)));
}
Also used : Pet(test.po.Pet)

Example 13 with Pet

use of test.po.Pet in project eweb4j-framework by laiweiwei.

the class TestDb method testBatchDelete.

public void testBatchDelete() throws Exception {
    Pet p1 = new Pet();
    p1.setPetId(31L);
    Pet p2 = new Pet();
    p2.setPetId(32L);
    Pet p3 = new Pet();
    p3.setPetId(33L);
    Number[] rs = Db.batchDelete(new Pet[] { p1, p2, p3 });
    System.out.println(Arrays.asList(rs));
}
Also used : Pet(test.po.Pet)

Example 14 with Pet

use of test.po.Pet in project eweb4j-framework by laiweiwei.

the class TestDb method testShow.

public void testShow() throws Exception {
    Pet db_pet = Pet.inst.find("name = ? and createAt > ?", "testName", Timestamp.valueOf("2013-03-06 14:30:10")).first();
    db_pet = Db.ar(Pet.class).dao().selectAll().where().field("name").equal("testName").and("createAt").moreThan(Timestamp.valueOf("2013-03-06 14:30:10")).queryOne();
    System.out.println(CommonUtil.toJson(db_pet));
}
Also used : Pet(test.po.Pet)

Example 15 with Pet

use of test.po.Pet in project eweb4j-framework by laiweiwei.

the class TestDb method testInsert.

public void testInsert() throws Exception {
    Pet pet = new Pet();
    pet.setName("testName2222");
    pet.setPetId(29);
    Db.ar(pet).save();
}
Also used : Pet(test.po.Pet)

Aggregations

Pet (test.po.Pet)27 Master (test.po.Master)8 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 DAOException (org.eweb4j.orm.dao.DAOException)3 Sql (org.eweb4j.orm.sql.Sql)3 DAO (org.eweb4j.orm.dao.DAO)2 Map (java.util.Map)1 EntityManager (javax.persistence.EntityManager)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 Trans (org.eweb4j.orm.jdbc.transaction.Trans)1