use of mbg.test.mb3.generated.dsql.model.AwfulTable in project generator by mybatis.
the class UpdateByExampleTest method testAwfulTableUpdateByExampleSelective.
@Test
public void testAwfulTableUpdateByExampleSelective() {
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);
AwfulTable newRecord = new AwfulTable();
newRecord.setFirstFirstName("Alonzo");
AwfulTableExample example = new AwfulTableExample();
example.createCriteria().andEMailLike("fred2@%");
int rows = mapper.updateByExampleSelective(newRecord, example);
assertEquals(1, rows);
List<AwfulTable> answer = mapper.selectByExample(example);
assertEquals(1, answer.size());
AwfulTable returnedRecord = answer.get(0);
assertEquals(record.getCustomerId(), returnedRecord.getCustomerId());
assertEquals(record.geteMail(), returnedRecord.geteMail());
assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
assertEquals(newRecord.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.dsql.model.AwfulTable in project generator by mybatis.
the class FlatJava5Test method testAwfulTableDeleteByPrimaryKey.
@Test
public void testAwfulTableDeleteByPrimaryKey() {
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();
int rows = mapper.deleteByPrimaryKey(generatedCustomerId);
assertEquals(1, rows);
AwfulTableExample example = new AwfulTableExample();
List<AwfulTable> answer = mapper.selectByExample(example);
assertEquals(0, answer.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.dsql.model.AwfulTable in project generator by mybatis.
the class FlatJava5Test method testAwfulTableSelectByPrimaryKey.
@Test
public void testAwfulTableSelectByPrimaryKey() {
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);
Integer generatedKey = record.getCustomerId();
AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedKey);
assertNotNull(returnedRecord);
assertEquals(record.getCustomerId(), 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.dsql.model.AwfulTable in project generator by mybatis.
the class SimpleTest method testAwfulTable.
@Test
public void testAwfulTable() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
AwfulTable record = new AwfulTable();
record.setFirstFirstName("Fred");
int rows = mapper.insert(record);
assertEquals(1, rows);
assertNotNull(record.getCustomerId());
record = new AwfulTable();
record.setFirstFirstName("Barney");
rows = mapper.insert(record);
assertEquals(1, rows);
assertNotNull(record.getCustomerId());
List<AwfulTable> records = mapper.selectAll();
assertEquals(2, records.size());
AwfulTable returnedRecord = mapper.selectByPrimaryKey(record.getCustomerId());
assertNotNull(returnedRecord);
assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
record.setFirstFirstName("Betty");
rows = mapper.updateByPrimaryKey(record);
assertEquals(1, rows);
returnedRecord = mapper.selectByPrimaryKey(record.getCustomerId());
assertNotNull(returnedRecord);
assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
rows = mapper.deleteByPrimaryKey(record.getCustomerId());
assertEquals(1, rows);
records = mapper.selectAll();
assertEquals(1, records.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.dsql.model.AwfulTable in project generator by mybatis.
the class FlatJava5Test method testAwfulTableUpdateByPrimaryKey.
@Test
public void testAwfulTableUpdateByPrimaryKey() {
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();
record.setId1(11);
record.setId2(22);
int rows = mapper.updateByPrimaryKey(record);
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(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();
}
}
Aggregations