org.hibernate.mapping.SimpleValue#setCascadeDeleteEnabled ( )源码实例Demo

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

源代码1 项目: lams   文件: OneToOneSecondPass.java
/**
 * Builds the <code>Join</code> instance for the mapped by side of a <i>OneToOne</i> association using 
 * a join tables.
 * <p>
 * Note:<br/>
 * <ul>
 * <li>From the mappedBy side we should not create the PK nor the FK, this is handled from the other side.</li>
 * <li>This method is a dirty dupe of EntityBinder.bindSecondaryTable</i>.
 * </p>
 */
private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
	Join join = new Join();
	join.setPersistentClass( persistentClass );

	//no check constraints available on joins
	join.setTable( originalJoin.getTable() );
	join.setInverse( true );
	SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
	//TODO support @ForeignKey
	join.setKey( key );
	join.setSequentialSelect( false );
	//TODO support for inverse and optional
	join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
	key.setCascadeDeleteEnabled( false );
	Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
	while ( mappedByColumns.hasNext() ) {
		Column column = (Column) mappedByColumns.next();
		Column copy = new Column();
		copy.setLength( column.getLength() );
		copy.setScale( column.getScale() );
		copy.setValue( key );
		copy.setName( column.getQuotedName() );
		copy.setNullable( column.isNullable() );
		copy.setPrecision( column.getPrecision() );
		copy.setUnique( column.isUnique() );
		copy.setSqlType( column.getSqlType() );
		copy.setCheckConstraint( column.getCheckConstraint() );
		copy.setComment( column.getComment() );
		copy.setDefaultValue( column.getDefaultValue() );
		key.addColumn( copy );
	}
	persistentClass.addJoin( join );
	return join;
}
 
源代码2 项目: lams   文件: EntityBinder.java
private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, MetadataBuildingContext buildingContext) {
	SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
	join.setKey( key );
	setFKNameIfDefined( join );
	key.setCascadeDeleteEnabled( false );
	TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, buildingContext );
	join.createPrimaryKey();
	join.createForeignKey();
	persistentClass.addJoin( join );
}
 
源代码3 项目: lams   文件: ModelBinder.java
private void bindJoinedSubclassEntity(
		JoinedSubclassEntitySourceImpl entitySource,
		JoinedSubclass entityDescriptor) {
	MappingDocument mappingDocument = entitySource.sourceMappingDocument();

	bindBasicEntityValues(
			mappingDocument,
			entitySource,
			entityDescriptor
	);

	final Table primaryTable = bindEntityTableSpecification(
			mappingDocument,
			entitySource.getPrimaryTable(),
			null,
			entitySource,
			entityDescriptor
	);

	entityDescriptor.setTable( primaryTable );
	if ( log.isDebugEnabled() ) {
		log.debugf( "Mapping joined-subclass: %s -> %s", entityDescriptor.getEntityName(), primaryTable.getName() );
	}

	// KEY
	final SimpleValue keyBinding = new DependantValue(
			mappingDocument,
			primaryTable,
			entityDescriptor.getIdentifier()
	);
	if ( mappingDocument.getBuildingOptions().useNationalizedCharacterData() ) {
		keyBinding.makeNationalized();
	}
	entityDescriptor.setKey( keyBinding );
	keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() );
	relationalObjectBinder.bindColumns(
			mappingDocument,
			entitySource.getPrimaryKeyColumnSources(),
			keyBinding,
			false,
			new RelationalObjectBinder.ColumnNamingDelegate() {
				int count = 0;
				@Override
				public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
					final Column column = primaryTable.getPrimaryKey().getColumn( count++ );
					return database.toIdentifier( column.getQuotedName() );
				}
			}
	);
	keyBinding.setForeignKeyName( entitySource.getExplicitForeignKeyName() );
	// model.getKey().setType( new Type( model.getIdentifier() ) );
	entityDescriptor.createPrimaryKey();
	entityDescriptor.createForeignKey();

	// todo : tooling hints

	bindAllEntityAttributes(
			entitySource.sourceMappingDocument(),
			entitySource,
			entityDescriptor
	);

	bindJoinedSubclassEntities( entitySource, entityDescriptor );
}
 
源代码4 项目: cacheonix-core   文件: HbmBinder.java
public static void bindJoinedSubclass(Element node, JoinedSubclass joinedSubclass,
		Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

	bindClass( node, joinedSubclass, mappings, inheritedMetas );
	inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from
																// <joined-subclass>

	// joined subclasses
	if ( joinedSubclass.getEntityPersisterClass() == null ) {
		joinedSubclass.getRootClass()
			.setEntityPersisterClass( JoinedSubclassEntityPersister.class );
	}

	Attribute schemaNode = node.attribute( "schema" );
	String schema = schemaNode == null ?
			mappings.getSchemaName() : schemaNode.getValue();

	Attribute catalogNode = node.attribute( "catalog" );
	String catalog = catalogNode == null ?
			mappings.getCatalogName() : catalogNode.getValue();

	Table mytable = mappings.addTable(
			schema,
			catalog,
			getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
			getSubselect( node ),
			false
		);
	joinedSubclass.setTable( mytable );
	bindComment(mytable, node);

	log.info(
			"Mapping joined-subclass: " + joinedSubclass.getEntityName() +
			" -> " + joinedSubclass.getTable().getName()
		);

	// KEY
	Element keyNode = node.element( "key" );
	SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
	joinedSubclass.setKey( key );
	key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
	bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );

	// model.getKey().setType( new Type( model.getIdentifier() ) );
	joinedSubclass.createPrimaryKey();
	joinedSubclass.createForeignKey();

	// CHECK
	Attribute chNode = node.attribute( "check" );
	if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );

	// properties
	createClassProperties( node, joinedSubclass, mappings, inheritedMetas );

}