Posts

Showing posts with the label Hibernate

Generate Java POJO and Hibernate XML from database tables

Today we have frameworks to persist java objects to database without writing DAO's and hibernate is one which is widely used. But for nascent developers, creating its mapping to database tables is still difficult. Recently I come across a way to generate Java  POJO and hibernate mapping XML  from database tables  using a Jboss Hibernate Tools. Its as easy as a click  and magic, mapping XML is generated and corresponding POJO 's are generated. Listed down the steps :- 1. Install the hibernate-tools jar using Eclipse's Install New software, selecting URL from http://www.jboss.org/tools/download.html depending upon the eclipse version. 2. Click on [File -> New -> Other -> Hibernate -> Hibernate Configuration File] and create a cfg file. The following properties should be specified : jdbc url , username, password, DB schema, driver class and dialect. 3. Click on [File -> New -> Other -> Hibernate -> Hibernate Console Configuration ] and crea...