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开发者_StackOverflow中文版 generatedValue . looking for better solution . i think when reverse engine, it suppose to generate those anotation
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.
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.
精彩评论