Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Multi level inheritance example

Hi Luciano,

That model in theory is valid and should work yes. Let us know if you encounter any issues.

Cheers,
Guy


On 11/06/2013 10:09 AM, Luciano Santos wrote:
Hi Guy,

Thanks for your answer. Actually i don't think the standard JPA behavior is enogh for me (unless EclipseLink is smart enough to handle it), because two levels of inheritance.

HarmNotification extensions have all TP_NOTIFICATION = 'I" plus a TP_HARM value to identify itself (Ex.: DG for DengueNotification, IN for InfuenzaNotification)
NegativeNotification doesn't qualify as a HarmNotification, it's just a Notification, and it does't have any harm associated of course, so it just hava TP_NOTIFICATION = 'N'

I agree that the best scenario for me would to have like you said something like this:

@Inheritance(SINGLE_TABLE)
@DiscriminatorColumn(name="TP_NOTIFICATION" ,...)
class Notification

@Inheritance(SINGLE_TABLE)
@DiscriminatorValue("I") // TP_NOTIFICATION
@DiscriminatorColumn(name="TP_HARM" ,...)
class HarmNotification extends Notification

@DiscriminatorValue("DG") //TP_HARM
class DengueNotification extends HarmNotification

@DiscriminatorValue("N") // TP_NOTIFICATION
class NegativeNotification extends Notification

But i am pretty sure it doesn't work right?

Thanks

2013/6/11 Guy Pelletier <guy.pelletier@xxxxxxxxxx>
Luciano,

@TenantDiscriminatorColumn is defaulting the contextProperty to
eclipselink.tenant-id therefore you must set the default contextProperty, that is, eclipselink.tenant-id either in your persistence.xml, or per entity manager. Eg. em.setProperty("eclipselink.tenant-id", value);

Also, please note your are using multitenancy but given the subject I wonder if you meant to use

@Inheritance(SINGLE_TABLE)

@DiscriminatorColumn(name ="TP_NOTIFICATION")

instead?

Cheers,
Guy

On 11/06/2013 8:25 AM, Luciano Santos wrote:
Hello.

I am struggling a little bit to make this single table two level/two column inheritance:

@Multitenant(SINGLE_TABLE)
@TenantDiscriminatorColumn(name = "TP_NOTIFICATION")
public abstract class Notification
...
@Column(name = "TP_NOTIFICATION", length = 1, insertable=false, updatable=false)
    private NotificationType type;
...
}

@DiscriminatorValue("N")
class NegativeNotification extends Notification {}

@DiscriminatorValue("H")
@TenantDiscriminatorColumn(name="TP_HARM", length=2)
class HarmNotification
...
    @Column(name = "TP_HARM", insertable=false, updatable=false)
    private HarmType harmType;
...
}

@DiscriminatorValue("IN")
class InfluenzaNotification extends HarmNotification

@DiscriminatorValue("PE")
class PertussisNotification extends HarmNotification

...

So far the deployment is OK, but a query for HarmNotification fails on the say to try a store operation:
Exception Description: No value was provided for the session property [eclipselink.tenant-id]. This exception is possible when using additional criteria or tenant discriminator columns without specifying the associated contextual property. These properties must be set through Entity Manager, Entity Manager Factory or persistence unit properties. If using native EclipseLink, these properties should be set directly on the session.
Query: ReadAllQuery(referenceClass=HarmNotification sql="SELECT t0.CO_SEQ_...

Do you guys have an example on how i need to declare this to make it work?

Thanks

Luciano G Santos


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

--

Oracle
Guy Pelletier

ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4

Green Oracle Oracle is committed to developing practices and products that help protect the environment


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



--

Oracle
Guy Pelletier

ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4

Green
            Oracle Oracle is committed to developing practices and products that help protect the environment


Back to the top