Additional Information:
Unit test code
Code:
History hist = creatHistoryObject();
HibernateUtil.saveObject( hist );
Session session = HibernateUtil.getCurrentSession().openSession();
History hist2 = (History)session.createQuery( "from History where id = " + hist.getId() ).uniqueResult();
String fieldName = Long.toString( rand.nextLong() );
String oldValue = Long.toString( rand.nextLong() );
String newValue = Long.toString( rand.nextLong() );
hist2.addPropertyChange( fieldName, oldValue, newValue );
HibernateUtil.updateObject( hist2 );
When running the above test, the last debug statement from Hibernate is:
Code:
Hibernate:
insert
into
PROPERTY_CHANGE
(FIELD_NAME, OLD_VALUE, NEW_VALUE, ID)
values
(?, ?, ?, ?)
Then the errors start
Code:
May 3, 2007 1:17:46 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1400, SQLState: 23000
May 3, 2007 1:17:46 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ORA-01400: cannot insert NULL into ("PROPERTY_CHANGE"."HISTORYID")
Database: Oracle 10.2g
Creation SQLCode:
CREATE TABLE HISTORY(
ID NUMBER NOT NULL,
HISTORY_TYPE VARCHAR2(24) NOT NULL
);
ALTER TABLE HISTORY ADD CONSTRAINT PK_HISTORY PRIMARY KEY(ID);
CREATE TABLE PROPERTY_CHANGE(
ID NUMBER NOT NULL,
HISTORYID NUMBER NOT NULL,
FIELD_NAME VARCHAR2(30) NOT NULL,
OLD_VALUE VARCHAR2(4000),
NEW_VALUE VARCHAR2(4000)
);
ALTER TABLE PROPERTY_CHANGE ADD CONSTRAINT PK_PROP_CHNG PRIMARY KEY(ID);
ALTER TABLE PROPERTY_CHANGE ADD CONSTRAINT FK_PC_AUD FOREIGN KEY(HISTORYID) REFERENCES HISTORY(ID);