/** * Reads the id mapping data of a referenced entity. * @param entityName Name of the entity which is the source of the relation. * @param referencedEntityName Name of the entity which is the target of the relation. * @param propertyAuditingData Auditing data of the property that is the source of the relation. * @param allowNotAuditedTarget Are not-audited target entities allowed. * @throws MappingException If a relation from an audited to a non-audited entity is detected, which is not * mapped using {@link RelationTargetAuditMode#NOT_AUDITED}. * @return The id mapping data of the related entity. */ public IdMappingData GetReferencedIdMappingData(String entityName, String referencedEntityName, PropertyAuditingData propertyAuditingData, bool allowNotAuditedTarget) { EntityConfiguration configuration; if (EntitiesConfigurations.Keys.Contains(referencedEntityName)) configuration = EntitiesConfigurations[referencedEntityName]; else { RelationTargetAuditMode relationTargetAuditMode = propertyAuditingData.getRelationTargetAuditMode(); if (!NotAuditedEntitiesConfigurations.Keys.Contains(referencedEntityName) || !allowNotAuditedTarget || !RelationTargetAuditMode.NOT_AUDITED.Equals(relationTargetAuditMode)) { throw new MappingException("An audited relation from " + entityName + "." + propertyAuditingData.Name + " to a not audited entity " + referencedEntityName + "!" + (allowNotAuditedTarget ? " Such mapping is possible, but has to be explicitly defined using [Audited(TargetAuditMode = RelationTargetAuditMode.NOT_AUDITED)]." : "")); } else configuration = NotAuditedEntitiesConfigurations[referencedEntityName]; } return configuration.IdMappingData; }