Interface between two related JPA entities
The script looks like this (tables shown)
Delivery table
------
id channelId type
10 100 fax
20 200 email
Fax table
----
id number
100 1234567
101 1234598
Email table
-----
id email
200 a@a.com
201 b@b.com
basically a relationship between the same delivery object and channel, but since each specific channel (fax, email) has different members, I want to create a common interface (channel) between the two objects and use that for @OneToOne relationship. Seems like a simple scenario where you may have already gone through but I can't seem to succeed. I tried to put this target on targetEntity but not use. Still says "shipping links unknown"
Any ideas? thanks in advance
a source to share
How do I use the superclass of a class abstract
for the inheritance strategy Channel
and TABLE_PER_CLASS
? Something like that:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Channel {
@Id
@GeneratedValue
private Long id;
// ...
}
@Entity
public class Fax extends Channel {
}
@Entity
public class Email extends Channel {
}
@Entity
public class Delivery {
@Id
@GeneratedValue
private Long id;
@OneToOne
private Channel channel;
// ...
}
a source to share