如何在JPA实体中定义外键?
我对客户表的创建有疑问。
CREATE TABLE `customer` (
`cus_name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(20) NOT NULL,
`phone` varchar(15) NOT NULL,
PRIMARY KEY (`email`)
)
我有第二个表格,它是带有电子邮件的外键的预订表查询,该键是从客户表中进行的。
CREATE TABLE `booking` (
`booking_num` int(11) NOT NULL AUTO_INCREMENT,
`pass_email` varchar(30) NOT NULL,
`name` varchar(30) NOT NULL,
`contact` varchar(20) NOT NULL,
PRIMARY KEY (`booking_num`),
CONSTRAINT `email_fk` FOREIGN KEY (`pass_email`) REFERENCES `customer` (`email`)
)
如何制作JPA来创建执行创建表格的确切查询的表?
@Joincolumn注释和关系中会有什么?
谢谢。
I have a query for Customer table creation.
CREATE TABLE `customer` (
`cus_name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(20) NOT NULL,
`phone` varchar(15) NOT NULL,
PRIMARY KEY (`email`)
)
I have the second table which is the booking table query with a foreign key of email which is from customer table.
CREATE TABLE `booking` (
`booking_num` int(11) NOT NULL AUTO_INCREMENT,
`pass_email` varchar(30) NOT NULL,
`name` varchar(30) NOT NULL,
`contact` varchar(20) NOT NULL,
PRIMARY KEY (`booking_num`),
CONSTRAINT `email_fk` FOREIGN KEY (`pass_email`) REFERENCES `customer` (`email`)
)
How do I make the JPA to create the tables that performs the exact query for creation of tables?
what would be in the @JoinColumn annotation and the relationship?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论