File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Save QueryString as String ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Save QueryString as String ?" Watch "Save QueryString as String ?" New topic

Save QueryString as String ?

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580

all sql-statements are printed to my console. This is fine.

But how can I save that sql-string in a common String value?

Something like:

Any Ideas??
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 160
configure a file appender

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
So I have to configure a FileAppender (via log4j),
write the query statements to that file and read that statements from the file again?

Not very conveniently? Is there no other way to get the string value (what Hibernate, JPA) in a direct way?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Why use a FileAppender? Just write a custom appender and have that communicate with your code.

There is no way to get Hibernate to do this for you. Doing anything (beyond logging) with the SQL generated by your JPA implementation kind of doesn't make sense which is probably why there is no out the box way of doing it.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580

custom file appender..I must admit I do not have great knowledge about such things..but I will learn


I agree. Here's the link:
subject: Save QueryString as String ?
It's not a secret anymore!