Hello-
Can somebody provide me with examples of createSQLQuery function.
I am trying to convert an SQL query, which joins multiple tables, to Hibernate query using createSQLQuery(,,).list() and am getting errors at runtime.
The error message and the java code is placed below.
I must be making some mistakes in creating the query.
Sample Java code might help me.
I will appreciate if somebody can point out where I am wrong.
regards,
Amitabh.
-----------------error message---------------
net.sf.hibernate.QueryException: No column name found for property [firstName] [SELECT {gm}.groupName AS {gm.groupName}, {gm}.id AS {gm.id}, {gm}.groupAdminId AS {gm.groupAdminId}, {m}.firstName AS {m.firstName}, {m}.lastName AS {m.lastName} FROM groupmaster {gm} join member {m} on ({m}.id={gm}.groupAdminId) join groupmembers {g} on({g}.groupId={gm}.id) where {g}.memberId=16]
------------java code----------------------------------------
String[] objs=new String[3];
objs[0]="gm";
objs[1]="m";
objs[2]="g";
Class[] cls= new Class[3];
cls[0]=GroupMaster.class;
cls[1]=GroupMembers.class;
cls[2]=Member.class;
List membersGroups = hSession.createSQLQuery("SELECT {gm}.groupName AS {gm.groupName}, {gm}.id AS {gm.id}, {gm}.groupAdminId AS {gm.groupAdminId}, {m}.firstName AS {m.firstName}, {m}.lastName AS {m.lastName} FROM groupmaster {gm} join member {m} on ({m}.id={gm}.groupAdminId) join groupmembers {g} on({g}.groupId={gm}.id) where {g}.memberId="+member.getId().intValue(),objs,cls).list();
------------
|