-->
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.  [ 1 post ] 
Author Message
 Post subject: Is createAlias superfluous in the Criteria API?
PostPosted: Tue Apr 19, 2005 5:43 am 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
Hibernate version:3

The javadocs for the Criteria API have
Code:
You may navigate associations using createAlias() or createCriteria()
...

List cats = session.createCriteria(Cat.class)
     .createAlias("kittens", "kit")
     .add( Restrictions.like("kit.name", "Iz%") )
     .list();


I was wondering why Hibernate requires the user to create aliases for nested properties. Can't it internally create aliases for column properties if required? I'd like to be able to do the following

Code:
List cats = session.createCriteria(Cat.class)
     .add( Restrictions.like("kittens.name", "Iz%") )
     .list();


Same goes for addOrder:

Code:
crit.addOrder(Order.asc("kittens.name));


I'm constructing these Criteria's programatically for some generic sort/filter functionality and have access to the nested properties. Creating aliases seems like a redundant step. I'm sure is there for a resaon, just dont know what it is?

Thanks,
Sanjiv


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.