I have an application that creates many lines that reference two other objects, i.e. there are two foreign key links in the line that implement ManyToOne relationships.
These are links to two objects:
CREATE TABLE a (
`id` INT NOT NULL auto_increment,
PRIMARY KEY (id)
)
CREATE TABLE b (
`id` INT NOT NULL auto_increment,
PRIMARY KEY (id)
)
This is an object that references a and b:
CREATE TABLE x (
`id` INT NOT NULL auto_increment,
`f_a` INT NOT NULL,
`f_b` INT NOT NULL,
CONSTRAINT `FK_a` FOREIGN KEY (`f_a`) REFERENCES `a` (`id`),
CONSTRAINT `FK_b` FOREIGN KEY (`f_b`) REFERENCES `b` (`id`),
)
a, b, and x are mapped to classes A, B, and X using JPA via EclipseLink, it's pretty simple and doesn't represent anything to it.
When I create X in Java, I do the following (note that a and b already exist, and I only know their identifiers - they are loaded from an outdated application):
A a = entityManager.find(A.class, knownIdForA);
B b = entityManager.find(B.class, knownIdForB);
X x = new X();
x.setA(a);
x.setB(b);
entityManager.persist(x);
, 200 000 , . 3 As Bs, 200 000 A B, 200 000 A B, .
: ? ? , ( ), JPA (.. )?
: JPA?
INSERT INTO x (`f_a`, `f_b`) VALUES (13, 17);
f_a f_b - ?