[英]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. 我已经使用了
hibernate.hbm2ddl.auto
但是它会影响我不想要的全倍。 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. 我要创建的表基本上用于处理两个对象之间的列表映射,因此该表没有任何POJO。
@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. 如果Employee有一个以上的电话号码。我可以创建
LIST_TABLE
因为Employee
和Phone_number
表已经存在。
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. 如果您已经创建了数据库模式的一部分,则不需要
hibernate.hbm2ddl.auto
,因为您发现它将尝试创建所有内容。 There is another value, hibernate.hbm2ddl.update
, but it's not recommended for production use . 还有另一个值
hibernate.hbm2ddl.update
,但不建议用于生产环境 。
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. 相反,我建议使用SchemaExport工具输出所需的SQL,为新表提取相关的
CREATE
和ALTER
语句,然后手动运行它们。 There's a related question on how to use SchemaExport here . 有一个关于如何使用的SchemaExport一个相关的问题在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.