Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Auto Generate hbm.xml from POJO

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I want to migrate my application from JDBC to 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!?

For example.
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]!?

Please help me!
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.



Hi Karthik,
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?

Thanks for your reply!
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic