foreign-keys

Hibernate: foreign key without entity class, only by id

孤街醉人 提交于 2020-12-05 05:13:35
问题 I have a hierarchical entity, which references it self as a parent. I need to do the mapping only via ids, not via entity instances (the reason is too complicated to explain). So I defined the entity this way: class Item { @Id private String id; @ManyToOne(targetEntity = Item.class) @JoinColumn(name = "PARENT_ID", nullable = true) private String parentId; } This seems to work fine. The foreign key constraint is created correctly in database. But when I execute the following query: SELECT i

ORA-00907: Missing Right Parenthesis On Creating Foreign Key Oracle 12c

筅森魡賤 提交于 2020-11-29 09:28:25
问题 I Want To Make a Table Which Include One Auto Generated Primary Key And Two Foreign Keys But I'm Facing This Error... create table answers ( id number generated by default on null as identity primary key , question_id number foreign key references questions(id) , user_id number foreign key references users(id) , answer varchar(1000) , post_date date); create table answers (id number generated by default on null as identity primary key, question_id number foreign key references questions(id),

Unable to add foreign key in MySQL 5.7 (Missing constraint in the referenced table)

强颜欢笑 提交于 2020-11-29 03:55:09
问题 I am trying to run a foreign key add query as below, with foreign key checks set to 0. Both the columns in the two tables are exactly the same. Also, both are primary keys. None of the solutions here helped in solving this problem. I'm on localhost. mysql> alter table deliveryaddress -> add foreign key(oid) references productorder(oid) -> on delete cascade on update restrict; ERROR 1822 (HY000): Failed to add the foreign key constaint. Missing index for c onstraint '' in the referenced table

Unable to add foreign key in MySQL 5.7 (Missing constraint in the referenced table)

佐手、 提交于 2020-11-29 03:55:09
问题 I am trying to run a foreign key add query as below, with foreign key checks set to 0. Both the columns in the two tables are exactly the same. Also, both are primary keys. None of the solutions here helped in solving this problem. I'm on localhost. mysql> alter table deliveryaddress -> add foreign key(oid) references productorder(oid) -> on delete cascade on update restrict; ERROR 1822 (HY000): Failed to add the foreign key constaint. Missing index for c onstraint '' in the referenced table