Java Code Examples for org.hibernate.mapping.SimpleValue#setCascadeDeleteEnabled()
The following examples show how to use
org.hibernate.mapping.SimpleValue#setCascadeDeleteEnabled() .
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: OneToOneSecondPass.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 2
Source File: EntityBinder.java From lams with GNU General Public License v2.0 | 5 votes |
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 ); }
Example 3
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 4 votes |
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 ); }
Example 4
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
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 ); }