Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate error

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys iam facing an error
while casting a collection

below shows the code




below shows the stack trace

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of Set does getProductTracks() return? What HashSet have you imported into your class? A Hibernare PersistentSet does not extend HashSet, so you can't cast from one to the other.
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getProductTracks() returns Collection
but i have tried with casting ArrayList also iam getting the same error

thanks
amir
[ April 23, 2008: Message edited by: Amirtharaj Chinnaraj ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why is dbTrackCollections defined as a HashSet? Chould it not be a Collection too?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Run a getClass() method call on the object before the cast and see what object type is being returned. It may not be what you expect!

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic