Q:

Is it possible to ask Hibernate to create table from .hbm.xml file?

I want to develop a DB structure where every "object" will go in its own table. Say, objects are "house", "car", etc. The structure of the tables is the same for each object. The tables are named this way: common prefix and the name of object. Also every object has two associate tables that go in one-to-many relationship.
For this purpose I created a naming strategy that returns the name of the physical table based on the name of the object.
The problem is that I can receive an object that has no table so I need to create it. I tried with direct SQL query and it worked fine before adding some foreign relationships to the table. Now I receive the following exception:
Exception in thread "main" org.hibernate.DuplicateMappingException:  Table [INV_OBJECT_ATTRIBS] contains logical column name [id] referenced by
multiple physical column names: [INV_ATTRIB_ID], [INV_KEY_ID]

My question is:
Is it possible to ask Hibernate from within code to create a table based on .hbm.xml file? Something like session->createTableFromXML(...)?

A:

Yes, look at the Hibernate schema generation tools hbm2ddl:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/toolsetguide.html

