下面列出了org.hibernate.engine.spi.Mapping#getReferencedPropertyType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean hasNonIdentifierPropertyNamedId(final EntityType entityType, final Mapping factory) {
// TODO : would be great to have a Mapping#hasNonIdentifierPropertyNamedId method
// I don't believe that Mapping#getReferencedPropertyType accounts for the identifier property; so
// if it returns for a property named 'id', then we should have a non-id field named id
try {
return factory.getReferencedPropertyType(
entityType.getAssociatedEntityName(),
EntityPersister.ENTITY_ID
) != null;
}
catch (MappingException e) {
return false;
}
}
/**
* Determine the type of either (1) the identifier if we reference the
* associated entity's PK or (2) the unique key to which we refer (i.e.
* the property-ref).
*
* @param factory The mappings...
*
* @return The appropriate type.
*
* @throws MappingException Generally, if unable to resolve the associated entity name
* or unique key property name.
*/
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
return getIdentifierType( factory );
}
else {
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
if ( type.isEntityType() ) {
type = ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory );
}
return type;
}
}