1

Is there a way to view the underlying SQL generated by a javax.persistence.Query object?

In other words, I have the following EJB QL query:

SELECT f FROM FunkyObject f where f.id = 4

I would like to see something like this:

SELECT funky_object.id, funky_object.name, funky_object.some_int_col
  FROM funky_object
WHERE funky_object.id = ?

I see something like this in my log file when there's an error executing a query.

I would like to know how I can see the same info for a valid query.

I'm using EJB with TopLink on Sun Application Server (JEE5).

Thanks in advance...

jahroy
  • 22,322
  • 9
  • 59
  • 108
  • 1
    http://stackoverflow.com/questions/4255541/show-generated-sql-in-toplink-in-eclipse – raddykrish May 10 '12 at 03:52
  • Thanks @raddykrish... Unfortunately my machine does't have any path that resembles the one mentioned in that thread. – jahroy May 10 '12 at 04:05
  • 1
    hope you have already tried in the persitence.xml – raddykrish May 10 '12 at 04:45
  • Yep, that did the trick. I don't get the log file, but I added that property to my persistence.xml and started seeing my generated SQL. Got it working just before I left work... Just getting home to say thanks now! – jahroy May 10 '12 at 04:56

0 Answers0