HHH-6825 - Renaming simple entity descriptor
This commit is contained in:
parent
fbfc133af8
commit
10f48ef973
|
@ -27,11 +27,11 @@ public abstract class AbstractOneToOneMapper extends AbstractToOneMapper {
|
|||
@Override
|
||||
public void nullSafeMapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data, Object primaryKey,
|
||||
AuditReaderImplementor versionsReader, Number revision) {
|
||||
RelationDescriptor relation = getRelationDescriptor(verCfg, referencedEntityName);
|
||||
EntityInfo referencedEntity = getEntityInfo(verCfg, referencedEntityName);
|
||||
|
||||
Object value = null;
|
||||
try {
|
||||
value = queryForReferencedEntity(versionsReader, relation, (Serializable) primaryKey, revision);
|
||||
value = queryForReferencedEntity(versionsReader, referencedEntity, (Serializable) primaryKey, revision);
|
||||
} catch (NoResultException e) {
|
||||
value = null;
|
||||
} catch (NonUniqueResultException e) {
|
||||
|
@ -44,11 +44,11 @@ public abstract class AbstractOneToOneMapper extends AbstractToOneMapper {
|
|||
|
||||
/**
|
||||
* @param versionsReader Audit reader.
|
||||
* @param relation Relation descriptor.
|
||||
* @param primaryKey Related entity identifier.
|
||||
* @param referencedEntity Referenced entity descriptor.
|
||||
* @param primaryKey Referenced entity identifier.
|
||||
* @param revision Revision number.
|
||||
* @return Referenced object or proxy of one-to-one relation.
|
||||
*/
|
||||
protected abstract Object queryForReferencedEntity(AuditReaderImplementor versionsReader, RelationDescriptor relation,
|
||||
protected abstract Object queryForReferencedEntity(AuditReaderImplementor versionsReader, EntityInfo referencedEntity,
|
||||
Serializable primaryKey, Number revision);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class AbstractToOneMapper implements PropertyMapper {
|
|||
* @param entityName Entity name.
|
||||
* @return Entity class, name and information whether it is audited or not.
|
||||
*/
|
||||
protected RelationDescriptor getRelationDescriptor(AuditConfiguration verCfg, String entityName) {
|
||||
protected EntityInfo getEntityInfo(AuditConfiguration verCfg, String entityName) {
|
||||
EntityConfiguration entCfg = verCfg.getEntCfg().get(entityName);
|
||||
boolean isRelationAudited = true;
|
||||
if (entCfg == null) {
|
||||
|
@ -60,7 +60,7 @@ public abstract class AbstractToOneMapper implements PropertyMapper {
|
|||
isRelationAudited = false;
|
||||
}
|
||||
Class entityClass = ReflectionTools.loadClass(entCfg.getEntityClassName());
|
||||
return new RelationDescriptor(entityClass, entityName, isRelationAudited);
|
||||
return new EntityInfo(entityClass, entityName, isRelationAudited);
|
||||
}
|
||||
|
||||
protected void setPropertyValue(Object targetObject, Object value) {
|
||||
|
@ -83,21 +83,21 @@ public abstract class AbstractToOneMapper implements PropertyMapper {
|
|||
AuditReaderImplementor versionsReader, Number revision);
|
||||
|
||||
/**
|
||||
* Simple descriptor of managed relation.
|
||||
* Simple descriptor of an entity.
|
||||
*/
|
||||
protected class RelationDescriptor {
|
||||
private final Class referencedEntityClass;
|
||||
private final String referencedEntityName;
|
||||
protected class EntityInfo {
|
||||
private final Class entityClass;
|
||||
private final String entityName;
|
||||
private final boolean audited;
|
||||
|
||||
public RelationDescriptor(Class referencedEntityClass, String referencedEntityName, boolean audited) {
|
||||
this.referencedEntityClass = referencedEntityClass;
|
||||
this.referencedEntityName = referencedEntityName;
|
||||
public EntityInfo(Class entityClass, String entityName, boolean audited) {
|
||||
this.entityClass = entityClass;
|
||||
this.entityName = entityName;
|
||||
this.audited = audited;
|
||||
}
|
||||
|
||||
public Class getReferencedEntityClass() { return referencedEntityClass; }
|
||||
public String getReferencedEntityName() { return referencedEntityName; }
|
||||
public Class getEntityClass() { return entityClass; }
|
||||
public String getEntityName() { return entityName; }
|
||||
public boolean isAudited() { return audited; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,10 +46,10 @@ public class OneToOneNotOwningMapper extends AbstractOneToOneMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Object queryForReferencedEntity(AuditReaderImplementor versionsReader, RelationDescriptor relation,
|
||||
protected Object queryForReferencedEntity(AuditReaderImplementor versionsReader, EntityInfo referencedEntity,
|
||||
Serializable primaryKey, Number revision) {
|
||||
return versionsReader.createQuery().forEntitiesAtRevision(relation.getReferencedEntityClass(),
|
||||
relation.getReferencedEntityName(), revision)
|
||||
return versionsReader.createQuery().forEntitiesAtRevision(referencedEntity.getEntityClass(),
|
||||
referencedEntity.getEntityName(), revision)
|
||||
.add(AuditEntity.relatedId(owningReferencePropertyName).eq(primaryKey))
|
||||
.getSingleResult();
|
||||
}
|
||||
|
|
|
@ -20,18 +20,18 @@ public class OneToOnePrimaryKeyJoinColumnMapper extends AbstractOneToOneMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Object queryForReferencedEntity(AuditReaderImplementor versionsReader, RelationDescriptor relation,
|
||||
protected Object queryForReferencedEntity(AuditReaderImplementor versionsReader, EntityInfo referencedEntity,
|
||||
Serializable primaryKey, Number revision) {
|
||||
if (relation.isAudited()) {
|
||||
if (referencedEntity.isAudited()) {
|
||||
// Audited relation.
|
||||
return versionsReader.createQuery().forEntitiesAtRevision(relation.getReferencedEntityClass(),
|
||||
relation.getReferencedEntityName(), revision)
|
||||
return versionsReader.createQuery().forEntitiesAtRevision(referencedEntity.getEntityClass(),
|
||||
referencedEntity.getEntityName(), revision)
|
||||
.add(AuditEntity.id().eq(primaryKey))
|
||||
.getSingleResult();
|
||||
} else {
|
||||
// Not audited relation.
|
||||
return createNotAuditedEntityReference(versionsReader, relation.getReferencedEntityClass(),
|
||||
relation.getReferencedEntityName(), primaryKey);
|
||||
return createNotAuditedEntityReference(versionsReader, referencedEntity.getEntityClass(),
|
||||
referencedEntity.getEntityName(), primaryKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,10 +75,10 @@ public class ToOneIdMapper extends AbstractToOneMapper {
|
|||
if (versionsReader.getFirstLevelCache().contains(referencedEntityName, revision, entityId)) {
|
||||
value = versionsReader.getFirstLevelCache().get(referencedEntityName, revision, entityId);
|
||||
} else {
|
||||
RelationDescriptor relationDescriptor = getRelationDescriptor(verCfg, referencedEntityName);
|
||||
EntityInfo referencedEntity = getEntityInfo(verCfg, referencedEntityName);
|
||||
|
||||
value = versionsReader.getSessionImplementor().getFactory().getEntityPersister(referencedEntityName).
|
||||
createProxy((Serializable)entityId, new ToOneDelegateSessionImplementor(versionsReader, relationDescriptor.getReferencedEntityClass(),
|
||||
createProxy((Serializable)entityId, new ToOneDelegateSessionImplementor(versionsReader, referencedEntity.getEntityClass(),
|
||||
entityId, revision, verCfg));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue