File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass request parameters to Query

 
Kir Swa
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam trying get records from DB based on request parameter. Here is my code

at line 1 iam getting exception:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'O0001' in 'where clause'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)...........

I executed same Query in MySQL, there it is working, and the Query is SELECT * FROM tablename WHERE id='O0001'; How will i write same Query(passing request parameter instead of entering manually) in createQuery()

Iam new to Hibernate. Can someone help me in finding the solution.

Thanks



 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. I have added them for you this time so you can see the difference in readability.

Try using named parameters.


This assumes that your OrderBean object has a property named 'id' also if this is the case are you really expecting a list here or a single result. If the latter have a look at doing something like this instead.


.
 
Kir Swa
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill, Its working now.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic