This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Doubt on hibernate

 
Ranch Hand
Posts: 108
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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: 108
  • 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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic