users@glassfish.java.net

Re: Where are the SQL statements generated of the NamedQueries stored?

From: <glassfish_at_javadesktop.org>
Date: Mon, 18 Feb 2008 19:09:20 PST

TopLink generates the SQL dynamically during runtime. Although TopLink can cache the statements they are not really 'stored' anywhere. The easiest way to view the SQL is to turn on logging using the "toplink.logging.level" "finer" persistence unit properties. To get the SQL within your application you can call.
[code]
DatabaseQuery dbQuery = ((oracle.toplink.essentials.ejb.cmp3.EJBQuery)em.createNamedQuery("name")).getDatabaseQuery();
dbQuery.prepareCall(((EntityManagerImpl)em.getDelegate()).getServerSession(), new DatabaseRecord());
dbQuery.getSQLString();
[/code]
--Gordon
[Message sent by forum member 'gyorke' (gyorke)]

http://forums.java.net/jive/thread.jspa?messageID=259588