Hi, I'm getting the following exception during persistence when i have @OneToMany mapping in my hibernate objects. StackTrace
Caused by: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [insert into JOB_FREQUENCY_INFO (CREATED_BY, CREATED_ON, LAST_UPDATED_BY, LAST_UPDATED_ON, VERSION_NO, TYPE, VALUE, UUID) values (?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:637) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683) at com.test.service.impl.DataAccessImpl.create(DataAccessImpl.java:71) ... 3 more Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001) at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:407) ... 6 more Caused by: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("SYS"."JOB_FREQUENCY_INFO"."JOB_ID")
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343) at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeBatch(DelegatingPreparedStatement.java:231) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247) ... 13 more
Hibernate Objects:
@Entity @Table(name = "JOB_SCHEDULE_INFO") public class JobSchedule { @Id @GeneratedValue(generator = "uniqueId") @GenericGenerator(name = "uniqueId", strategy = "com.test.persistence.UniqueIDGenerator") @Type(type = "com.test.persistence.ApplianceUUID") @Column(name = "UUID", nullable = false) protected ApplianceUUID uuid;
@OneToMany(fetch = FetchType.EAGER, cascade = { javax.persistence.CascadeType.ALL }) @Cascade( { CascadeType.ALL }) @JoinColumn(name = "JOB_ID") private Set<JobFrequency> jobFreqValue;
@Column(name = "STATUS", nullable = false) private boolean status;
//Some other fields //getters and setters }
@Entity @Table(name = "JOB_FREQUENCY_INFO") public class JobFrequency {
@Id @GeneratedValue(generator = "uniqueId") @GenericGenerator(name = "uniqueId", strategy = "com.test.persistence.UniqueIDGenerator") @Type(type = "com.test.persistence.ApplianceUUID") @Column(name = "UUID", nullable = false) protected ApplianceUUID uuid; @Column(name = "TYPE", nullable = false) private String type;
@Column(name = "VALUE", nullable = false) private String value;
@ManyToOne @JoinColumn(name = "JOB_ID", nullable = false, updatable = false, insertable = false) private JobSchedule job;
//Some other fields //getters and setters }
Any help is greatly appreciated.
Thanks Rohit
|