Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with hibernate

 
Tobias Tangfelt
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to hibernate and I am trying to to make inserts with storere procedures on my MySQL database. I have no problem to get information from it, the problem become when I am trying to insert data to it.
Here is my code in the hbm.xml file (It is only the part where I am trying to implement my store procedure that are going to insert values in database):


Here is a part of the Java code:


The store procedure is working fine.
I got following error message when I am trying to execute:
"Exception in thread "AWT-EventQueue-0" org.hibernate.TransactionException: Transaction not successfully started"

Does anyone have any suggestion?

 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
not sure what the problem is but did you try using this instead of openSession?
 
Tobias Tangfelt
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually solved my problem with INSERT.
But I have problem with UPDATE and INSERT.

This is my hbm.xml file:


This is my delete method:


This is my update method:


All the stored procedure is working, and I have try the exact sam thing without the stored procedure and it´s working. And my INSERT operation also working.
But when I can´t get it to work, and I have no idea why.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to ask: why are you using stored procedures and Hibernate together? Do the stored procedures do something Hibernate can't?
 
Jan Cumps
Bartender
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and do you commit inside your stored procedure?
 
Tobias Tangfelt
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use stored procedure because I am reading a course there we now got a task where we are trying to use stored procedure in Hibernate.
I haven´t done commit in my store procedure but i have it in my Java code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic