Skip to content

Commit 64b109e

Browse files
committed
HHH-19183 Remove commit 9728694 by Peter Holvenstot
1 parent d4d3c58 commit 64b109e

File tree

5 files changed

+5
-477
lines changed

5 files changed

+5
-477
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AbstractPluralAttributeSourceImpl.java

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
*/
55
package org.hibernate.boot.model.source.internal.hbm;
66

7-
import java.io.Serializable;
8-
import java.util.ArrayList;
9-
import java.util.List;
10-
import java.util.Optional;
117

128
import org.hibernate.AssertionFailure;
139
import org.hibernate.boot.MappingException;
14-
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmColumnType;
1510
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFilterType;
16-
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToOneType;
17-
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
1811
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSynchronizeType;
1912
import org.hibernate.boot.jaxb.hbm.spi.PluralAttributeInfo;
2013
import org.hibernate.boot.model.source.spi.Caching;
@@ -72,75 +65,11 @@ protected AbstractPluralAttributeSourceImpl(
7265
this.attributeRole = container.getAttributeRoleBase().append( pluralAttributeJaxbMapping.getName() );
7366
this.attributePath = container.getAttributePathBase().append( pluralAttributeJaxbMapping.getName() );
7467

75-
Optional<JaxbHbmManyToOneType> jaxbHbmManyToOneTypeOptional = Optional.empty();
76-
77-
// Our goal here is to find the inverse side of a one to many to figure out against what to join
78-
if ( pluralAttributeJaxbMapping.isInverse() && pluralAttributeJaxbMapping.getOneToMany() != null && pluralAttributeJaxbMapping.getKey().getPropertyRef() == null ) {
79-
String childClass = pluralAttributeJaxbMapping.getOneToMany().getClazz();
80-
81-
if ( childClass != null ) {
82-
// We match by columns as defined in the key
83-
final List<String> keyColumnNames;
84-
if ( pluralAttributeJaxbMapping.getKey().getColumnAttribute() == null ) {
85-
keyColumnNames = new ArrayList<>( pluralAttributeJaxbMapping.getKey().getColumn().size() );
86-
for ( JaxbHbmColumnType jaxbHbmColumnType : pluralAttributeJaxbMapping.getKey().getColumn() ) {
87-
keyColumnNames.add( jaxbHbmColumnType.getName() );
88-
}
89-
}
90-
else {
91-
keyColumnNames = new ArrayList<>( 1 );
92-
keyColumnNames.add( pluralAttributeJaxbMapping.getKey().getColumnAttribute() );
93-
}
94-
jaxbHbmManyToOneTypeOptional = mappingDocument.getDocumentRoot().getClazz()
95-
.stream()
96-
.filter( (JaxbHbmRootEntityType entityType) -> childClass.equals( entityType.getName() ) )
97-
.flatMap( jaxbHbmRootEntityType -> jaxbHbmRootEntityType.getAttributes().stream() )
98-
.filter( attribute -> {
99-
if ( attribute instanceof JaxbHbmManyToOneType manyToOneType ) {
100-
String manyToOneTypeClass = manyToOneType.getClazz();
101-
String containerClass = container.getAttributeRoleBase().getFullPath();
102-
// Consider many to ones that have no class defined or equal the owner class of the one to many
103-
if ( manyToOneTypeClass == null || manyToOneTypeClass.equals( containerClass ) ) {
104-
if ( manyToOneType.getColumnAttribute() == null ) {
105-
List<Serializable> columns = manyToOneType.getColumnOrFormula();
106-
if ( columns.size() != keyColumnNames.size() ) {
107-
return false;
108-
}
109-
for ( int i = 0; i < columns.size(); i++ ) {
110-
Serializable column = columns.get( i );
111-
String keyColumn = keyColumnNames.get( i );
112-
if ( !( column instanceof JaxbHbmColumnType ) || !( (JaxbHbmColumnType) column )
113-
.getName()
114-
.equals( keyColumn ) ) {
115-
return false;
116-
}
117-
}
118-
}
119-
else {
120-
return keyColumnNames.size() == 1 && keyColumnNames.get( 0 )
121-
.equals( manyToOneType.getColumnAttribute() );
122-
}
123-
return true;
124-
}
125-
}
126-
return false;
127-
})
128-
.map( JaxbHbmManyToOneType.class::cast )
129-
.findFirst();
130-
}
131-
}
132-
133-
this.keySource = jaxbHbmManyToOneTypeOptional
134-
.map( jaxbHbmManyToOneType -> new PluralAttributeKeySourceImpl(
135-
sourceMappingDocument(),
136-
pluralAttributeJaxbMapping.getKey(),
137-
jaxbHbmManyToOneType,
138-
container
139-
) ).orElseGet( () -> new PluralAttributeKeySourceImpl(
140-
sourceMappingDocument(),
141-
pluralAttributeJaxbMapping.getKey(),
142-
container
143-
) );
68+
this.keySource = new PluralAttributeKeySourceImpl(
69+
sourceMappingDocument(),
70+
pluralAttributeJaxbMapping.getKey(),
71+
container
72+
);
14473

14574
this.typeInformation = new HibernateTypeSourceImpl( pluralAttributeJaxbMapping.getCollectionType() );
14675

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/PluralAttributeKeySourceImpl.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.List;
88

99
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmKeyType;
10-
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToOneType;
1110
import org.hibernate.boot.model.source.spi.AttributeSourceContainer;
1211
import org.hibernate.boot.model.source.spi.PluralAttributeKeySource;
1312
import org.hibernate.boot.model.source.spi.RelationalValueSource;
@@ -70,62 +69,6 @@ public List getColumnOrFormulaElements() {
7069
);
7170
}
7271

73-
public PluralAttributeKeySourceImpl(
74-
MappingDocument mappingDocument,
75-
final JaxbHbmKeyType jaxbKey,
76-
final JaxbHbmManyToOneType jaxbManyToOne,
77-
final AttributeSourceContainer container) {
78-
super( mappingDocument );
79-
80-
this.explicitFkName = StringHelper.nullIfEmpty( jaxbManyToOne.getForeignKey() );
81-
this.referencedPropertyName = StringHelper.nullIfEmpty( jaxbManyToOne.getPropertyRef() );
82-
if ( jaxbKey.getOnDelete() == null ) {
83-
this.cascadeDeletesAtFkLevel = jaxbManyToOne.getOnDelete() != null && "cascade".equals( jaxbManyToOne.getOnDelete().value() );
84-
}
85-
else {
86-
this.cascadeDeletesAtFkLevel = "cascade".equals( jaxbKey.getOnDelete().value() );
87-
}
88-
if ( jaxbKey.isNotNull() == null ) {
89-
this.nullable = jaxbManyToOne.isNotNull() == null || !jaxbManyToOne.isNotNull();
90-
}
91-
else {
92-
this.nullable = !jaxbKey.isNotNull();
93-
}
94-
if ( jaxbKey.isUpdate() == null ) {
95-
this.updateable = jaxbManyToOne.isUpdate();
96-
}
97-
else {
98-
this.updateable = jaxbKey.isUpdate();
99-
}
100-
101-
this.valueSources = RelationalValueSourceHelper.buildValueSources(
102-
sourceMappingDocument(),
103-
null, // todo : collection table name
104-
new RelationalValueSourceHelper.AbstractColumnsAndFormulasSource() {
105-
@Override
106-
public XmlElementMetadata getSourceType() {
107-
return XmlElementMetadata.KEY;
108-
}
109-
110-
@Override
111-
public String getSourceName() {
112-
return null;
113-
}
114-
115-
@Override
116-
public String getColumnAttribute() {
117-
return StringHelper.nullIfEmpty( jaxbKey.getColumnAttribute() );
118-
}
119-
120-
@Override
121-
public List getColumnOrFormulaElements() {
122-
return jaxbKey.getColumn();
123-
}
124-
125-
}
126-
);
127-
}
128-
12972
@Override
13073
public String getExplicitForeignKeyName() {
13174
return explicitFkName;

hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.java

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)