netbeans 6.5.1 反向引擎 Oracle 实体
我是反向引擎实体类,但主键没有用 GenelatedValue 注释。我的表是在oracle上创建的。我是否需要在表主键上添加自动增量约束?
现在我手动编辑实体并添加 generatedValue 。寻找更好的解决方案。我认为当反向引擎时,它应该生成那些注释
i reverse engined entity class but the primary key is not anottaed with GeneratedValue . my table is created on oracle. do i need to add contraint on the table primary key for auto increment?
rightn ow i manually edit the entity and add generatedValue . looking for better solution . i think when reverse engine, it suppose to generate those anotation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Netbeans 实际上在从已有的数据库结构快速生成实体类的骨架结构方面做得非常好。话虽如此,您必须记住,它仍然足以让您运行,将其视为生产级代码是愚蠢的。您将必须进一步完善它。
在 Java 中,我通常发现自己正在做的是使用各种工具仔细构建我的数据模型(我会尽量避免在这里进行推销)。一旦我觉得它相当充实,我将生成 DDL,建立数据库,然后使用工具对其进行逆向工程。但我总是通过检查代码并根据需要进行更正来跟进。从那时起,我通常首先对我的实体进行更改,然后手动将等效的更改传播到数据库。
我已经有一段时间没有进行任何认真的 Java/DB 开发了,只是因为我正在从事的大型项目有一个专门的 DB 团队,所以现在可能有一些很好的工具,可以非常准确地生成 DDL 和实体,并且同步。然而,即使是这样,对于任何中小型项目,我仍然可能会遵循上述做法。
Netbeans actually does a pretty nice job of quickly generating a skeleton structure of your entity classes from an already in-place database structure. With that being said, you have to remember that it's still just enough to get you running and it would be foolish to consider it production-grade code. You will have to further refine it.
In Java what I commonly find myself doing is carefully crafting my data model using any of a variety of tools (I'll try to avoid making a sales pitch here). Once I feel that it's fairly fleshed out, I'll generate the DDL, throw up the database, and then reverse engineer it using a tool. But I always follow that up by going through the code and correcting as necessary. From that point forward I usually make changes to my entities first and then manually propagate the equivalent changes to the database.
It's been a while since I've done any serious Java/DB development simply because the large project I'm working on has a dedicated DB team, so there may be some good tools now that can both generate your DDL and entities very accurately and in sync. However, even if that were the case, I would still probably follow the above practice for any small to medium sized project.
我从来没有见过一个 JPA 工具可以正确地对 Oracle 数据库进行逆向工程。我总是不得不对逆向工程代码进行许多修改。我通常只进行一次逆向工程,然后将所有新更改从代码传播到数据库。
I have never seen a JPA tool that reverse-engineered an oracle database properly. I've always had to make many modifications to the reverse-enginneered code. I usually just reverse engineer once and after that propagate all new changes from the code to the DB.