| Summary: | MULTITENANT_PROPERTY_DEFAULT - persistence unit property or just a default string? | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Karen Butzke <karenfbutzke> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | CLOSED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | guy.pelletier |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Karen Butzke
I'm confused, it's the default context property for multitenant that can be set at the PU or EM level. This property needs to be set if any Entity uses a defaulted TenantDiscriminatorColumn since 'eclipselink.tenant-id' is the default context property. There is no metadata processing per say of this property. Context properties must be populated from the user (on the PU or EM) otherwise they will get an exception when executing their queries. I must be confused as well :) In TenantDiscriminatorColumnMetadata.process(MetadataDescriptor) it sets the m_contextProperty to MULTITENANT_PROPERTY_DEFAULT if it is null. This would make the m_contextProperty be "eclipselink.tenant-id". Given the example in the javadocs I would expect the m_contextProperty should get set to "Oracle". Is this the expected behavior? I don't see how that could be happening when nothing ever calls EntityManagerFactoryProvider.getConfigPropertyAsString for this property. No, so the value 'Oracle' needs to be set by the user in the PU definition or on an EM.
E.G.
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT,
"Oracle");
or
<property name="eclipselink.tenant-id" value="Oracle"/>
Another example, if the user had specified something like this:
@Entity
@Multitenant
@TenantDiscriminatorColumn(name="TENANT_ID", contextProperty="tenant-id")
Then you would see (set by the user):
em.setProperty("tenant-id", "Oracle")
or in XML
<property name="tenant-id" value="Oracle"/>
So metadata processing does not process and set the value of the context property, only the name of the context property it needs to look up on the session at runtime.
Using the example above it says we have a multitenant column named TENANT_ID. When we insert the multitenant entity we need to populate that column with a value. The context property tells us which property to look for on the session. If the user doesn't set it (through the EM or PU), they will get an exception.
Thanks for the explanation Guy, I think I finally get it! So Dali could have a validation error if a particular contextProperty does not have a corresponding property defined in the persistence.xml. Of course that doesn't take into account them setting the property on the entityManager in code. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |