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