在我的代码中,我做了如下:
我对这种持久化方法的行为感到困惑.
请帮帮我.
代码如下:
//My Service......
@Service("myService")
@Transactional
public class MyServiceImpl implements MyService {
@Transactional(rollbackFor = { Throwable.class })
public void updateCourse(final Course course) throws MyServiceException {
------
------
CourseEntity courseEntity = courseDao.findById(course.getId());
populateCourseEntity(courseEntity, course);
courseDao.update(courseEntity);
}
}
//CourseDao.....
public class CourseDaoImpl implements CourseDao {
--------
public void update(final T entity) throws MyDaoException {
if (entity != null) {
this.entityManager.persist(entity);
}
else {
String errMsg = "Object to be updated cannot be null.";
throw new MyDaoException(errMsg); …Run Code Online (Sandbox Code Playgroud)