Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on hibernate

 
syruss kumar
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't initialize your cartItems property to a HashSet, let Hibernate decided what implementation it will use and code to the interface.
 
syruss kumar
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot paul,

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

java.lang.ExceptionInInitializerError
Caused by: org.hibernate.MappingException: could not instantiate id generator
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:97)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:182)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.Helper.sessionCreator.createSession(sessionCreator.java:16)
at com.DataAccessObjects.CartDAO.<clinit>(CartDAO.java:14)
Caused by: org.hibernate.MappingException: param named "property" is required for foreign id generation strategy
at org.hibernate.id.ForeignGenerator.configure(ForeignGenerator.java:82)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:93)
... 5 more





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

Can anyone help me to resolve this ?
Thanks in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic