Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to know if a transaction is successful or not in hibernate?

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am designing a web application in which I am using Hibernate for ORM mapping I have implement something like this


I want to know how can I know that a transaction is successful or not as return type of tx.commit() is void.

Thanks
 
Roel De Nijs
Sheriff
Posts: 10725
146
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you register the same student (violating a primary key constraint) or try to insert a null value into a column having a not null constraint?
 
Dave Tolls
Ranch Hand
Posts: 2207
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the API for Transaction.commit() you'll see that even though it may not return a value, it does do something else.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Dave

I don't get my answar by reading your refernce post can you clearify it some bit more?
 
Roel De Nijs
Sheriff
Posts: 10725
146
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishor Joshi wrote:I don't get my answar by reading your refernce post can you clearify it some bit more?

That can only mean 2 things: either you actually can't read or you want spoon feeding instead of getting hints. I can't imagine it's the first. So it has to be the latter case, and then I've only 1 advice: ShowSomeEffort please. Thanks!

(And you clearly haven't tried my suggestion either, otherwise you knew what Dave's post is referring to)
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Roel,@Dave

Thanks I have figure out this is my updated code which is working fine
 
Roel De Nijs
Sheriff
Posts: 10725
146
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't close your session if the commit finishes successfully...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!