aspose file tools*
The moose likes Object Relational Mapping and the fly likes Bad sql grammer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Bad sql grammer" Watch "Bad sql grammer" New topic
Author

Bad sql grammer

raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi All,

My project involves struts1.2,springs1.2,hibernate 3.0

To display few details in the jsp page , i wrote a query in dao layer and created the related pojo files and hbm files etc
query is :

" select billingaddress.billingaddressLine1,billingaddress.billingaddressLine2,billingaddress.city,billingaddress.firstName,billingaddress.middleName,billingaddress.lastName,"+
" billingaddress.pager,"+
" billingaddress.altPhone,billingaddress.officePhone,billingaddress.cellular,"+
" billingaddress.state,billingaddress.zip,billingaddress.email"+
" from SBBillingAddress billingaddress"+
" where memberid =?"

Below i mention the exception



Reagrds,
raj chopra
Sai Rao
Greenhorn

Joined: Mar 23, 2007
Posts: 4

Hello Raj, Have you checked if the table SBBillingAddress has a field labelled 'Memberid'? Or is it 'member_id'? Please verify the column name used - it seems to be the likely cause of the error you have posted.
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi sai,

thanks for reply,

Sai Rao wrote:Hello Raj, Have you checked if the table SBBillingAddress has a field labelled 'Memberid'? Or is it 'member_id'? Please verify the column name used - it seems to be the likely cause of the error you have posted.


I have cross checked my table in database, pojo class(SBBillingAddress), and hbm file(SBBillingAddress.hbm.xml) all are fine.
also one more thing is that memberid is defined as primary key in hbm file.
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
In your query use "where billingaddress.memberid =?" instead of "where memberid =?"
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi prashanth,
Thanks for reply,

Reddy Prashanth wrote:In your query use "where billingaddress.memberid =?" instead of "where memberid =?"


Problem got solved.thanks a ton
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad sql grammer