Search code examples
hibernatepojo

Hibernate tables from pojo classes


I wonder if anybody can help.

I have a class structure that I am working on and I would like to generate the sql tables and mapping files from these classes. Is it possible?


Solution

  • Yes, you can. You need:

    1. hibernate.cfg.xml with this line

      create More info here: Hibernate hbm2ddl.auto possible values and what they do? and here: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html

    2. you need to map the class: there are 2 ways: with annotation or hbm files. Here some about mapping: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html .

    In the mapping you need to describe name table, catalog and (if you want) column.