generate annotated java class from hbm file

北战南征 提交于 2019-12-12 13:05:55

问题


I have an old project in which java classes are generated from hbm files.

Is it possible ,using these hbm files, to generate java classes with annotations?


回答1:


I don't think you can do it directly from hbm to annotations, but it's possible to do it if you proceed like this:

  1. Generate the database schema from your hbm configuration.
  2. Use Hibernate reverse engeneering to generate annotated classes from this database.

You may take a look at these links for further information:

  • Generating Hibernate annotated classes from database using eclipse.
  • How to generate domain objects with annotations using hibernate tools.
  • How to generate Hibernate mapping files & annotation with Hibernate Tools



回答2:


We have had the same issue and solved it by using this hbm to annotation converter script https://github.com/SchweizerischeBundesbahnen/hibernate_hbm2annotation




回答3:


You can use a hibernate reverse engeneering tool, but for generating annoted classes from database not from hbm's.



来源:https://stackoverflow.com/questions/31241594/generate-annotated-java-class-from-hbm-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!