PDA

View Full Version : Problem with HibernateJobDao


Ronald
Nov 21st, 2007, 04:57 AM
When I use the Hibernate configuration I get the following exception:


Hibernate: select this_.ID as ID0_0_, this_.version as version0_0_, this_.STATUS as STATUS0_0_, this_.JOB_NAME as JOB4_0_0_, this_.JOB_KEY as JOB5_0_0_ from BATCH_JOB this_ where case when this_.JOB_KEY is NULL then 'Simple' when this_.SCHEDULE_DATE is NULL then 'Default' else 'Scheduled' end='Default' and (this_.JOB_NAME=? and this_.JOB_KEY=?)

Hibernate: insert into BATCH_JOB (ID, version) values (null, ?)
2007-11-21 10:23:48,890 ERROR JDBCExceptionReporter - Attempt to insert null into a non-nullable column: column: JOB_NAME table: BATCH_JOB in statement [insert into BATCH_JOB (ID, version) values (null, ?)]


When I modify the sql file packaged with Spring batch to the following I don't get the exception.


CREATE TABLE BATCH_JOB (
ID BIGINT IDENTITY PRIMARY KEY ,
VERSION BIGINT,
JOB_NAME VARCHAR(100) ,
JOB_KEY VARCHAR(20) ,
SCHEDULE_DATE DATE ,
STATUS VARCHAR(10) );



I think this is an issue in Spring Batch, but I'm not sure. Maybe I'm using a wrong configuration.

Is this a known issue?

Dave Syer
Nov 21st, 2007, 09:27 AM
JOB_NAME is not null for a reason so you shouldn't have to modify the DDL. I think someone else reported this problem and it turned out they had not configured the Hibernate LocalSessionFactory and/or the HibernateJobDao correctly. You need to inject the interceptor and EntityNameLocator, as per the samples (which changed recently so if you are using an old configuration with a new snapshot that might explain the problem).

Ronald
Nov 22nd, 2007, 02:06 AM
I forgot to inject the EntityNameInterceptor. Thanks for pointing that out!