Otherwise you can enable it in the logging:

log4j.logger.org.hibernate.SQL=DEBUG

On Tue, Feb 10, 2009 at 7:50 AM, Derek Chen-Becker <dchenbec...@gmail.com>wrote:

> Interesting idea. I'll look into adding something like this (configurable
> at boot and/or runtime) into scalajpa.
>
> Derek
>
>
> On 2/9/09, Oliver <ola...@gmail.com> wrote:
>>
>>
>> Hi Derek and interested parties
>>
>> I know there is a showSQL option that can be enabled with
>> JTA/Hibernate but I find the output verbose and uninformative about
>> parameter replacement.
>>
>> So, I have my own ScalaQuery that allows simple debugging - the main
>> differences are -
>>
>>     var queryParams: List[Pair[String,Any]] = Nil
>>    /*  the following method needs to be called by the various
>> SetParameter methods */
>>     def addParam(one: String,two: Any) = {
>>         query.setParameter(one, two)
>>         queryParams = (one, two) :: queryParams
>>     }
>>     /*
>>      output the query with parameters substitued, for debugging ...
>>      */
>>     def getQueryWithParams() = {
>>         var q = queryStr
>>         try {
>>             queryParams.foreach{v =>
>>                 var rep = v._2 match {
>>                     case d: Date => "'"+SUtil.formatDate(d,
>> "dd/MM/yyyy")+"'"
>>                     case s: String => "'"+s+"'"
>>                     case x => if (x==null) "" else x.toString
>>                 }
>>                 rep = rep.replaceAll("\\$", "ddDollardd") // stupid bug
>>                 q = q.replaceAll(":"+v._1, rep)
>>             }
>>             q.replaceAll("ddDollardd", "\\$")
>>         } catch {
>>             case e: Exception => q+" PARAMS "+queryParams+ " EXCEPTION "+e
>>         }
>>     }
>>
>> With this I can log the query via
>>   Log.info(emailQuery.getQueryWithParams())
>>
>> Better still, (assuming execOnce exists in a utility object) when I
>> only need to see the query once in the log
>>     /*
>>      execulte execFn, just once for the jvm.
>>      */
>>     val execOnceSet = scala.collection.mutable.Set("")
>>     def execOnce(key: String, execFn: => Unit) = {
>>         if (!execOnceSet.contains(key)) {
>>             execOnceSet += key
>>             execFn
>>         }
>>     }
>>
>>   execOnce("findByEmail",  Log.info(emailQuery.getQueryWithParams()) )
>>
>>
>> You can add the functionality if you find it useful
>>
>> cheers
>> Oliver
>>
>>
>> >>
>>


-- 
Viktor Klang
Senior Systems Analyst

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to