aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate create query method result in Stirng? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate create query method result in Stirng?" Watch "hibernate create query method result in Stirng?" New topic
Author

hibernate create query method result in Stirng?

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

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


No Kaustubh No Fun, Know Kaustubh Know Fun..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: May 13, 2010
Posts: 1270

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

Joined: Jul 20, 2005
Posts: 10113
    
165

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.

[My Blog] [JavaRanch Journal]
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Tahnks Jaikiran but do you know any such option in IE??? if you please let me know also

Thanks
Kaustubh
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10113
    
165

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

Joined: May 13, 2010
Posts: 1270

Thanks I'll take care of it dude..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate create query method result in Stirng?