-->
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: Quary by Primary Key
PostPosted: Thu Sep 15, 2005 10:04 am 
Beginner
Beginner

Joined: Thu Apr 14, 2005 11:39 am
Posts: 31
Hi,

I am using Spring HibernateTemaplate class. I need to quesry database with my primary key. I am trying to use get or load methods.But model class does not have serelizable id defined. Is there any other simple methods without writinf "from table name where pk=xxx" ?

Code:

public Templatedetail searchTemplateByPK(String templateid) throws InfrastructureException {

try {

Templatedetail obj = (Templatedetail)getHibernateTemplate().get(Templatedetail.class, ???);
} catch (DataAccessException e) {
e.printStackTrace();
throw new InfrastructureException(e);
}
return obj;
}

In the model class this was defined as : private Long templateid;

Thanks
Sudhakar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 10:17 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
java.lang.Long IS (implements) Serializable. So I'm not sure I understand what your problem is. Just pass a Long in for the ??? in your example code...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 12:02 pm 
Beginner
Beginner

Joined: Thu Apr 14, 2005 11:39 am
Posts: 31
Yeah I also figured from this chapter. http://www.hibernate.org/hib_docs/v3/re ... ersistence


Thnaks for your reply.

Sudhakar


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.