• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate query with Hardcoded result

 
Navanethan Muthusamy
Greenhorn
Posts: 11
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic