java IntelliJ IDEA 休眠
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3331174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IntelliJ IDEA Hibernate
提问by toomuchcs
I'm learning hibernate and I am running into some issues. I'm reading "Harnessing Hibernate" by O'Reilly. They explain everything using ANT, but since I want to avoid writing a huge build.xml file, I'm trying to get it to work with IntelliJ.
我正在学习休眠,但遇到了一些问题。我正在阅读 O'Reilly 的“Harnessing Hibernate”。他们使用 ANT 解释了所有内容,但由于我想避免编写巨大的 build.xml 文件,因此我试图让它与 IntelliJ 一起使用。
I managed to make a mapping according to a DB table in a MySQL database, and wrote the bean for it. It worked, but I can't find any information on how to generate beans and SQL code, or how to reverse engineer with IntelliJ. I found loads of tutorials about Eclipse, using JBOSS Hibernate tools plugin, and the site claims this support for generating code is already in the standard installation of IntelliJ.
我设法根据 MySQL 数据库中的 DB 表进行映射,并为其编写了 bean。它有效,但我找不到有关如何生成 bean 和 SQL 代码或如何使用 IntelliJ 进行逆向工程的任何信息。我找到了大量关于 Eclipse 的教程,使用 JBOSS Hibernate 工具插件,并且该站点声称这种生成代码的支持已经在 IntelliJ 的标准安装中。
Am I forgetting some configuration such as adding libraries? I'm trying to find this out but I'm desperate now. Please don't suggest me to use Eclipse, I need IntelliJ for my current role.
我是否忘记了一些配置,例如添加库?我正试图找出这一点,但我现在很绝望。请不要建议我使用 Eclipse,我目前的角色需要 IntelliJ。
采纳答案by Pascal Thivent
AFAIK, IntelliJ IDEA includes the complete JPA/Hibernate support in its Ultimate Edition:
AFAIK,IntelliJ IDEA 在其 Ultimate Edition 中包含完整的 JPA/Hibernate 支持:
Generating Persistence Mappings from Database Schema
IntelliJ IDEA allows you to quickly generate persistence mappings from any database schema: Generating Persistance Mappings
(source: jetbrains.com)
从数据库模式生成持久性映射
IntelliJ IDEA 允许您从任何数据库模式快速生成持久性映射:生成持久性映射
(来源:jetbrains.com)
Now, the question is, what edition of Intellij IDEA are you using?
现在,问题是,您使用的是哪个版本的 Intellij IDEA?
回答by duffymo
If you add the hbm2ddlto your Hibernate config and ask it to create the database schema you'll get it by running a single test or some other code that exercises Hibernate. Once you have it, turn off create.
如果您将它添加hbm2ddl到您的 Hibernate 配置并要求它创建数据库模式,您将通过运行单个测试或其他一些练习 Hibernate 的代码来获得它。一旦你有了它,关闭创建。
Let Hibernate do the work.
让 Hibernate 来完成这项工作。


