java - 如何通过 Hibernate 逆向工程使用 Hibernate 工具为“Single DB”生成模型代码
问题描述
我通过JBoss Tools > Hibernate Tools使用Hibernate 逆向工程来生成模型类。
在那里,当我添加 Hibernate 配置并运行它/重建它时,它会列出所有 DB,尽管我在 hibernate.cfg.xml 的 hibernate.connection.url 中只提到了一个 DB。例如:jdbc:mysql://localhost:3306/booksdb。
休眠.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/booksdb</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.connection.password">xxxx</property>
</session-factory>
</hibernate-configuration>
然后,当我生成实体代码时,它还会扫描所有其他数据库表以生成所有实体代码。有时它会受到不同数据库中的一些重复表的影响。
问题: 如何对 hibernate.connection.url 中提到的单个数据库执行此操作?
休眠版本:5.4
MySQL 版本信息
- innodb_version:5.7.26
- 协议版本:10
- 版本:5.7.26-0ubuntu0.18.04.1
- 版本评论:(Ubuntu)
- version_compile_machine:x86_64
- version_compile_os:Linux
解决方案
推荐阅读
- go - 无法构建具有外部模块本地副本的项目
- regex - How to grep only the desired position match in a single line, where there is multiple matches, using regex?
- log4j - Is there a log4j appender for Moogsoft?
- javascript - Create directory recursively if it does not exist?
- python-3.x - Scrapy shell
is running all of the spiders in my 'spiders' folder - git - git branche's files doesn't appear in my local
- excel - If/And functions are not working correctly in my formula, can someone help me?
- angular - 延迟加载模块上的角度子路由未加载
- c# - C# 对 JSON 响应字符串进行排序
- oauth-2.0 - Alexa Skill Activation API 中的 redirect_uri 是什么?