• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Updates work but save throws java.lang.ClassCastException: java.lang.String incompatible  RSS feed

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a hibernate object



Updates work but saves throw an exception java.lang.ClassCastException: java.lang.String incompatible with com.project.test.A
 
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Updates work but saves throw an exception...


How do you get it to save before the update anyway? Or you may need to tell more details about this scenario...
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed this issue but it looks like a hack to me.. I used native SQL query to insert.



Hey Vijitha, To test the update I manually inserted the values into the database and then did an update. It worked, so basically sessionFactory.getCurrentSession().update works but sessionFactory.getCurrentSession().save throws a class cast exception.
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it has something to do with the primary key. It fails for all the tables where I don't have a sequence number generator and I manually enter the primary key.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!