-->
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: Regarding createSQLQuery function
PostPosted: Tue Mar 30, 2004 11:30 am 
Newbie

Joined: Fri Feb 20, 2004 10:07 am
Posts: 17
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();

------------


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.