开发者

Java Newbie: JPA and EJB workflow question

I'm just learning about JPA and session beans. I've worked through a simple database model (schema designed using MySQL Workbench) and used an IDE (NetBeans) wizard to generate the JPA entity classes and session beans.

My question has to do with an appropriate workflow when the data model changes. For example, if I add a column to a table, do some IDE's have features that will update ent开发者_如何学运维ity classes and session beans to reflect the new underlying data structure? Or are these changes best handled manually?

I read this answer on SO, but the answer was a bit beyond my experience so far.


I've worked through a simple database model (schema designed using MySQL Workbench) and used an IDE (NetBeans) wizard to generate the JPA entity classes and session beans.

To my experience, these generated entities are often not perfect (e.g. you get attributes for FK instead of relations). I thus consider them as a starting point, but certainly not a final result.

(...) For example, if I add a column to a table, do some IDE's have features that will update entity classes and session beans to reflect the new underlying data structure? Or are these changes best handled manually?

I'm not aware of any tool supporting perfectly round-trip engineering, especially when using a bottom-up approach i.e. when starting from the database schema (some providers allow to update a schema when using a top-down approach i.e. when starting from the entities and mappings but this isn't perfect either) and changes are IMO best handled manually.

Actually, I personally consider JPA code generation tooling (whether you use a top-down or a bottom-up approach) mostly as "bootstrapping" tools, they help to get things started. But at some point, you'll have to start syncing things by hand (which is where migration tools like the one mentioned in the question you linked to are useful).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜