File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to assign compsite keys manually" Watch "how to assign compsite keys manually" New topic
Author

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


Thanks,
Vamshidhar Nimbagiri
SCJP 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to assign compsite keys manually