Hi, I new to hibernate and trying to store some values into a simple table.
I am getting error saying that javax/transaction/Synchronization
while using below code.
Goodthing is the table 'CONTACT' is created in the database. But no rows are inserted.
Can anyone help me please.....
Thanks,
Sidhu.
Hibernate version:
3
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="Contact" table="CONTACT">
<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>
Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
Transaction tx;
tx = session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("firstname");
contact.setLastName("lastname");
contact.setEmail("
[email protected]");
session.save(contact);
session.flush();
tx.commit();
session.close();
Full stack trace of any exception that occurs:
javax/transaction/Synchronization
Name and version of the database you are using:
oracle 10g
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: