Skip to main content

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

I would suggest not naming your EmbeddedId class "EmbeddedId". Im guessing this class name was changed to post in your email, but incase it wasnt, it may be worth renaming and retesting since these kind of namespace collisions can lead to non-deterministic behavior when classloading.

Also, I am not familiar with @Multitenant annotation, but taking a look at the wiki (, two things are listed as for @Multitenant(TABLE_PER_TENANT):

    To configure table-per-tenant multitenancy, you must specify:

  • A table-per-tenant property to identify the user. This can be set per entity manager, or it can be set at the entity manager factory to isolate table-per-tenant per persistence unit.)

  • A tenant table discriminator to identify and isolate the tenant's tables from other tenants' tables. The discriminator types are SCHEMA, SUFFIX, and PREFIX. For more information about tenant discriminator types, see "@TenantTableDiscriminator".

Maybe someone more familiar with the use of @Multitenant can expand on it's usage.

On Tue, Dec 26, 2017 at 6:06 AM, Sowmiya Chellamuthu <sowmiyachellamuthu@xxxxxxxxx> wrote:

public abstract class BaseMappedSuperClass {
   private EmbeddedId id;

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "typeCol")
public abstract class Vehicle extends BaseMappedSuperClass{
   private String name;

@Entity(name = "Cycle")
@DiscriminatorValue(value = "Cycle")
public class Cycle extends Vehicle {
   private String bellType;

@Entity(name = "Bus")
@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

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

eclipselink-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top