Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If <code>Container</code> has a bidirectional OneToOne with <code>SomeTypeOfContainerAssignment</code>, which extends <code>ContainerAssignment</code>, then the container field should not be defined and mapped in <code>ContainerAssignment</code>, but in <code>SomeTypeOfContainerAssignment</code>:</p> <pre><code>public class Container { @Id private Long id; @OneToOne(mappedBy = "container") private SomeTypeOfContainerAssignment someTypeOfContainerAssignment; } public class ContainerAssignment { @Id private Long id; } public class SomeTypeOfContainerAssignment extends ContainerAssignment { @OneToOne private Container container; } </code></pre> <p>If all the types of container assignments have such a OneToOne association with COntainer, you can define the Container as</p> <pre><code>public abstract class ContainerAssignment { @Id private Long id; public abstract Container getContainer(); public abstract void setContainer(Container container); } </code></pre> <p>To be honest, I don't know if you're allowed to use the same join column in the table to map the <code>@OneToOne container</code> fields of each subclass.</p> <p>I think this is the best you can have. If you put the container field in the base class, then you must define the association as a OneToMany/ManyToOne association, since it's what it really is. </p> <p>I don't think what you want to do is possible, and I wouldn't mess with composite PKs, as they're discouraged for good reasons, and a nightmare to use.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload