File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Problem with hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with hibernate" Watch "Problem with hibernate" New topic

Problem with hibernate

Tobias Tangfelt

Joined: May 11, 2011
Posts: 9
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

Joined: Nov 21, 2006
Posts: 142
not sure what the problem is but did you try using this instead of openSession?

SCJP 1.4, SCWCD 1.5
Tobias Tangfelt

Joined: May 11, 2011
Posts: 9
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

Joined: Apr 14, 2004
Posts: 10336

I have to ask: why are you using stored procedures and Hibernate together? Do the stored procedures do something Hibernate can't?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

... and do you commit inside your stored procedure?

OCUP UML fundamental and ITIL foundation
Tobias Tangfelt

Joined: May 11, 2011
Posts: 9
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.
I agree. Here's the link:
subject: Problem with hibernate
It's not a secret anymore!