It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Doubt on hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Doubt on hibernate" Watch "Doubt on hibernate" New topic

Doubt on hibernate

syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 100
Hi all,

I have return a class in which i have 2 tables 1.Cart_new 2.cart_items.primary key of cart_new is mapped as a foreign key to cart_items

While im trying to get the values i got this error.

Exception in thread "main" java.lang.ClassCastException: org.hibernate.collection.PersistentSet cannot be cast to java.util.HashSet

Can't we cast that?
Can any one suggest me ?
Thanks in advance

All search starts with beginner's luck and all search ends with victor's severly tested.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Don't initialize your cartItems property to a HashSet, let Hibernate decided what implementation it will use and code to the interface.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 100
Thanks a lot paul,

i have resolved that issue but while i tried to save that i got could not instantiate id generator exception.

Caused by: org.hibernate.MappingException: could not instantiate id generator
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(
at org.hibernate.impl.SessionFactoryImpl.<init>(
at org.hibernate.cfg.Configuration.buildSessionFactory(
at com.Helper.sessionCreator.createSession(
at com.DataAccessObjects.CartDAO.<clinit>(
Caused by: org.hibernate.MappingException: param named "property" is required for foreign id generation strategy
... 5 more

i surfed in the net but couldnt resolved this .
is it a jar using hibernate3.jar

Can anyone help me to resolve this ?
Thanks in advance
It is sorta covered in the JavaRanch Style Guide.
subject: Doubt on hibernate
It's not a secret anymore!