Now all the basic settings are now fine, and I started using transactions. Struts + Spring + Hibernate Annotation Transaction Manager. This is an example code in Action that will call a class of service:
userService.addUser();
Here is the addUser() method in the service class:
@Transactional(value="deu" ) public void addUser() { userDao.addUser(); this.addUser2(); }
First, I called addUser in userDao, which will insert the user. Secondly, I called addUser2 another method in this service class.
@Transactional(value="deu" , propagation=Propagation.REQUIRES_NEW ) public void addUser2() {
And this will not succeed due to zero PK. I believe that the second call ( addUser2 ) will not work, but will not affect the previous one. However, the user is not inserted.
If I just call:
@Transactional(value="deu" ) public void addUser() { userDao.addUser();
It works, that is, basic settings, such as a database, are not incorrect.
Any idea?
source share