use of mbg.test.mb3.generated.flat.mapper.AwfulTableMapper in project generator by mybatis.
the class FlatJava5Test method testAwfulTableInsertSelective.
@Test
public void testAwfulTableInsertSelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.seteMail("fred@fred.com");
record.setEmailaddress("alsofred@fred.com");
record.setFrom("from field");
record.setId1(1);
record.setId2(2);
record.setId5(5);
record.setId6(6);
record.setId7(7);
record.setSecondFirstName("fred2");
record.setThirdFirstName("fred3");
mapper.insertSelective(record);
Integer generatedCustomerId = record.getCustomerId();
assertEquals(57, generatedCustomerId.intValue());
AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedCustomerId);
assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
assertEquals(record.geteMail(), returnedRecord.geteMail());
assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
assertEquals("Mabel", returnedRecord.getFirstFirstName());
assertEquals(record.getFrom(), returnedRecord.getFrom());
assertEquals(record.getId1(), returnedRecord.getId1());
assertEquals(record.getId2(), returnedRecord.getId2());
assertEquals(record.getId5(), returnedRecord.getId5());
assertEquals(record.getId6(), returnedRecord.getId6());
assertEquals(record.getId7(), returnedRecord.getId7());
assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.flat.mapper.AwfulTableMapper in project generator by mybatis.
the class FlatJava5Test method testAwfulTableUpdateByPrimaryKeySelective.
@Test
public void testAwfulTableUpdateByPrimaryKeySelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.seteMail("fred@fred.com");
record.setEmailaddress("alsofred@fred.com");
record.setFirstFirstName("fred1");
record.setFrom("from field");
record.setId1(1);
record.setId2(2);
record.setId5(5);
record.setId6(6);
record.setId7(7);
record.setSecondFirstName("fred2");
record.setThirdFirstName("fred3");
mapper.insert(record);
Integer generatedCustomerId = record.getCustomerId();
AwfulTable newRecord = new AwfulTable();
newRecord.setCustomerId(generatedCustomerId);
newRecord.setId1(11);
newRecord.setId2(22);
int rows = mapper.updateByPrimaryKeySelective(newRecord);
assertEquals(1, rows);
AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedCustomerId);
assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
assertEquals(record.geteMail(), returnedRecord.geteMail());
assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
assertEquals(record.getFrom(), returnedRecord.getFrom());
assertEquals(newRecord.getId1(), returnedRecord.getId1());
assertEquals(newRecord.getId2(), returnedRecord.getId2());
assertEquals(record.getId5(), returnedRecord.getId5());
assertEquals(record.getId6(), returnedRecord.getId6());
assertEquals(record.getId7(), returnedRecord.getId7());
assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.flat.mapper.AwfulTableMapper in project generator by mybatis.
the class FlatJava5Test method testAwfulTableDeleteByExample.
@Test
public void testAwfulTableDeleteByExample() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.seteMail("fred@fred.com");
record.setEmailaddress("alsofred@fred.com");
record.setFirstFirstName("fred1");
record.setFrom("from field");
record.setId1(1);
record.setId2(2);
record.setId5(5);
record.setId6(6);
record.setId7(7);
record.setSecondFirstName("fred2");
record.setThirdFirstName("fred3");
mapper.insert(record);
record = new AwfulTable();
record.seteMail("fred2@fred.com");
record.setEmailaddress("alsofred2@fred.com");
record.setFirstFirstName("fred11");
record.setFrom("from from field");
record.setId1(11);
record.setId2(22);
record.setId5(55);
record.setId6(66);
record.setId7(77);
record.setSecondFirstName("fred22");
record.setThirdFirstName("fred33");
mapper.insert(record);
AwfulTableExample example = new AwfulTableExample();
List<AwfulTable> answer = mapper.selectByExample(example);
assertEquals(2, answer.size());
example = new AwfulTableExample();
example.createCriteria().andEMailLike("fred@%");
int rows = mapper.deleteByExample(example);
assertEquals(1, rows);
example.clear();
answer = mapper.selectByExample(example);
assertEquals(1, answer.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.flat.mapper.AwfulTableMapper in project generator by mybatis.
the class ConditionalJava5Test method testAwfulTableInsert.
@Test
public void testAwfulTableInsert() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.seteMail("fred@fred.com");
record.setEmailaddress("alsofred@fred.com");
record.setFirstFirstName("fred1");
record.setFrom("from field");
record.setId1(1);
record.setId2(2);
record.setId5(5);
record.setId6(6);
record.setId7(7);
record.setSecondFirstName("fred2");
record.setThirdFirstName("fred3");
int rows = mapper.insert(record);
assertEquals(1, rows);
Integer generatedCustomerId = record.getCustomerId();
assertEquals(57, generatedCustomerId.intValue());
AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedCustomerId);
assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
assertEquals(record.geteMail(), returnedRecord.geteMail());
assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
assertEquals(record.getFrom(), returnedRecord.getFrom());
assertEquals(record.getId1(), returnedRecord.getId1());
assertEquals(record.getId2(), returnedRecord.getId2());
assertEquals(record.getId5(), returnedRecord.getId5());
assertEquals(record.getId6(), returnedRecord.getId6());
assertEquals(record.getId7(), returnedRecord.getId7());
assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.flat.mapper.AwfulTableMapper in project generator by mybatis.
the class ConditionalJava5Test method testAwfulTableUpdateByPrimaryKeySelective.
@Test
public void testAwfulTableUpdateByPrimaryKeySelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.seteMail("fred@fred.com");
record.setEmailaddress("alsofred@fred.com");
record.setFirstFirstName("fred1");
record.setFrom("from field");
record.setId1(1);
record.setId2(2);
record.setId5(5);
record.setId6(6);
record.setId7(7);
record.setSecondFirstName("fred2");
record.setThirdFirstName("fred3");
int rows = mapper.insert(record);
assertEquals(1, rows);
Integer generatedCustomerId = record.getCustomerId();
assertEquals(57, generatedCustomerId.intValue());
AwfulTable newRecord = new AwfulTable();
newRecord.setCustomerId(generatedCustomerId);
newRecord.setId1(11);
newRecord.setId2(22);
rows = mapper.updateByPrimaryKeySelective(newRecord);
assertEquals(1, rows);
AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedCustomerId);
assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
assertEquals(record.geteMail(), returnedRecord.geteMail());
assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
assertEquals(record.getFrom(), returnedRecord.getFrom());
assertEquals(newRecord.getId1(), returnedRecord.getId1());
assertEquals(newRecord.getId2(), returnedRecord.getId2());
assertEquals(record.getId5(), returnedRecord.getId5());
assertEquals(record.getId6(), returnedRecord.getId6());
assertEquals(record.getId7(), returnedRecord.getId7());
assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
} finally {
sqlSession.close();
}
}
Aggregations