aspose file tools*
The moose likes Object Relational Mapping and the fly likes Criteria to SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Criteria to SQL" Watch "Criteria to SQL" New topic
Author

Criteria to SQL

Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 73
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

Joined: Dec 25, 2010
Posts: 90

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


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Also see,

http://wiki.eclipse.org/EclipseLink/FAQ/JPA#How_to_get_the_SQL_for_a_Query.3F

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 73
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)?


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Criteria to SQL