use of org.eclipse.persistence.descriptors.VPDMultitenantPolicy in project eclipselink by eclipse-ee4j.
the class MultitenantMetadata method process.
/**
* INTERNAL:
*/
public void process(MetadataDescriptor descriptor) {
ClassDescriptor classDescriptor = descriptor.getClassDescriptor();
MultitenantPolicy policy;
if (m_type == null || m_type.equals(MultitenantType.SINGLE_TABLE.name()) || m_type.equals(MultitenantType.VPD.name())) {
if (m_type == null || m_type.equals(MultitenantType.SINGLE_TABLE.name())) {
policy = new SingleTableMultitenantPolicy(classDescriptor);
// As soon as we find one entity that is multitenant, turn off
// native SQL queries Users can set the property on their
// persistence unit if they want it back on. Or per query.
getProject().setAllowNativeSQLQueries(false);
} else {
policy = new VPDMultitenantPolicy(classDescriptor);
// Within VPD, we must ensure we are using an Always exclusive mode.
((ServerSession) getProject().getSession()).getDefaultConnectionPolicy().setExclusiveMode(ConnectionPolicy.ExclusiveMode.Always);
}
// Set the include criteria flag on the query manager (in VPD this will be false).
((SingleTableMultitenantPolicy) policy).setIncludeTenantCriteria(includeCriteria());
// Single table multi-tenancy (perhaps using VPD).
processTenantDiscriminators(descriptor, (SingleTableMultitenantPolicy) policy);
} else {
// Initialize the policy.
policy = new TablePerMultitenantPolicy(classDescriptor);
// Process the tenant table discriminator.
processTenantTableDiscriminator(descriptor, (TablePerMultitenantPolicy) policy);
}
// Set the policy on the descriptor.
classDescriptor.setMultitenantPolicy(policy);
// we are sharing an EMF.
if (getProject().usesMultitenantSharedEmf()) {
if (getProject().usesMultitenantSharedCache()) {
// Caching details are processed before multitenant metadata.
if (classDescriptor.isSharedIsolation()) {
classDescriptor.setCacheIsolation(CacheIsolationType.PROTECTED);
}
} else {
classDescriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
}
}
}
Aggregations