-->
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.  [ 4 posts ] 
Author Message
 Post subject: "The method setResultTransformer(ResultTransformer) is
PostPosted: Mon May 19, 2008 12:48 pm 
Newbie

Joined: Wed Mar 12, 2008 3:24 pm
Posts: 2
My apologies if this is a FAQ. I've tried to search for an answer but I can't seem to find it.

I am trying to create a query that uses a result transformer using the following code:

org.hibernate.Query query = getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(hql).setResultTransformer(new MyTransformer());

however I'm running into an issue because I keep getting the following error:

"The method setResultTransformer(ResultTransformer) is undefined for the type Query."

We are currently using hibernate 3.something, but I don't know the exact version number (is there a way to find out programatically?). I am constrained to use the version provided, so upgrading to a newer version is not really an option.

Any ideas on what could be causing this?

Thanks,
Dave


Top
 Profile  
 
 Post subject: Try to use this :
PostPosted: Mon May 19, 2008 2:00 pm 
Newbie

Joined: Mon May 19, 2008 1:50 pm
Posts: 2
Location: Hyderabad
List cats = sess.createCriteria(Cat.class)
.createCriteria("kittens", "kt")
.add( Restrictions.eq("name", "F%") )
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
.list();
Iterator iter = cats.iterator();
while ( iter.hasNext() ) {
Map map = (Map) iter.next();
Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);
Cat kitten = (Cat) map.get("kt");
}
[/b]

_________________
Arindam Ghosh


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 2:24 pm 
Newbie

Joined: Wed Mar 12, 2008 3:24 pm
Posts: 2
So the answer is to use the criteria API to do the query? If so, I guess that's a work around. Personally I find the criteria API to be more opaque and harder to understand than writing queries.

Also, if this is *NOT* a bug, and Query really does not have, and is not intended to have a setResultTransformer() method, will the Javadocs be updated to reflect that setResultTransformer() is *NOT* a method in the Query class?

Thanks for your response.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 5:19 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, this can't really be a bug, if I understood your issue you have some problems in your environment settings.
your code compiles, right? This means that when you are compiling your sources you have a hibernate version on your classpath containing a org.hibernate.Query HAVING the method.
It is possible that you are missing this method on the environment where you run you compiled code; so you should check you have the same hibernate versions in your developer environment (ide?) and your testing/staging/production.

Quote:
I am constrained to use the version provided

That's possible, but you have to define ONE version; of course if the provided version is "old" you may lack some features.

kind regards

_________________
Sanne
http://in.relation.to/


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