Search in sources :

Example 81 with Pkfields

use of mbg.test.mb3.generated.annotated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKFieldsCountByExample.

@Test
public void testPKFieldsCountByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Bob");
        record.setLastname("Jones");
        record.setId1(3);
        record.setId2(4);
        mapper.insert(record);
        PkfieldsExample example = new PkfieldsExample();
        example.createCriteria().andLastnameLike("J%");
        long rows = mapper.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = mapper.countByExample(example);
        assertEquals(2, rows);
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.annotated.flat.model.PkfieldsExample) Test(org.junit.Test)

Example 82 with Pkfields

use of mbg.test.mb3.generated.annotated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testEquals1.

@Test
public void testEquals1() {
    Pkfields pkfields1 = new Pkfields();
    assertFalse(pkfields1.equals(null));
}
Also used : Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Test(org.junit.Test)

Example 83 with Pkfields

use of mbg.test.mb3.generated.annotated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKFieldsInsert.

@Test
public void testPKFieldsInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setDatefield(new Date());
        record.setDecimal100field(10L);
        record.setDecimal155field(new BigDecimal("15.12345"));
        record.setDecimal30field((short) 3);
        record.setDecimal60field(6);
        record.setFirstname("Jeff");
        record.setId1(1);
        record.setId2(2);
        record.setLastname("Butler");
        record.setTimefield(new Date());
        record.setTimestampfield(new Date());
        record.setStringboolean(true);
        mapper.insert(record);
        Pkfields returnedRecord = mapper.selectByPrimaryKey(2, 1);
        assertNotNull(returnedRecord);
        assertTrue(datesAreEqual(record.getDatefield(), returnedRecord.getDatefield()));
        assertEquals(record.getDecimal100field(), returnedRecord.getDecimal100field());
        assertEquals(record.getDecimal155field(), returnedRecord.getDecimal155field());
        assertEquals(record.getDecimal30field(), returnedRecord.getDecimal30field());
        assertEquals(record.getDecimal60field(), returnedRecord.getDecimal60field());
        assertEquals(record.getFirstname(), returnedRecord.getFirstname());
        assertEquals(record.getId1(), returnedRecord.getId1());
        assertEquals(record.getId2(), returnedRecord.getId2());
        assertEquals(record.getLastname(), returnedRecord.getLastname());
        assertTrue(timesAreEqual(record.getTimefield(), returnedRecord.getTimefield()));
        assertEquals(record.getTimestampfield(), returnedRecord.getTimestampfield());
        assertEquals(record.isStringboolean(), returnedRecord.isStringboolean());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 84 with Pkfields

use of mbg.test.mb3.generated.annotated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testEquals4.

@Test
public void testEquals4() {
    Pkfields pkfields1 = new Pkfields();
    pkfields1.setId1(2);
    Pkfields pkfields2 = new Pkfields();
    pkfields2.setId1(3);
    assertFalse(pkfields1.equals(pkfields2));
}
Also used : Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Test(org.junit.Test)

Example 85 with Pkfields

use of mbg.test.mb3.generated.annotated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testEquals3.

@Test
public void testEquals3() {
    Pkfields pkfields1 = new Pkfields();
    pkfields1.setId1(2);
    Pkfields pkfields2 = new Pkfields();
    pkfields2.setId1(2);
    assertTrue(pkfields1.equals(pkfields2));
}
Also used : Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)226 SqlSession (org.apache.ibatis.session.SqlSession)208 ArrayList (java.util.ArrayList)24 Pkfields (mbg.test.mb3.generated.annotated.flat.model.Pkfields)23 Pkfields (mbg.test.mb3.generated.flat.model.Pkfields)23 Pkfields (mbg.test.mb3.generated.mixed.flat.model.Pkfields)23 PkfieldsMapper (mbg.test.mb3.generated.annotated.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.annotated.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper)17 PkfieldsMapper (mbg.test.mb3.generated.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.flat.mapper.PkfieldsMapper)17 PkfieldsMapper (mbg.test.mb3.generated.mixed.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.mixed.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.mixed.flat.mapper.PkfieldsMapper)17 PkfieldsMapper (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.PkfieldsMapper)16 Pkfields (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.Pkfields)16 PkfieldsMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.PkfieldsMapper)16 Pkfields (mbg.test.mb3.generated.annotated.hierarchical.model.Pkfields)16 PkfieldsMapper (mbg.test.mb3.generated.hierarchical.immutable.mapper.PkfieldsMapper)16