Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Criteria to SQL

 
Alex Armenteros
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to log the querys I make in a blaze servlet.

Any way to get the sql string from a criteria? I got it before but without the parameters (something like "where con1<?")

Thank you for your time.
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex.

It depends by the way you persistence provider log the information and the level of the log, generaly you need to add some properties to the persistence unit in the persistence.xml to log the sql generated with the parameters, for example for openjpa you need to add these properties: and for eclipselinkI hope this help you with your question.
Kind regards.
Cesar
 
Alex Armenteros
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, my post is a bit short on info...

I'm using Hibernate with annotations (I don't like hibernate mapping files)

And making querys like

The class is a subclass of org.springframework.orm.hibernate3.support.HibernateDaoSupport

Is there anyway to make a function like this... String criteriaToSQL(Criteria cr)?


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic