-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Load with other argument then integer
PostPosted: Fri Mar 27, 2009 1:49 am 
Newbie

Joined: Fri Mar 27, 2009 1:42 am
Posts: 1
Hi

I am use hibernateTemplate.load(User.class, userId)

and get the user object
but

now I want to use this method or any other method in hibernate template for username which is not primary key but unique value in database.

like hibernateTemplate.load(User.class, userName)

but its not possible and its give me exceptinon that :

org.springframework.orm.hibernate3.HibernateSystemException: Provided id of the wrong type for class gd.bean.User. Expected: class java.lang.Integer, got class gd.bean.User; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type for class gd.bean.User. Expected: class java.lang.Integer, got class gd.bean.User

can any one give me idea... how to do that.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 27, 2009 2:23 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Hi,
method load(Class, Seriliazable) is used to retrieve data by ID. To retrieve the data by other field, you should use Criteria / Query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.