Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-15-2007, 09:42 AM
Member
 
Join Date: Jun 2007
Posts: 1
Saritha is on a distinguished road
Friends could u plz give me solution 4 this
Using hibernate i am just trying to insert a record ..... but i thowing exception

Hibernate: select max(id) from check
Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started
at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:100)
at Test.main(Test.java:18)

This is my code .....

Session s = HibernateUtil.currentSession();
Check c = new Check();
c.setName("Sankya-p");
c.setAddress("Isro-p");
Transaction t = s.getTransaction();
s.save(c);
t.commit();
HibernateUtil.closeSession();

and hbm file ....
<class name="Check" table="check">
<id
name="id"
type="integer"
column="id"
>
<generator class="increment"/>
</id>

<property
name="name"
type="string"
column="name"
length="20"
/>
<property
name="address"
type="string"
column="address"
length="20"
/>
</class>
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-15-2007, 05:42 PM
Senior Member
 
Join Date: Jun 2007
Posts: 119
Peter is on a distinguished road
This error appears because you didn't do a begin transaction, and tried to do a commit of it
You didn't do this line t.beginTransaction();
example:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); try { SQLQuery query = session.createSQLQuery("select name from condition"); System.out.println(query.list().get(0).toString()); } catch (Exception ex) { ex.printStackTrace(); } session.close();

Last edited by Peter : 06-16-2007 at 05:51 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
anyone can give idea 2 my assignment? chen8735 Advanced Java 2 03-08-2008 07:03 PM
Is there anyone can give a instruction about Myoodb ibmzz Database 0 01-19-2008 10:04 AM
Give me some suggestion on wedding story book roots Forum Lobby 1 01-10-2008 05:17 PM
Simple serverless chat solution goodjonx Networking 3 01-07-2008 04:25 PM
give me a advise sireesha New To Java 3 12-11-2007 02:38 AM


All times are GMT +3. The time now is 09:04 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org