Question

We're using JPA for our new project. We have an inheritance relation which has a discrimnator.

We're trying to remove the discrimninator field from my superclass table but we can't figure out how to achieve this using eclipselink. We know that this is possible with hibernate, does anyone know how to achieve this with eclipselink?

You might be wondering why we want to achieve this (I know that using a discriminator is faster because it removes the need for exists checks on the other tables), it's because we try to implement the following: JPA multiple discriminator values (see the question and the answer).

Was it helpful?

Solution

I do not believe this will work the way you intend it to. When you query for the Organization with ID value of 1, the entity you get back can be an Organization, Customer or a Supplier. Java doesn't allow the type to be all 3 at once, at least not in the way you have set up inheritance. Since an Organization can still exist without being a supplier or customer, inheritance doesn't make sense to me.

These 3 tables should represent different entities - an Organization can have a customer designation and/or a Supplier designation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top