Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Exception - java.lang.Object cannot cast to

 
Kishen Singh Punjabi
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Below is the table
CREATE TABLE MyTable(
'a_id' varchar(50) NOT NULL,
'b_id' varchar(100) NOT NULL,
'my_field' varchar(1) DEFAULT '0',
PRIMARY KEY ('a_id','b_id'));


Values will be
a_id - b_id - my_field
aa - b1 - N
aa-b2-N
aa-b3-Y
aa-b5-N
pp-q1-Y
pp-q2-N
pp-q3-N
pp-q4-B

I want to have two Java beans as
Pojo1.java



Pojo2.java



I want to retrieve the a_id for a given b_id (I'm am able to retrieve this)
I want to retrieve the List of pojo2 for a single a_id (Have issue with this)

My Java Code which throws java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to pojo2




Below is the hibernate file for MyTable




Please help in correcting my mapping file or Java code.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrithik,
This doesn't return a MyTable object. It returns two fields that happen to be in MyTable


This returns a MyTable object.


I'm also not seeing where you map Ppjo2 to MyTable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic