Navnath
Navnath

Reputation: 1094

Create list table automatic using Hibernate

Is there any way to create single tale using hibernate. I have use hibernate.hbm2ddl.auto but it impacts to full aplication which I don't want. Table which I want to create is basicaly use to handle list mapping between two objects, so there is no any POJO for this table.

@OneToMany
@JoinTable(name="LIST_TABLE", joinColumns={@JoinColumn(name="EMP_ID")}, inverseJoinColumns={@JoinColumn(name="PHONE_ID")})

Where Employee have more then one Phone numbers.Can I create LIST_TABLE as Employee and Phone_number tables are already there.

Upvotes: 0

Views: 181

Answers (1)

sharakan
sharakan

Reputation: 6901

If you already have part of the database schema created, you don't want hibernate.hbm2ddl.auto, because as you have discovered that will try to create everything. There is another value, hibernate.hbm2ddl.update, but it's not recommended for production use.

Instead, I would recommend using the SchemaExport tool to output the required SQL, extract the relevant CREATE and ALTER statements for your new table, and run them manually. There's a related question on how to use SchemaExport here.

Upvotes: 1

Related Questions