Merge pull request #1 from akarsh-jain/akarsh-jain-patch-1

Revert changes to isolate cyclic entity (HHH-13068) fixes
This commit is contained in:
akarsh-jain 2019-05-24 18:09:06 +05:30 committed by GitHub
commit d7a2e24aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 23 deletions

View File

@ -1261,7 +1261,6 @@ public class ActionQueue {
ClassMetadata classMetadata = action.getPersister().getClassMetadata(); ClassMetadata classMetadata = action.getPersister().getClassMetadata();
if ( classMetadata != null ) { if ( classMetadata != null ) {
Type[] propertyTypes = classMetadata.getPropertyTypes(); Type[] propertyTypes = classMetadata.getPropertyTypes();
Type identifierType = classMetadata.getIdentifierType();
for ( int i = 0; i < propertyValues.length; i++ ) { for ( int i = 0; i < propertyValues.length; i++ ) {
Object value = propertyValues[i]; Object value = propertyValues[i];
@ -1269,27 +1268,17 @@ public class ActionQueue {
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value ); addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
} }
if ( identifierType.isComponentType() ) {
CompositeType compositeType = (CompositeType) identifierType;
Type[] compositeIdentifierTypes = compositeType.getSubtypes();
for ( Type type : compositeIdentifierTypes ) {
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
}
}
} }
} }
private void addParentChildEntityNameByPropertyAndValue(AbstractEntityInsertAction action, BatchIdentifier batchIdentifier, Type type, Object value) { private void addParentChildEntityNameByPropertyAndValue(AbstractEntityInsertAction action, BatchIdentifier batchIdentifier, Type type, Object value) {
if ( type.isEntityType() ) { if ( type.isEntityType() && value != null ) {
final EntityType entityType = (EntityType) type; final EntityType entityType = (EntityType) type;
final String entityName = entityType.getName(); final String entityName = entityType.getName();
final String rootEntityName = action.getSession().getFactory().getMetamodel().entityPersister( entityName ).getRootEntityName(); final String rootEntityName = action.getSession().getFactory().getMetamodel().entityPersister( entityName ).getRootEntityName();
if ( entityType.isOneToOne() && OneToOneType.class.cast( entityType ).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT ) { if ( entityType.isOneToOne() && OneToOneType.class.cast( entityType ).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT ) {
if ( !entityType.isReferenceToPrimaryKey() ) {
batchIdentifier.getChildEntityNames().add( entityName ); batchIdentifier.getChildEntityNames().add( entityName );
}
if ( !rootEntityName.equals( entityName ) ) { if ( !rootEntityName.equals( entityName ) ) {
batchIdentifier.getChildEntityNames().add( rootEntityName ); batchIdentifier.getChildEntityNames().add( rootEntityName );
} }
@ -1298,23 +1287,20 @@ public class ActionQueue {
if ( !batchIdentifier.getEntityName().equals( entityName ) ) { if ( !batchIdentifier.getEntityName().equals( entityName ) ) {
batchIdentifier.getParentEntityNames().add( entityName ); batchIdentifier.getParentEntityNames().add( entityName );
} }
if ( value != null ) {
String valueClass = value.getClass().getName(); String valueClass = value.getClass().getName();
if ( !valueClass.equals( entityName ) ) { if ( !valueClass.equals( entityName ) ) {
batchIdentifier.getParentEntityNames().add( valueClass ); batchIdentifier.getParentEntityNames().add( valueClass );
} }
}
if ( !rootEntityName.equals( entityName ) ) { if ( !rootEntityName.equals( entityName ) ) {
batchIdentifier.getParentEntityNames().add( rootEntityName ); batchIdentifier.getParentEntityNames().add( rootEntityName );
} }
} }
} }
else if ( type.isCollectionType() ) { else if ( type.isCollectionType() && value != null ) {
CollectionType collectionType = (CollectionType) type; CollectionType collectionType = (CollectionType) type;
final SessionFactoryImplementor sessionFactory = ( (SessionImplementor) action.getSession() ) final SessionFactoryImplementor sessionFactory = ( (SessionImplementor) action.getSession() )
.getSessionFactory(); .getSessionFactory();
if ( collectionType.getElementType( sessionFactory ).isEntityType() && if ( collectionType.getElementType( sessionFactory ).isEntityType() ) {
!sessionFactory.getMetamodel().collectionPersister( collectionType.getRole() ).isManyToMany() ) {
String entityName = collectionType.getAssociatedEntityName( sessionFactory ); String entityName = collectionType.getAssociatedEntityName( sessionFactory );
String rootEntityName = action.getSession().getFactory().getMetamodel().entityPersister( entityName ).getRootEntityName(); String rootEntityName = action.getSession().getFactory().getMetamodel().entityPersister( entityName ).getRootEntityName();
batchIdentifier.getChildEntityNames().add( entityName ); batchIdentifier.getChildEntityNames().add( entityName );