private void bindJoinedSubclassEntities( AbstractEntitySourceImpl entitySource, PersistentClass superEntityDescriptor) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { final JoinedSubclass subEntityDescriptor = new JoinedSubclass( superEntityDescriptor, metadataBuildingContext ); bindJoinedSubclassEntity( (JoinedSubclassEntitySourceImpl) subType, subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); } }
); entityDescriptor.setTable( primaryTable ); if ( log.isDebugEnabled() ) { log.debugf( "Mapping joined-subclass: %s -> %s", entityDescriptor.getEntityName(), primaryTable.getName() ); mappingDocument, primaryTable, entityDescriptor.getIdentifier() ); if ( mappingDocument.getBuildingOptions().useNationalizedCharacterData() ) { keyBinding.makeNationalized(); entityDescriptor.setKey( keyBinding ); keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() ); relationalObjectBinder.bindColumns( keyBinding.setForeignKeyName( entitySource.getExplicitForeignKeyName() ); entityDescriptor.createPrimaryKey(); entityDescriptor.createForeignKey();
public void doSecondPass(Map persistentClasses) throws MappingException { TableBinder.bindFk( entity.getSuperclass(), entity, columns, value, false, buildingContext ); } }
public void doSecondPass(Map persistentClasses) throws MappingException { if ( rootClass != null ) { rootClass.createPrimaryKey(); } else if ( joinedSubClass != null ) { joinedSubClass.createPrimaryKey(); joinedSubClass.createForeignKey(); } else { throw new AssertionError( "rootClass and joinedSubClass are null" ); } } }
bindClass(sub, joinedSubclass, mappings); if (joinedSubclass.getEntityPersisterClass() == null) { joinedSubclass.getRootClass().setEntityPersisterClass(GroovyAwareJoinedSubclassEntityPersister.class); null, false); joinedSubclass.setTable(mytable); LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> " + joinedSubclass.getTable().getName()); SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier()); joinedSubclass.setKey(key); GrailsDomainClassProperty identifier = sub.getIdentifier(); String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName); bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings); joinedSubclass.createPrimaryKey();
onDeleteAppropriate = true; final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass; SimpleValue key = new DependantValue( context, jsc.getTable(), jsc.getIdentifier() ); jsc.setKey( key ); ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class ); if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) {
persistentClass = new JoinedSubclass( superEntity ); persistentClass.getRootClass().setEntityPersisterClass( JoinedSubclassEntityPersister.class ); SimpleValue key = new DependantValue( jsc.getTable(), jsc.getIdentifier() ); jsc.setKey( key ); if ( onDeleteAnn != null ) { key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ) ); key.setCascadeDeleteEnabled( false ); TableBinder.bindFk( jsc.getSuperclass(), jsc, inheritanceJoinedColumns, key, false, mappings );
); entityDescriptor.setMappedTable( primaryTable ); if ( log.isDebugEnabled() ) { log.debugf( "Mapping joined-subclass: %s -> %s", entityDescriptor.getEntityName(), primaryTable.getName() ); mappingDocument, primaryTable, entityDescriptor.getIdentifier() ); if ( mappingDocument.getBuildingOptions().useNationalizedCharacterData() ) { keyBinding.makeNationalized(); entityDescriptor.setKey( keyBinding ); keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() ); relationalObjectBinder.bindColumns( keyBinding.setForeignKeyName( entitySource.getExplicitForeignKeyName() ); entityDescriptor.createPrimaryKey(); entityDescriptor.createForeignKey();
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( key!=null && !key.isValid(mapping) ) { throw new MappingException( "subclass key mapping has wrong number of columns: " + getEntityName() + " type: " + key.getType().getName() ); } }
@Test public void testProperCallbacks() { PersistentClassVisitorValidator vv = new PersistentClassVisitorValidator(); new RootClass( metadataBuildingContext ).accept( vv ); new Subclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new JoinedSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new SingleTableSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new UnionSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); }
public Iterator getReferenceablePropertyIterator() { return getPropertyIterator(); }
bindClass(sub, joinedSubclass, mappings); if (joinedSubclass.getEntityPersisterClass() == null) { joinedSubclass.getRootClass().setEntityPersisterClass(getGroovyAwareJoinedSubclassEntityPersisterClass()); null, false); joinedSubclass.setTable(mytable); LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> " + joinedSubclass.getTable().getName()); SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier()); joinedSubclass.setKey(key); final PersistentProperty identifier = sub.getIdentity(); String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName); bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings); joinedSubclass.createPrimaryKey();
persistentClass.getRootClass().setEntityPersisterClass( JoinedSubclassEntityPersister.class ); SimpleValue key = new DependantValue( jsc.getTable(), jsc.getIdentifier() ); jsc.setKey( key ); ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class ); if ( fk != null && !BinderHelper.isDefault( fk.name() ) ) {
public void doSecondPass(Map persistentClasses) throws MappingException { if ( rootClass != null ) { rootClass.createPrimaryKey(); } else if ( joinedSubClass != null ) { joinedSubClass.createPrimaryKey(); joinedSubClass.createForeignKey(); } else { throw new AssertionError( "rootClass and joinedSubClass are null" ); } } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( key!=null && !key.isValid(mapping) ) { throw new MappingException( "subclass key mapping has wrong number of columns: " + getEntityName() + " type: " + key.getType().getName() ); } }
@Override public Iterator getReferenceablePropertyIterator() { return getPropertyIterator(); }
if ( joinedSubclass.getEntityPersisterClass() == null ) { joinedSubclass.getRootClass().setEntityPersisterClass( JoinedSubclassEntityPersister.class ); getSubselect( node ), false ); joinedSubclass.setTable( mytable ); bindComment(mytable, node); + joinedSubclass.getEntityName() + " -> " + joinedSubclass.getTable().getName() ); 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 ); joinedSubclass.createPrimaryKey(); joinedSubclass.createForeignKey();
false ); joinedSubclass.setTable( mytable ); bindComment(mytable, node); LOG.debugf( "Mapping joined-subclass: %s -> %s", joinedSubclass.getEntityName(), joinedSubclass.getTable().getName() ); SimpleValue key = new DependantValue( mappings, mytable, joinedSubclass.getIdentifier() ); joinedSubclass.setKey( key ); key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) ); bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings ); joinedSubclass.createPrimaryKey(); joinedSubclass.createForeignKey();
onDeleteAppropriate = true; final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass; SimpleValue key = new DependantValue( mappings, jsc.getTable(), jsc.getIdentifier() ); jsc.setKey( key ); ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class ); if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) {
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException { if ( rootClass != null ) { rootClass.createPrimaryKey(); } else if ( joinedSubClass != null ) { joinedSubClass.createPrimaryKey(); joinedSubClass.createForeignKey(); } else { throw new AssertionError( "rootClass and joinedSubClass are null" ); } } }