| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
|
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
1 comments so far (post your own) View All Comments Latest 10 Comments:At the time of working with this example:
- table gets created in database
- but no record is inserted
The given below is the solution for the Porblem:
In your FirstExample.java, the transaction should be started explicitly and after saveing your contact details transaction should be commited explicitly.
write below lines before the doing anything with your contact class.
-----------------------------------------------
tx = session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Creating New Contact detail.");
Contact contact = new Contact();
System.out.println("providing contact details");
contact.setId(6); // Primary key has to be unique for every record inserted!
contact.setFirstName("subnesh");
contact.setLastName("sharma");
contact.setEmail("subnesh@gmail.com");
session.save(contact);
tx.commit();
System.out.println("Contact saved into database successfully");
------------------------------------------------
or
rather then making changes in your FirstExample.java (use same code as privided in this tutorial), you can add new property to hibernate.cfg.xml file with below code:
<property name="hibernate.connection.autocommit"> true </property>
------------------------------------
Posted by subnesh on Wednesday, 02.27.08 @ 11:44am | #50282