0

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.

Navnath
  • 1,064
  • 4
  • 18
  • 34

1 Answers1

1

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.

Community
  • 1
  • 1
sharakan
  • 6,821
  • 1
  • 34
  • 61
  • 1
    That is correct. However, if I understood right Navnath has created his tables manually (maybe it is a legacy database) and subsequently mapped it with Hibernate. Is that right? If that is the case "hibernate.hbm2ddl.import_files" should be a good option. – Rafa Mar 25 '13 at 18:22
  • Yori... Really thanks for your comment..... This is what I am expecting.... Thankis Sharakan too... – Navnath Mar 26 '13 at 06:14