posted 15 years ago
Hi Mark,
Its still not working. Following are the changes I made.
Invoice.hbm.xml
Sales.hbm.xml
Note, I tried different ways of creating the many-to-one relation, like giving the column name as well etc. the inverse tag was only applicable for the one-to-many side of the relation, so I have put it on the Invoice hbm.
Exception
org.hibernate.AssertionFailure: null id in com.postsales.domain.model.Sales entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:157)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
Right now as a workaround, I am treating these as two separate tables, removed the relationship mapping from the hbm, I have the transaction management at the service level so I believed that it will handle things, of making it as a single transaction, and so updating them separately as two tables just as we do in database just go and insert one record, and use that id and update the table with the foreign key.
In my Dao, I have the following:
I know thats a bit crude way of doing it, but its working for me. Do comment on my xml if you think any changes would help me.
thank you,
Kavitha.