V
V
Vitaly Stolyarov2016-12-10 00:46:45
Java
Vitaly Stolyarov, 2016-12-10 00:46:45

How to apply @OneToOne to an interface?

interface Info{}

class Opt implements Info{}
class Val implements Info{}

A class has an object of type Info that can accept objects of one of the types Opt or Val
An attempt to use @OneToOne(targetEntity=Val.class targetEntity=Opt.class) fails because multiple targetEntity is not possible

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2016-12-10
@aol-nnov

no way. apply to the class.
if you are looking for where to take out common fields - make an abstract class and mark it with @MappedSuperclass
if the interface, bloody nose, is needed for some things, make a marker interface and superclass it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question