Hi,
i am new to the hibernate. i am trying to do some sample application with hibernate using HSQLDatabase. i am able to retriving the data from the database. but when i am trying to save the data in to the database.. it is not inserting.i am using increment as a generator class for Id.after executing the program it is showing following information in the console..
Hibernate: select max(id) from BOOK
Hibernate: insert into BOOK (bookname, id) values (?, ?)
but in the database it is not showing the inserted data.i am not getting any exception also. when i try to retrive the data from the database using Query.list()it is retriving normally.
please see the code bellow what i did:
main class:
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Book b1 = new Book();
b1.setLngBookId(1);
b1.setStrBookName("testData");
session.save(b1);
session.getTransaction().commit();
hbm file:
<hibernate-mapping>
<class name="test.Book" table="BOOK">
<id name="lngBookId" type="long" column="id" >
<generator class="increment"/>
</id>
<property name="strBookName">
<column name="bookname" />
</property>
</class>
</hibernate-mapping>
cfg file:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">
jdbc:hsqldb:file
:\PAYMENTS\HSQLDB</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">true</property>
<mapping resource="book.hbm.xml"/>
</session-factory>
</hibernate-configuration>
please give me the solution to my problem.
Thanks & regards!!
Naresh Kapilavai