Community
Participate
Working Groups
@MappedSuperClass public abstract class BaseMappedSuperClass { @EmbeddedId private EmbeddedId id; } @Entity @Multitenant(MultitenantType.TABLE_PER_TENANT) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "typeCol") public abstract class Vehicle extends BaseMappedSuperClass{ private String name; } @Entity(name = "Cycle") @Multitenant(MultitenantType.TABLE_PER_TENANT) @DiscriminatorValue(value = "Cycle") public class Cycle extends Vehicle { private String bellType; } @Entity(name = "Bus") @Multitenant(MultitenantType.TABLE_PER_TENANT) @DiscriminatorValue(value = "Bus") public class Bus extends Vehicle { private String gearType; } I have the above entity structure and if I try to do an insert op on the entity Cycle or Bus, it fails inconsistently, because of the missing primary key field (id). When I tried to debug the JPA codebase, I figured that the tenant discriminator, which is tenant_id in my case is not appended to the table name prefix for the embeddedId field 'Id' and the discriminator column field 'typeCol'. What is more interesting is that this behavior is not consistent. If I restart my application and try, it works. If I restart again and try,it does not work.
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl#initializeDescriptors(java.util.Collection, boolean) The above method processes the descriptors for the entities defined. Here based on the order in which it is being processed, the issue occurs or not.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink