Consulting Chapter 7 of "Hibernate in Action" (
https://forums.hibernate.org/viewtopic.php?f=1&t=965074), I used the following method:
Code:
String queryString = "SELECT A.id as (C.id), A.name as (C.name) from table_a A;"
Query query = HibernateUtil.getSession().createSQLQuery(queryString).addEntity("C", CCC.class);
CCC.java is something like this:
Code:
@Entity
public class CCC
{
@Id
private id;
private name;
//getter and setter....
}
It doesn't work with org.hibernate.exception.SQLGrammarException near (C.id).
Any solution for this? I wonder if the method in
viewtopic.php?f=1&t=943217&hilit=dynamic+dynamic+instantiation is the only solution. I don't want to use the xml since I have used annotation in all of my code.