-->
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: tables not getting updated upon saving
PostPosted: Tue Nov 03, 2009 1:20 am 
Newbie

Joined: Mon Nov 02, 2009 8:37 am
Posts: 1
Hi All,

I am trying to achieve a simple hibernate functionality. I have a swing UI using which i can search existing records, add new records or update existing records. Search operations are fine. But when i try to add or update the records, it does not get reflected in DB.
Environment details:
DB server: Mysql 4.1
Hibernate: 2.1
Code snippet for adding new records
CD cd = new CD(artistField.getText(), titleField.getText(),
new Date(), Double.parseDouble(costField.getText()));
listModel.addCD(cd);
try {
Session session = sessionFactory.openSession();
session.save(cd);

session.flush();
session.close();
} catch (Exception e) {
e.printStackTrace();
}

Hibernate config file entry
<hibernate-mapping>
<class name="CD" table="cd">
<id name="id" type="int" unsaved-value="null">
<column name="ID" sql-type="int" not-null="true" />
<generator class="hilo" />
</id>
<property name="title" />
<property name="artist" />
<property name="purchasedate" type="date" />
<property name="cost" type="double" />
</class>
</hibernate-mapping>

If anybody can help me out, it would be great.

Thanks and regards,
Siva


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.