-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: ClassCastException
PostPosted: Fri Nov 16, 2007 10:29 am 
Newbie

Joined: Fri Nov 16, 2007 10:21 am
Posts: 1
Hello,
I have a problem saving a bean User. I use the following code:

UserDao dao = new UserDao();
User user = new User();
Service.populate(user);
dao.save(utente);
if(user != null){
return SUCCESS;
}

here is the dao.save method:


public User save(User user){
Utente newuser = null;
begin();
newuser = (User)getSession().save(user);
commit();
close();
return newuser;
}

this code throws a ClassCastException: java.lang.Long
I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me?


Top
 Profile  
 
 Post subject: Can u plzzzz.......
PostPosted: Sat Nov 17, 2007 12:28 am 
Newbie

Joined: Tue Nov 13, 2007 7:25 am
Posts: 8
Location: Bhubaneswar
Okay dude.... Can u please tell the line where its throwing ClassCastException .......

_________________
Regards
Lalit Narayan Mishra


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 17, 2007 7:52 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Quote:
newuser = (User)getSession().save(user);

The save() method returns the primary key of the saved entity, not the entity itself.

And this is clearly wrong:
Code:
User user = new User();
...
if(user != null){
  return SUCCESS;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.