it is giging same fatal exception
while i have chaged hibernate2.jar
other programs are working propely ,
only diff is that i did not create a utill class for sessionFactory.
This is code of workign program
// this is working properly
package roseindia.tutorial.hibernate;
import org.hibernate.Transaction;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class FirstExample {
public static void main(String[] args) {
Session session = null;
Transaction tx = null;
try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(5);
contact.setFirstName("umesh5");
contact.setLastName("rawat5");
contact.setEmail("5umeshrawat30@gmail.com");
tx= session.beginTransaction();
session.save(contact);
//session.
System.out.println("Done");
contact.setFirstName("umesh5Changed");
session.update(contact);
tx.commit();
//session.commit();
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
//session.flush();
//session.close();
}
}
}
================
contact.hbm
<?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="roseindia.tutorial.hibernate.Contact" table="CONTACT" mutable="false" >
<id name="id" type="long" 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>
=========
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">1</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
<mapping resource="insurance.hbm.xml"/>
<mapping resource="book.hbm.xml"/>
</session-factory>
</hibernate-configuration>
==================
Contact .java
package roseindia.tutorial.hibernate;
/**
* @author Deepak Kumar
*
*
http://www.roseindia.net
*
Java Class to map to the datbase Contact Table
*/
public class Contact {
private String firstName;
private String lastName;
private String email;
private long id;
/**
* @return Email
*/
public String getEmail() {
return email;
}
/**
* @return First Name
*/
public String getFirstName() {
return firstName;
}
/**
* @return Last name
*/
public String getLastName() {
return lastName;
}
/**
* @param string Sets the Email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @param string Sets the First Name
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @param string sets the Last Name
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return ID Returns ID
*/
public long getId() {
return id;
}
/**
* @param l Sets the ID
*/
public void setId(long id) {
this.id = id;
}
}
==