-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with store procedures
PostPosted: Wed May 18, 2011 4:08 pm 
Newbie

Joined: Wed May 18, 2011 4:00 pm
Posts: 2
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):
Code:
<sql-query name="insertCarsSP" callable="true">
    <return alias="cars" class="labb6Hibernate.bil">

    </return>
    { call insertCars(?,?,?) }
</sql-query>


Here is a part of the Java code:
Code:
Session session = MyHibernateUtil.getSessionFactory().openSession();
       org.hibernate.Query q = session.getNamedQuery("insertCarsSP");       
       q.setParameter(0, "Saab");
       q.setParameter(1, "9000");
       q.setParameter(2, "1999");
       session.getTransaction().commit();
       session.close();


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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.