-->
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: How to determine Hibernate type at runtime
PostPosted: Tue Mar 16, 2004 5:57 pm 
Newbie

Joined: Mon Mar 15, 2004 5:48 am
Posts: 9
I am trying to write an accessor class for Hibernate using Java Generics. What I would like to write is something like this:

List<DataClass> dataList = (List<DataClass>) session.find(
"from " + this.classObj.getName() + " as objclass where objclass." + this.realKeyName + " = ?",
key, Hibernate.entity(key));

But Hibernate.entity doesn't work for simple key types like String, so instead I have to do this:
List<DataClass> dataList = (List<DataClass>) session.find(
"from " + this.classObj.getName() +
" as objclass where objclass." + this.realKeyName + " = '" + key +"'");

Is there any way to dynamically determine the correct Hibernate type other than write my own function to do the mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 6:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
SessionFactory.getClassMetadata()


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.