[jboss-user] [EJB 3.0] - Re: OneToMany Unidirectional EntityManager remove() problem

rkiran81 do-not-reply at jboss.com
Thu May 22 02:40:00 EDT 2008


Hi JaiKiran,

Thanks for your reply. 
 With Child PROFILE_ID (parent id) column Allowing Not Null values, below is the code and stack trace.
  | 
  | @OneToMany(cascade = {CascadeType.ALL})
  | @JoinColumn(name="PROFILE_ID")
  | @org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
  | public Collection getQueryProfileBean()
  | {
  | return queryProfileBean;
  | }
  | 11:44:13,310 WARN  [JDBCExceptionReporter] SQL Error: 515, SQLState: 23000
  | 11:44:13,310 ERROR [JDBCExceptionReporter] Cannot insert the value NULL into column 'PROFILE_ID', table 'QAUsers.dbo.LK_
  | PROFILE_QUERY'; column does not allow nulls. UPDATE fails.
  | 11:44:13,325 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
  | org.hibernate.exception.ConstraintViolationException: could not delete collection rows: [com.bis.dbservices.domainprofil
  | edao.DomainProfileBean.queryProfileBean#7106370]
  |         at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
  |         at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  |         at org.hibernate.persister.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:11
  | 40)
  |         at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:54)
  |         at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
  |         at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
  |         at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
  |         at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
  | 7)With Child PROFILE_ID (parent id) column Allowing Null values, below is the code.
  | 
  | @OneToMany(cascade = {CascadeType.ALL})
  | @JoinColumn(name="PROFILE_ID")
  | public Collection getQueryProfileBean()
  | {
  | return queryProfileBean;
  | }
  | 
  | Works fine.

org.hibernate.annotations.CascadeType.DELETE_ORPHAN is not helping in any way. Just make the parent id in child table to allow null and CascadeType.ALL will do the job.

It actually inserts null and then deletes the column. This is what i found.

Even am trying to find any other way for this ie.. with parent id column to allow nulls, if you get any idea on this please update the same.

Thank you very much for your support.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152550#4152550

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152550



More information about the jboss-user mailing list