I cannot save my objects to the DB. I can do updates fine, but am having trouble creating a new object and saving it in my database.
My DAO object has the following code:
Session session = openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
Product p = new Product (new Long(4444),
"Chair",
new Double(1.99));
session.save(p);
tx.commit();
}
catch(...) { ... handle exception ... }
When I turn on show_sql=true I see the following in my log file:
Hibernate: insert into PRODUCT (DESCRIPTION, PRICE, ID) values (?, ?, default)
Are the "?" and the word "default" OK?
Then I receive an error from the DB2 database:
JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: -407, SQLState: 23502
JDBCException E net.sf.hibernate.util.JDBCExceptionReporter [IBM][CLI Driver][DB2/NT] SQL0407N
Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=2, COLNO=0" is not allowed. SQLSTATE=23502
Can anyone shed some light on what is going on here?
The DB says my values are NULL, but they are not.
Thanks,
Bill
|