transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
try {
UnitType typeX = unitTypeDAO.findByCode("XXX");
assertTrue(typeX.getMeasure().equalsIgnoreCase("measureX"));
UnitType typeY = unitTypeDAO.findByCode("YYY");
assertTrue(typeY.getMeasure().equalsIgnoreCase("measureY"));
unitTypeDAO.flush();
sessionFactory.getCurrentSession().evict(typeX);
sessionFactory.getCurrentSession().evict(typeY);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
return null;
}
});
/* Update the measure unit type */
m1 = new UnitTypeDTO("XXX", "update-measureX");
m2 = new UnitTypeDTO("YYY", "update-measureY");
unitTypeDTOs = new ArrayList<UnitTypeDTO>();
unitTypeDTOs.add(m1);
unitTypeDTOs.add(m2);
unitTypeListDTO = createUnitTypeListDTO(m1, m2);
instanceConstraintViolationsList = unitTypeService
.addUnitTypes(unitTypeListDTO).instanceConstraintViolationsList;
assertTrue(instanceConstraintViolationsList.toString(),
instanceConstraintViolationsList.size() == 0);
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
try {
UnitType typeX = unitTypeDAO.findByCode("XXX");
assertTrue(typeX.getMeasure().equalsIgnoreCase(
"update-measureX"));
UnitType typeY = unitTypeDAO.findByCode("YYY");
assertTrue(typeY.getMeasure().equalsIgnoreCase(
"update-measureY"));
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
return null;