0
			String[] names, 
			SessionImplementor session, 
			Object owner) throws HibernateException, SQLException { 
		return resolve( hydrate(rs, names, session, owner), session, owner ); 
	} 
 
	/** 
	 * Two entities are considered the same when their instances are the same. 
	 * 
	 * 
	 * @param x One entity instance 
	 * @param y Another entity instance 
	 * @return True if x == y; false otherwise. 
	 */ 
	public final boolean isSame(Object x, Object y) { 
		return x == y; 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public int compare(Object x, Object y) { 
		return 0; //TODO: entities CAN be compared, by PK, fix this! -> only if/when we can extract the id values.... 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public Object deepCopy(Object value, SessionFactoryImplementor factory) { 
		return value; //special case ... this is the leaf of the containment graph, even though not immutable 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public Object replace( 
			Object original, 
			Object target, 
			SessionImplementor session, 
			Object owner, 
			Map copyCache) throws HibernateException { 
		if ( original == null ) { 
			return null; 
		} 
		Object cached = copyCache.get(original); 
		if ( cached != null ) { 
			return cached; 
		} 
		else { 
			if ( original == target ) { 
				return target; 
			} 
			if ( session.getContextEntityIdentifier( original ) == null  && 
					ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) { 
				final Object copy = session.getFactory().getEntityPersister( associatedEntityName ) 
						.instantiate( null, session ); 
				//TODO: should this be Session.instantiate(Persister, ...)? 
				copyCache.put( original, copy ); 
				return copy; 
			} 
			else { 
				Object id = getIdentifier( original, session ); 
				if ( id == null ) { 
					throw new AssertionFailure("non-transient entity has a null id"); 
				} 
				id = getIdentifierOrUniqueKeyType( session.getFactory() ) 
						.replace(id, null, session, owner, copyCache); 
				return resolve( id, session, owner ); 
			} 
		} 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public int getHashCode(Object x, SessionFactoryImplementor factory) { 
		EntityPersister persister = factory.getEntityPersister(associatedEntityName); 
		if ( !persister.canExtractIdOutOfEntity() ) { 
			return super.getHashCode( x ); 
		} 
 
		final Serializable id; 
		if (x instanceof HibernateProxy) { 
			id = ( (HibernateProxy) x ).getHibernateLazyInitializer().getIdentifier(); 
		} 
		else { 
			final Class mappedClass = persister.getMappedClass(); 
			if ( mappedClass.isAssignableFrom( x.getClass() ) ) { 
				id = persister.getIdentifier( x ); 
			} 
			else { 
				id = (Serializable) x; 
			} 
		} 
		return persister.getIdentifierType().getHashCode( id, factory ); 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) { 
		EntityPersister persister = factory.getEntityPersister(associatedEntityName); 
		if ( !persister.canExtractIdOutOfEntity() ) { 
			return super.isEqual(x, y ); 
		} 
 
		final Class mappedClass = persister.getMappedClass(); 
		Serializable xid; 
		if (x instanceof HibernateProxy) { 
			xid = ( (HibernateProxy) x ).getHibernateLazyInitializer() 
					.getIdentifier(); 
		} 
		else { 
			if ( mappedClass.isAssignableFrom( x.getClass() ) ) { 
				xid = persister.getIdentifier( x ); 
			} 
			else { 
				//JPA 2 case where @IdClass contains the id and not the associated entity 
				xid = (Serializable) x; 
			} 
		} 
 
		Serializable yid; 
		if (y instanceof HibernateProxy) { 
			yid = ( (HibernateProxy) y ).getHibernateLazyInitializer() 
					.getIdentifier(); 
		} 
		else { 
			if ( mappedClass.isAssignableFrom( y.getClass() ) ) { 
				yid = persister.getIdentifier( y ); 
			} 
			else { 
				//JPA 2 case where @IdClass contains the id and not the associated entity 
				yid = (Serializable) y; 
			} 
		} 
 
		return persister.getIdentifierType() 
				.isEqual(xid, yid, factory); 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public boolean isEmbeddedInXML() { 
		return isEmbeddedInXML; 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public boolean isXMLElement() { 
		return isEmbeddedInXML; 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException { 
		if ( !isEmbeddedInXML ) { 
			return getIdentifierType(factory).fromXMLNode(xml, factory); 
		} 
		else { 
			return xml; 
		} 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { 
		if ( !isEmbeddedInXML ) { 
			getIdentifierType(factory).setToXMLNode(node, value, factory); 
		} 
		else { 
			Element elt = (Element) value; 
			replaceNode( node, new ElementWrapper(elt) ); 
		} 
	} 
 
	public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters) 
	throws MappingException { 
		if ( isReferenceToPrimaryKey() ) { //TODO: this is a bit arbitrary, expose a switch to the user? 
			return ""; 
		} 
		else { 
			return getAssociatedJoinable( factory ).filterFragment( alias, enabledFilters ); 
		} 
	} 
 
	/** 
	 * Resolve an identifier or unique key value 
	 */ 
	public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException { 
		if ( isNotEmbedded( session ) ) { 
			return value; 
		} 
 
		if ( value == null ) { 
			return null; 
		} 
		else { 
			if ( isNull( owner, session ) ) { 
				return null; //EARLY EXIT! 
			} 
 
			if ( isReferenceToPrimaryKey() ) { 
				return resolveIdentifier( (Serializable) value, session ); 
			} 
			else { 
				return loadByUniqueKey( getAssociatedEntityName(), uniqueKeyPropertyName, value, session ); 
			} 
		} 
	} 
 
	public Type getSemiResolvedType(SessionFactoryImplementor factory) { 
		return factory.getEntityPersister( associatedEntityName ).getIdentifierType(); 
	} 
 
	protected final Object getIdentifier(Object value, SessionImplementor session) throws HibernateException { 
		if ( isNotEmbedded(session) ) { 
			return value; 
		} 
 
		if ( isReferenceToPrimaryKey() ) { 
			return ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); //tolerates nulls 
		} 
		else if ( value == null ) { 
			return null; 
		} 
		else { 
			EntityPersister entityPersister = session.getFactory().getEntityPersister( getAssociatedEntityName() ); 
			Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); 
			// We now have the value of the property-ref we reference.  However, 
			// we need to dig a little deeper, as that property might also be 
			// an entity type, in which case we need to resolve its identitifier 
			Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); 
			if ( type.isEntityType() ) { 
				propertyValue = ( ( EntityType ) type ).getIdentifier( propertyValue, session ); 
			} 
 
			return propertyValue; 
		} 
	} 
 
	protected boolean isNotEmbedded(SessionImplementor session) { 
//		return !isEmbeddedInXML; 
		return false; 
	} 
 
	/** 
	 * Generate a loggable representation of an instance of the value mapped by this type. 
	 * 
	 * @param value The instance to be logged. 
	 * @param factory The session factory. 
	 * @return The loggable string. 
	 * @throws HibernateException Generally some form of resolution problem. 
	 */ 
	public String toLoggableString(Object value, SessionFactoryImplementor factory) { 
		if ( value == null ) { 
			return "null"; 
		} 
		 
		EntityPersister persister = factory.getEntityPersister( associatedEntityName ); 
		StringBuffer result = new StringBuffer().append( associatedEntityName ); 
 
		if ( persister.hasIdentifierProperty() ) { 
			final EntityMode entityMode = persister.getEntityMode(); 
			final Serializable id; 
			if ( entityMode == null ) { 
				if ( isEmbeddedInXML ) { 
					throw new ClassCastException( value.getClass().getName() ); 
				} 
				id = ( Serializable ) value; 
			} 
			else { 
				id = persister.getIdentifier( value ); 
			} 
			 
			result.append( '#' ) 
				.append( persister.getIdentifierType().toLoggableString( id, factory ) ); 
		} 
		 
		return result.toString(); 
	} 
 
	/** 
	 * Is the association modeled here defined as a 1-1 in the database (physical model)? 
	 * 
	 * @return True if a 1-1 in the database; false otherwise. 
	 */ 
	public abstract boolean isOneToOne(); 
 
	/** 
	 * Is the association modeled here a 1-1 according to the logical moidel? 
	 * 
	 * @return True if a 1-1 in the logical model; false otherwise. 
	 */ 
	public boolean isLogicalOneToOne() { 
		return isOneToOne(); 
	} 
 
	/** 
	 * Convenience method to locate the identifier type of the associated entity. 
	 * 
	 * @param factory The mappings... 
	 * @return The identifier type 
	 */ 
	Type getIdentifierType(Mapping factory) { 
		return factory.getIdentifierType( getAssociatedEntityName() ); 
	} 
 
	/** 
	 * Convenience method to locate the identifier type of the associated entity. 
	 * 
	 * @param session The originating session 
	 * @return The identifier type 
	 */ 
Connect your IDE to all the code out there  Get Codota for Java