Java Code Examples for org.hibernate.engine.spi.Mapping#getReferencedPropertyType()

The following examples show how to use org.hibernate.engine.spi.Mapping#getReferencedPropertyType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractPropertyMapping.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
	}
}
 
Example 2
Source File: EntityType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
	}
}