Hi,
I am just novice to Hibernate.I am doing very simple example.Everything is working fine but database is not updated.I am just inserting records in the table.
java Bean file:Contact.java
Hibernate version:3.2
Mapping documents<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <class name="com.oreilly.Contact" table="CONTACT"> <id name="id" type="integ" column="ID" > <generator class="assigned"/> </id>
<property name="firstName"> <column name="FIRSTNAME" /> </property> <property name="lastName"> <column name="LASTNAME"/> </property> <property name="email"> <column name="EMAIL"/> </property> </class> </hibernate-mapping>
:
Code between sessionFactory.openSession() and session.close() Contact contact = new Contact(); contact.setId(3); contact.setFirstName("Pranabesh"); contact.setLastName("Paul"); contact.setEmail("pranabesh.paul@wipro.com"); session.save(contact); System.out.println("Done"); }catch(Exception e){ System.out.println("Exception is here"+e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.flush(); session.close(); System.out.println("Its over"); } :
Full stack trace of any exception that occursNo Exception log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record Done Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?) Its over :
Name and version of the database you are using: MYSQL 5.0
The generated SQL (show_sql=true):
yes
Debug level Hibernate log excerpt: i have not set yet
|