wood burning stoves*
The moose likes Object Relational Mapping and the fly likes how to assign compsite keys manually Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to assign compsite keys manually" Watch "how to assign compsite keys manually" New topic

how to assign compsite keys manually

vamshidhar nimbagiri
Ranch Hand

Joined: Oct 04, 2004
Posts: 61
i am using hiberate session.save() method and passing my mapping class object which contains the composite key.
hibernatesession.save(myclass); but its trhowing an exception saying

org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.wpsmedicare.corporate.entity.medicare.MedicareProvider
at java.lang.Throwable.<init>(Throwable.java:59)
at java.lang.Throwable.<init>(Throwable.java:73)
at org.hibernate.exception.NestableRuntimeException.<init>(NestableRuntimeException.java:100)
at org.hibernate.id.Assigned.generate(Assigned.java:32)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)

I have two classes one my mapping class and compositekey class which contains the composite fields info. plz tell me how to set this composite keys before inserting or calling save() method.

Thanks in Advance,

Vamshidhar Nimbagiri
SCJP 5.0
It is sorta covered in the JavaRanch Style Guide.
subject: how to assign compsite keys manually
Similar Threads
One to One not cascading on insert - IdentifierGenerationException
Problem with inserting new data into database using hibernate
spring + hibernate
NonUniqueObjectException in Hibernate