• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate - Query Interface

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there !
I�m having problems on using the Query interface. When using the parameters facilities as coded below , Hibernate just doesn�t replace them by the variables values...

Query q = session.createQuery( "select * from Usuario where nome like '%:nome%'"
+ " and login like '%:login%'"
+ " and password like '% assword%'");

It doesn�t work...
q = q.setProperties(usuario); // It�s supposed to replace the parameters by the bean properties with the same names...

Nor this alternative works...

q.setString("nome", usuario.getNome());
q.setString("login", usuario.getLogin());
q.setString("password", usuario.getPassword());
When I debug the query, It is this way after the assignment :

select * from Usuario where nome like '%:nome%'and login like '%:login%'and password like '% assword%' ... with no replaces...
Any idea ?
Thanx in advance,
F�bio
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't want to drive you away F�bio, but have you tried the brand new Hibenate site?
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic