我想做这个 :
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public MyObject create(ObjectBasicDTO dto) {
MyObject myObject = new MyObject (dto);
return sessionFactory.getCurrentSession().save(object);
}
但我必须这样做:
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public MyObject create(ObjectBasicDTO dto) {
MyObject myObject = new MyObject (dto);
Long id = sessionFactory.getCurrentSession().save(object);
return sessionFactory.getCurrentSession().get(MyObject.class, id);
}
那正确吗 ?那似乎很蹩脚。