org.hibernate.mapping.ManyToOne#setReferencedEntityName ( )源码实例Demo

下面列出了org.hibernate.mapping.ManyToOne#setReferencedEntityName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gorm-hibernate5   文件: GrailsDomainBinder.java
/**
 * @param property The property to bind
 * @param manyToOne The inverse side
 */
protected void bindUnidirectionalOneToManyInverseValues(ToMany property, ManyToOne manyToOne) {
    PropertyConfig config = getPropertyConfig(property);
    if (config == null) {
        manyToOne.setLazy(true);
    } else {
        manyToOne.setIgnoreNotFound(config.getIgnoreNotFound());
        final FetchMode fetch = config.getFetchMode();
        if(!fetch.equals(FetchMode.JOIN) && !fetch.equals(FetchMode.EAGER)) {
            manyToOne.setLazy(true);
        }

        final Boolean lazy = config.getLazy();
        if(lazy != null) {
            manyToOne.setLazy(lazy);
        }
    }

    // set referenced entity
    manyToOne.setReferencedEntityName(property.getAssociatedEntity().getName());
}
 
源代码2 项目: gorm-hibernate5   文件: GrailsDomainBinder.java
/**
 */
protected void bindManyToOneValues(org.grails.datastore.mapping.model.types.Association property, ManyToOne manyToOne) {
    PropertyConfig config = getPropertyConfig(property);

    if (config != null && config.getFetchMode() != null) {
        manyToOne.setFetchMode(config.getFetchMode());
    }
    else {
        manyToOne.setFetchMode(FetchMode.DEFAULT);
    }

    manyToOne.setLazy(getLaziness(property));

    if (config != null) {
        manyToOne.setIgnoreNotFound(config.getIgnoreNotFound());
    }

    // set referenced entity
    manyToOne.setReferencedEntityName(property.getAssociatedEntity().getName());
}
 
源代码3 项目: mPaaS   文件: HibernatePropertyParser.java
/**
 * 构造ManyToOne
 */
private ManyToOne buildManyToOne(MetaProperty property, Table table,
								 String columnName) {
	ManyToOne value = new ManyToOne(metadataCollector, table);
	// value.setPropertyName(property.getName());
	value.setTypeName(property.getType());
	value.setReferencedEntityName(property.getType());
	value.setLazy(property.isLazy());
	buildColumn(columnName, IDGenerator.LEN, value, table);
	value.createForeignKey();
	return value;
}
 
源代码4 项目: cacheonix-core   文件: HbmBinder.java
public static void bindManyToOne(Element node, ManyToOne manyToOne, String path,
		boolean isNullable, Mappings mappings) throws MappingException {

	bindColumnsOrFormula( node, manyToOne, path, isNullable, mappings );
	initOuterJoinFetchSetting( node, manyToOne );
	initLaziness( node, manyToOne, mappings, true );

	Attribute ukName = node.attribute( "property-ref" );
	if ( ukName != null ) {
		manyToOne.setReferencedPropertyName( ukName.getValue() );
	}

	manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );

	String embed = node.attributeValue( "embed-xml" );
	manyToOne.setEmbedded( embed == null || "true".equals( embed ) );

	String notFound = node.attributeValue( "not-found" );
	manyToOne.setIgnoreNotFound( "ignore".equals( notFound ) );

	if( ukName != null && !manyToOne.isIgnoreNotFound() ) {
		if ( !node.getName().equals("many-to-many") ) { //TODO: really bad, evil hack to fix!!!
			mappings.addSecondPass( new ManyToOneSecondPass(manyToOne) );
		}
	}

	Attribute fkNode = node.attribute( "foreign-key" );
	if ( fkNode != null ) manyToOne.setForeignKeyName( fkNode.getValue() );

	validateCascade( node, path );
}
 
源代码5 项目: lams   文件: ModelBinder.java
private void bindManyToOneAttribute(
		final MappingDocument sourceDocument,
		final SingularAttributeSourceManyToOne manyToOneSource,
		ManyToOne manyToOneBinding,
		String referencedEntityName) {
	// NOTE : no type information to bind

	manyToOneBinding.setReferencedEntityName( referencedEntityName );
	if ( StringHelper.isNotEmpty( manyToOneSource.getReferencedEntityAttributeName() ) ) {
		manyToOneBinding.setReferencedPropertyName( manyToOneSource.getReferencedEntityAttributeName() );
		manyToOneBinding.setReferenceToPrimaryKey( false );
	}
	else {
		manyToOneBinding.setReferenceToPrimaryKey( true );
	}

	manyToOneBinding.setLazy( manyToOneSource.getFetchCharacteristics().getFetchTiming() == FetchTiming.DELAYED );
	manyToOneBinding.setUnwrapProxy( manyToOneSource.getFetchCharacteristics().isUnwrapProxies() );
	manyToOneBinding.setFetchMode(
			manyToOneSource.getFetchCharacteristics().getFetchStyle() == FetchStyle.SELECT
					? FetchMode.SELECT
					: FetchMode.JOIN
	);

	if ( manyToOneSource.isEmbedXml() == Boolean.TRUE ) {
		DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfEmbedXmlSupport();
	}

	manyToOneBinding.setIgnoreNotFound( manyToOneSource.isIgnoreNotFound() );

	if ( StringHelper.isNotEmpty( manyToOneSource.getExplicitForeignKeyName() ) ) {
		manyToOneBinding.setForeignKeyName( manyToOneSource.getExplicitForeignKeyName() );
	}

	final ManyToOneColumnBinder columnBinder = new ManyToOneColumnBinder(
			sourceDocument,
			manyToOneSource,
			manyToOneBinding,
			referencedEntityName
	);
	final boolean canBindColumnsImmediately = columnBinder.canProcessImmediately();
	if ( canBindColumnsImmediately ) {
		columnBinder.doSecondPass( null );
	}
	else {
		sourceDocument.getMetadataCollector().addSecondPass( columnBinder );
	}

	if ( !manyToOneSource.isIgnoreNotFound() ) {
		// we skip creating the FK here since this setting tells us there
		// cannot be a suitable/proper FK
		final ManyToOneFkSecondPass fkSecondPass = new ManyToOneFkSecondPass(
				sourceDocument,
				manyToOneSource,
				manyToOneBinding,
				referencedEntityName
		);

		if ( canBindColumnsImmediately && fkSecondPass.canProcessImmediately() ) {
			fkSecondPass.doSecondPass( null );
		}
		else {
			sourceDocument.getMetadataCollector().addSecondPass( fkSecondPass );
		}
	}

	manyToOneBinding.setCascadeDeleteEnabled( manyToOneSource.isCascadeDeleteEnabled() );
}
 
源代码6 项目: gorm-hibernate5   文件: GrailsDomainBinder.java
/**
 * Binds a many-to-many relationship. A many-to-many consists of
 * - a key (a DependentValue)
 * - an element
 *
 * The element is a ManyToOne from the association table to the target entity
 *
 * @param property The grails property
 * @param element  The ManyToOne element
 * @param mappings The mappings
 */
protected void bindManyToMany(Association property, ManyToOne element,
                              InFlightMetadataCollector mappings, String sessionFactoryBeanName) {
    bindManyToOne(property, element, EMPTY_PATH, mappings, sessionFactoryBeanName);
    element.setReferencedEntityName(property.getOwner().getName());
}