public void process(MetadataDescriptor descriptor) {
RelationalDescriptor classDescriptor = descriptor.getClassDescriptor();
if (m_type == null || m_type.equals(MultitenantType.SINGLE_TABLE.name()) || m_type.equals(MultitenantType.VPD.name())) {
// Initialize the policy.
SingleTableMultitenantPolicy policy;
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);
// Set the include criteria flag on the query manager.
policy.setIncludeTenantCriteria(includeCriteria());
} 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);
// When in VPD, do not include the criteria.
policy.setIncludeTenantCriteria(false);
}
// Single table multi-tenancy (perhaps using VPD).
processTenantDiscriminators(descriptor, policy);