Reputation: 16865
I have 3 tables
-----
|foo
-----
| id pk
| rfid unique
-----
|bar
-----
|id pk
|a
|compound
|key
-----------------------------
| unique ( a, compound, key )
------------
|foo_bar_baz
------------
|id pk
|rfid
|a
|compound
|key
|baz
I'd like to make a FooBarBaz
relationship entity that looks something like (written in kotlin)
data class FooBarBaz(
@OneToOne
@JoinColumn(name = "rfid")
var foo: Foo,
@OneToOne
@JoinColumns([ "a", "compound", "key"])
var bar: Bar
) {
var baz: String
}
and I don't want Foo
and Bar
to know about FooBarBaz
, OneToOne
seems to want a bidirectional relationship, and it wasn't happy with me adding multiple JoinColumns
. How should I write my JPA entities?
Upvotes: 0
Views: 44