-->
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: returnMaps() alternative
PostPosted: Thu Aug 11, 2005 7:07 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 3:15 pm
Posts: 29
Below is an example in the hibernate v3 documentation. returnMaps() is no longer used. Can someone give me an example of how to do this in Hibernate3?
Thanks,
B


List cats = sess.createCriteria(Cat.class)
.createCriteria("kittens", "kt")
.add( Restrictions.eq("name", "F%") )
.returnMaps()
.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");
}

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 7:31 pm 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
Is this what you're looking for?

http://www.hibernate.org/hib_docs/v3/ap ... ENTITY_MAP


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 8:14 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 3:15 pm
Posts: 29
YES!

So now we have:

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");
}


Simple when you know what to look for. :(

Thanks,
B

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 5:49 pm 
Newbie

Joined: Wed Nov 16, 2005 10:58 am
Posts: 10
is there a way to do something like ALIAS_TO_ENTITY_MAP with query results?

thanks
b.


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.