Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Fwd: @Multitenant @Inheritance Single table causing inconsistence issues for save



@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.

After some more debugging I figured, in this method
*org.eclipse.persistence.internal.sessions.DatabaseSessionImpl#initializeDescriptors(java.util.Collection,
boolean) *, based on the order in which the descriptors are processed, the
result varies.

What is the logic behind the order in which the entities are processed to
initialize the metadata? Can I influence the order in which it is processed?

Version of eclipse link used is 2.5.1.




Back to the top