Reputation: 150
My insert code in the DAO:
public void add(){
Books a=new Books();
a.setId("213");
a.setName("The DaVinci Code");
a.setAuthor("Dan Brown");
getSession().save(a);
}
I am trying insert or delete a record from the database DB2. But it gives me the following error:
ERROR util.JDBCExceptionReporter - [SQL7008] (TABLE name) not valid for operation.
ERROR def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert:
I also heard something about journaling in the net but not sure about it. I have no idea how to solve the problem. Please help!
Upvotes: 0
Views: 340
Reputation: 1804
When using DB2 as database, you have to journal a table before any update or insert within a transaction. If you try to make it within a transaction and it's not being journalled, it shows you code SQL7008.
Hibernate has a default propery of autocommit which is false if you set it to true it would work, but it's not recommended to do it since you will not be able to control the transactions and commit only if everything works.
<property name="hibernate.connection.autocommit" value="true"/>
(Not recommended)
So, the idea would be you to fix it in your database and set the table as journalled.
Upvotes: 1