在 eclipse 的 toplink 中显示生成的 SQL
我在 eclipse 中使用 EclipseLink 库(在开发时)并部署在 TopLink 上,我需要显示生成的 sql 语句。
我正在使用以下 persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myPUnit" transaction-type="JTA">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>
<jta-data-source>jdbc/dcds</jta-data-source>
<properties>
<property name="toplink.cache.shared.default" value="false"/>
<property name="toplink.logging.level" value="FINE" />
</properties>
</persistence-unit>
</persistence>
我知道它应该显示生成的 sql 语句,但事实并非如此。
I am using EclipseLink libraries in eclipse (at dev time) and deploy on TopLink, I need to show the generated sql statement.
I am using the following persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myPUnit" transaction-type="JTA">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>
<jta-data-source>jdbc/dcds</jta-data-source>
<properties>
<property name="toplink.cache.shared.default" value="false"/>
<property name="toplink.logging.level" value="FINE" />
</properties>
</persistence-unit>
</persistence>
I know it should show generated sql statements, but this is not the case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要查看 JPA 查询的 SQL,您可以启用 FINE 或更低级别的日志记录。
要在运行时获取特定查询的 SQL,您可以使用 DatabaseQuery API。
该 SQL 将包含 ?对于参数。要使用参数翻译 SQL,您需要一个包含参数值的 DatabaseRecord。
来源:如何获取查询的 SQL
To see the SQL for a JPA Query you can enable logging on FINE or lower.
To get the SQL for a specific Query at runtime you can use the DatabaseQuery API.
This SQL will contain ? for parameters. To get the SQL translated with the arguments you need a DatabaseRecord with the parameter values.
Source: How to get the SQL for a Query
作为解决方法,请在此处查找生成的 SQL:
app_serv_home\j2ee\home\log\oc4j\log.xml
看:
http://m-hewedy .blogspot.com/2010/11/workaround-to-find- generated-sql-on-oas.html
As a workaround, find generated SQLs here:
app_serv_home\j2ee\home\log\oc4j\log.xml
see:
http://m-hewedy.blogspot.com/2010/11/workaround-to-find-generated-sql-on-oas.html