This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
 
Have you checked out Aspose?
 
subject: how to assign compsite keys manually
 
jQuery in Action, 3rd edition