Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Hibernate query with Hardcoded result

 
Greenhorn
Posts: 11
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you tell how do I write a hibernate query like

String name = "John";

List list = session.createSQLQuery("Select '+ name +' as Name from Emp")
.addScalar("name")
.setResultTransformer(Transformers.aliasToBean(EmpBean.class)).list();



FYI: In EmpBean class I have String getter and setter method for name.

Problem:
----------
In this query expecting char setter and getter in EmpBean class, because of single quote.

and when i try to add addScalar("name", Hibernate.STRING) its showing that deprecated.


Can you please let me know how do i manage this case.

Thanks,
Navanethan
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic