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
|