Hibernate issues with composite primary key?

If you aren't going to need in the same Hibernate Session the objects once saved, you could detach them right after saving with Session.evict().

Up vote 0 down vote favorite share g+ share fb share tw.

I am facing some issues with Hibernate. We need to save an object with its children. Each child has a composite primary key.

One property of the key will be inserted by a trigger. Another property will be set from the program before calling saveOrUpdate(Object). But we are not able to save the object.

Hibernate throws the exception Same identifier is already exists in the session. I have tried session.clear(), but I get the same exception. When I tried session.merge(), only the last child was saved, others were ignored.

Java hibernate link|improve this question edited Oct 27 '11 at 16:21eykanal5,71111328 asked Oct 27 '11 at 12:02Tyrant182.

Can you publish the hbm files or java of the object you are trying to save. – ManuPK Oct 27 '11 at 13:16.

If you aren't going to need in the same Hibernate Session the objects once saved, you could detach them right after saving with Session.evict(): // children is the collection of detached children, ready to save for (Child child : children){ session. Save(child); session. Evict(child); } Alternatively, this entry in the Hibernate Forums might be helpful: Before Insert Trigger and ID generator.

There's an implementation of an AbstractPostInsertGenerator you can integrate to suit your needs.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions