I want to migrate my application from JDBCto Hibernate. I have lots of POJO classes for that I have to create hbm.xml files. I want to know, Is there any way to generate hbm.xml and database table form POJO!?
I am having Student Pojo with setter and getter methods.
Is there any feature or plugin in Eclips to generate Student.hbm.xml and StudentTable (In Database) form [b]Student POJO/b]!?
Yes, the JBoss Hibernate Tools plugin provides this option. After installation, right click on your POJO class in Eclipse and select New > Hibernate XML Mapping File.
However, note that the plugin really has no way of deciding column mappings. If your ID field is userID and column name is EMPLOYEE_ID, it can't really put in that
mapping - you need to do that manually.
For generating DDL, there are ant tasks and standalone tools that come along with Hibernate Tools. For DDL from POJOs, they need to be annotated. For DDL from XML mapping file, you have to use the ant task - hbm2ddl or something like that.
Sanket L Shah
posted 10 years ago
Karthik Shiraly wrote:Hi,
plugin really has no way of deciding column mappings. If your ID field is userID and column name is EMPLOYEE_ID, it can't really put in that mapping - you need to do that manually.
Thanks for your reply,You are right It does not generate column's mapping in generated hbm.xml file. Do you know any external tool for generating hbm.xml files form POJO?