File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Save QueryString as String ?

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
With



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: 157
configure a file appender


R6i
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
Bartender

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
hello,

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

http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-toolbox.html?page=1

thanks.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Save QueryString as String ?
 
Similar Threads
Hibernate entity manager: call to find() and showing SQL
How to Convert HQL to SQL Query
Hibernate keeps updating database.
Hibernate SQL
Hibernate and java.util.Logging