gpt4 book ai didi

java - JPQL 到 SQL 转换器

转载 作者:搜寻专家 更新时间:2023-10-31 08:24:49 25 4
gpt4 key购买 nike

是否可以访问由 JPQL 生成的 SQL?

我想稍后使用 SQL 创建一个 View 以供我使用。

如果重要的话,我会使用 Hibernate。

最佳答案

Is it possible to access the SQL which is generated by JPQL?

您可以从 Hibernate Interceptor 访问 SQL String,更准确地说是从方法 Interceptor.html#onPrepareStatement(java.lang.String)

onPrepareStatement

String onPrepareStatement(String sql) Called when sql string is being prepared. Parameters: sql - sql to be prepared Returns: original or modified sql

If you decide to go this way, the best option is to extends EmptyInterceptor and to override only the methods you want.

You can hook your interceptor using the following declaration in your persistence.xml:

<properties>
<property name="hibernate.ejb.interceptor" value="com.acme.MyInterceptor"/>
</properties>

关于java - JPQL 到 SQL 转换器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2367801/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com