在Hibernate Spring应用程序中更新架构之前获取DDL [英] Getting DDL Before Updating the Schema in Hibernate Spring Applications

查看:113
本文介绍了在Hibernate Spring应用程序中更新架构之前获取DDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Spring-Hibernate应用程序中, log4j 属性文件中的 hibernate.show_sql = true 足以向hibernate显示生成的查询。但是,如果我们需要实际的sql查询,我们必须做什么(对于生产环境,我需要观察者并在更新模式之前验证查询)。

我要做的是,在生产中的第一个模式生成之后(通过hibernate本身),我不希望hibernate更新模式(DDL)。我想劫持更改,更新(DDL)查询和验证后,我想在数据库中手动运行这些脚本。
有没有办法做到这一点? log4j.properties 文件中添加以下配置:
$

b $ b

记录SQL语句
log4j.logger.org.hibernate.SQL = debug



记录传递给查询的JDBC参数
log4j.logger.org.hibernate.type = trace


$ b $


$ b

< property name =show_sql> true< / p <属性>



有关更多详细信息,请查看帖子


In a Spring-Hibernate application, hibernate.show_sql=true in log4j property file is enough to show to hibernate generated query. But what we have to do if we need the actual sql query.(For production environment i need to observer and verify the query before updating the schema).

What i am going to do is, after the first schema generation in production( by hibernate itself) i dont want hibernate to update the schema(DDL).I want to hijack the alter, update (DDL) queries and after verification i would like to run those scripts manually in DB. Is there any approach to do that?

解决方案

Add the following configurations in log4j.properties file

logs the SQL statements log4j.logger.org.hibernate.SQL=debug

Logs the JDBC parameters passed to a query log4j.logger.org.hibernate.type=trace

Enable the show sql property in hibernate configuration file as follows.

<property name="show_sql">true</property>

For more details, check the post

这篇关于在Hibernate Spring应用程序中更新架构之前获取DDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆