mappingDAO.session = com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory
.getNewSession();
valueTypeDAO.session = com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory
.getNewSession();
Mapping mapping = new Mapping();
mapping.setId(mappingDAO.findById(99999l).getId());
mapping.setName("Mappings");
RowAlias rowAlias1 = new RowAlias();
rowAlias1.setId(99999);
rowAlias1.setAlias("aliasTest1Updated");
rowAlias1.setValueType(valueTypeDAO.findById(1l));
rowAlias1.setLength(6);
mapping.addRowAlias(rowAlias1);
RowAlias rowAlias2 = new RowAlias();
rowAlias2.setAlias("newAlias1Added");
rowAlias2.setValueType(valueTypeDAO.findById(1l));
rowAlias2.setLength(7);
mapping.addRowAlias(rowAlias2);
RowAlias rowAlias3 = new RowAlias();
rowAlias3.setId(100001);
rowAlias3.setAlias("aliasTest3Updated");
rowAlias3.setValueType(valueTypeDAO.findById(1l));
rowAlias3.setLength(6);
mapping.addRowAlias(rowAlias3);
ColumnAlias columnAlias1 = new ColumnAlias();
columnAlias1.setId(100000);
columnAlias1.setAlias("aliasTest5Updated");
columnAlias1.setColumnFamily("cf");
columnAlias1.setValueType(valueTypeDAO.findById(2l));
columnAlias1.setQualifier("qual1");
mapping.addColumnAlias(columnAlias1);
ColumnAlias columnAlias2 = new ColumnAlias();
columnAlias2.setAlias("newAlias2Added");
columnAlias2.setColumnFamily("cf");
columnAlias2.setValueType(valueTypeDAO.findById(2l));
columnAlias2.setQualifier("qual2");
mapping.addColumnAlias(columnAlias2);
mappingDAO.transaction = mappingDAO.session.getTransaction();
long id = mappingDAO.save(mapping);
assertEquals(id, 99999l);
mapping = mappingDAO.findById(99999l);
assertEquals(mapping.getName(), "Mappings");
mappingDAO.session.close();
stmt.executeUpdate("delete from rowAlias where mappingId=" + 99999);
stmt.executeUpdate("delete from columnAlias where mappingId=" + 99999);
stmt.executeUpdate("delete from mapping where id=" + 99999);