Reputation: 125
What I want to do is save a user and then save a restaurant entity. I thought this will be easy but it seems that I failed to understand something.
userService.save(user); //this one runs just fine
selectedRestaurant.getEmployees().add(user);
restaurantService.save(selectedRestaurant); //exception
The relation between the two is @OneToMany. No transaction annotations are used. I thought that the first one opens a transaction and closes it too and the second one does the same. But after trying to save the restaurant I get this:
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtaining JDBC connection
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtained JDBC connection
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl - Skipping aggressive release due to registered resources
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.hibernate.jpa.spi.AbstractEntityManagerImpl - Mark transaction for rollback
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl - HHH000106: Forcing container resource cleanup on transaction completion
[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.hibernate.engine.jdbc.spi.SqlExceptionHelper - could not log warnings
java.sql.SQLException: Statement has already been closed
Why whould this roll back?
I'm trying to use spring data jpa (1.9.2.RELEASE), weblogic 12c, mysql 5.6.17. If relevant Emulate Two-Phase Commit is enabled in weblogic.
Could you give me advices how to do this properly?
Upvotes: 0
Views: 149
Reputation: 125
User id is auto generated. The save method cannot make the connection between an entity and a dto without id.
Upvotes: 1