-->
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: problem with Criteria.createAlias () method
PostPosted: Thu Dec 13, 2007 12:57 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
I have a weird problem. Here is my java class

Code:
public class Profile{
public Person person;
public Person personHead;
public Person deptHead;
}

public class Person{
  public String firstName;
  public String lastName;
}


My requirement is to: Query for Profile records and sort them on Person lastName. Now when I search for the following

Code:
List _results = (List)session.createCriteria(Profile.class)
.createAlias("person","person")
.addOrder(Order.asc("person.lastName"))
.list();


Error message
**************
Code:
SEVERE: ORA-00904: "PERSON1_"."LASTNAME": invalid identifier
Query-->select * from T_PROFILE this_ order by person1_.lastName desc


Where the following two works fine.
------------------------------------------------------------------------------
List _results = (List)session.createCriteria(Profile.class)
Code:
.createAlias("personHead","person")
.addOrder(Order.asc("person.lastName"))
.list();


Code:
Query--> select * from T_PROFILE this_ inner join T_PERSON person1_ on this_.personHead=person1_.id
order by person1_.lastName asc



Code:
List _results = (List)session.createCriteria(Profile.class)
.createAlias("deptHead","person")
.addOrder(Order.asc("person.lastName"))
.list();


This works fine.
-------------------------------------------------------------------------------

I have tried this. Still the same error message is coming:
Code:
List _results = (List)session.createCriteria(Profile.class)
.createAlias("person","per")
.addOrder(Order.asc("per.lastName"))
.list();


Is there any problem with createAlias method? It is giving error message when I give same name for alias and property?

Thanks


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.