目录"不&QUOT运行休眠工具注释生成;属性 [英] Running hibernate tool annotation generation without the "catalog" attribute

查看:97
本文介绍了目录"不&QUOT运行休眠工具注释生成;属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的休眠工具
它从数据库中读取并为每个表创建Java类,
和复合主键的Java类。
这是伟大的。

when i run my hibernate tools it reads from the db and create java classes for each tables, and a java class for composite primary keys. that's great.

问题是这一行

@Table(name="tst_feature"
    ,catalog="tstdb"
)

而需要的表名称,则不需要目录属性。
有时我想用tstdb,有时我想用tstdev

while the table name is required, the "catalog" attribute is not required. sometimes i want to use "tstdb", sometimes i want to use "tstdev"

我认为是选择何种数据库依赖于JDBC连接URL
但是,当我改变JDBC URL指向tstdev,它依然使用tstdb

i thought which db was chosen depends on the jdbc connection url but when i change the jdbc url to point to "tstdev", it is still using "tstdb"

那么,
我知道必须做什么,
只是不知道它是怎么做的
我的选择是

so, i know what must be done, just don't know how its is done my options are


  • 燮preSS目录属性的生成
    目前我手动做这个(不太高)
    或者我可以写一个分析Java文件的程序,并手动删除该属性
    但我希望我不必


  • 找到一个方法来告诉Hibernate忽略目录属性和使用显式指定的模式。
    我不知道确切的设置,我必须要改变才达到这一点,或者即使该选项可用。

推荐答案

您需要按照3个步骤 -

You need to follow 3 steps -

1)在hibernate.cfg.xml文件中,添加该属性。

1) In the hibernate.cfg.xml, add this property

hibernate.default_catalog = MyDatabaseName
(如上述交指定)

hibernate.default_catalog = MyDatabaseName (as specified in above post)

2)在hibernate.reveng.xml中,添加所有表滤波器这样

2) In the hibernate.reveng.xml, add all the table filters like this

表过滤器匹配名称=MyTableName
(仅此,没有目录姓名)

table-filter match-name="MyTableName" (just this, no catalog name here)

3)重新生成hibernate的code

3) Regenerate hibernate code

您不会看到任何的*的.hbm.xml文件中的任何目录名称。

You will not see any catalog name in any of the *.hbm.xml files.

我已经使用Eclipse的伽利略和Hibernate-3.2.4.GA。

I have used Eclipse Galileo and Hibernate-3.2.4.GA.

这篇关于目录"不&QUOT运行休眠工具注释生成;属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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