Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.3.1
Mapping documents:
Below is the code I use to create a row in DB .
hibernateSessionFactory = new Configuration().configure().buildSessionFactory();
Session session = factory.getCurrentSession();
try {
session.beginTransaction();
session.save(event);
System.out.println("save done");
session.getTransaction().commit();
System.out.println("commit done");
} catch (Exception e) {
e.printStackTrace();
session.getTransaction().rollback();
}
Note : I also used session.close() and factory.close() . But It did not help
No Exception
MySql 5.1
The generated SQL :: Hibernate: insert into EVENTS (EVENT_DATE, EVENT_TITLE) values (?, ?)
Problems with Session and transaction handling? - NO
After first record insertion the the primary key is 1. and when i use the same code and insert record again the primary key is still 1 there by there is no new row inserted.
I tried using select,assign,increment,native in generator class. But Still having the above..
The .hbm.xml file is as shown below
<?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.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="eventdate" type="timestamp" column="EVENT_DATE"/>
<property name="title" type="string" column="EVENT_TITLE"/>
</class>
</hibernate-mapping>
Read this:
http://hibernate.org/42.html