Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate create query method result in Stirng?

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public List fetchMsgIdentifierByMessageId(Integer strWhereClause){//added for CNR report to get messagecategory from messagemaster
List lstCode = null;
String strQuery = null;

try {
if(strWhereClause != null){
strQuery = "select messageCategory, messageNumber from MessageMaster where messageId= " +strWhereClause ;
}

lstCode = sessionFactory.getCurrentSession().createQuery(strQuery).list();
sessionFactory.getCurrentSession().flush();
return lstCode;
} catch (RuntimeException re) {
throw re;
}
}



Hi I am using above method to get some data from one of my table in DB. Now if you see the red line in my code is creating some problem for me actually we're using hibernate in our application and when the marked line executes it will return the result as a list now I tried every function of it but that will not return the result in string it has some functions that return string but it is not the result is return the hole query string to me. Is there any way out so that I can get the result as a string or simply execute the above query...???

Hope you get it right.....or please let me know
Thanks
Kaustubh
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

It's not clear to me what you're asking: the list() method returns a list. So does the method you're returning it from. Whatever calls that method should turn it into a string; how it does so depends on how you want to marshal the returned data into string format.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I made spell mistakes on lot of places. It will be great to have spell checker on javarach before submitting the queries and if there's any such option available please let me know.

Thanks
Kaustubh
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kaustubh G Sharma wrote:Sorry I made spell mistakes on lot of places. It will be great to have spell checker on javarach before submitting the queries and if there's any such option available please let me know.


I use Firefox and when I use the forum editor, Firefox by default has spell check enabled. I can see my typos marked with a red underline while I am writing the post.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tahnks Jaikiran but do you know any such option in IE??? if you please let me know also

Thanks
Kaustubh
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kaustubh G Sharma wrote:Tahnks Jaikiran but do you know any such option in IE??? if you please let me know also



I haven't used IE in ages. However, I just did a google search for "spell checker in IE" and the first search result was a link to a IE plugin.

Kaustubh G Sharma wrote:
Tahnks ...


In the absence of a spell checker, it's a good habit to do a quick check (proof read) on what you have typed. Of course, not all spelling errors can be caught that way, but I am sure you can easily notice typos like the one above.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I'll take care of it dude..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic