增强Hibernate数据库模式? [英] Enhance Hibernate Database Schema?

查看:100
本文介绍了增强Hibernate数据库模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为测试使用Hibernate(JPA2) hibernate.hbm2ddl.auto = update 并且 hibernate.hbm2ddl.auto = validate for production。



我想要做的是,使用一个附加表(未映射到实体)扩展生成的模式,以便该表这是可能的,以及如何?

解决方案

是的,可以使用辅助数据库对象。我为这个主题撰写了博文,因为文档不是最好的。



编辑:另一个未公开的Hibernate功能,我没有在该博客中提及:如果在根目录中包含名为import.sql的文件您的类路径在运行Hibernate模式导出时,它也会执行该文件中的语句。


I'm using Hibernate (JPA2) hibernate.hbm2ddl.auto=update for test and hibernate.hbm2ddl.auto=validate for production.

What I want to do is, extending the generated schema with an additional table (that is not mapped to an entity) so that this table is generated for the tests and verify for production.

Is this possible, and how?

解决方案

Yes, it's possible using "auxiliary database objects". I wrote a blog post on the topic because the documentation wasn't the greatest.

Edit: One other undocumented feature of Hibernate that I didn't mention in that blog: if you include a file named "import.sql" in the root of your classpath when you run a Hibernate schema export, it will also execute the statements in that file.

这篇关于增强Hibernate数据库模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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