• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MS SQL server bind variables

 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying set up a query with bind variables in hibernate. This query searches a view in an MS SQL server database.

I used setparameter method of the SQLquery class but the resultset returns empty.

I then added the parameter directly to the query, like so:



and it works.

Is there any way of using bind variables here?

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bind variables should just work. What driver are you using? Can you post your code?
 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my config file:



I have sqljdbc4.jar in my classpath.

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and your code?
 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the sessionfactory:




Here's the DAO method:


The above method throws the following exception:


I dont know if this helps, but the column names in the view are aliases.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic