简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM