September 2018
Intermediate to advanced
802 pages
19h 30m
English
Let's write the code that demonstrates CRUD operations on the family table. First, here's how a family record can be created and associated with two person2 records:
String resource = "mybatis/mb-config2.xml";String familyMapperNamespace = "mybatis.FamilyMapper";String personMapperNamespace = "mybatis.Person2Mapper";try { InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); try(SqlSession session = sqlSessionFactory.openSession()){ Family f = new Family("The Jones"); session.insert(familyMapperNamespace + ".insertFamily", f); System.out.println("Family id=" + f.getId()); //Family id=1 Person2 p = new Person2(25, "Jill", ...
Read now
Unlock full access