remove more usages of some deprecated methods

This commit is contained in:
Gavin King 2022-10-29 22:20:14 +02:00
parent bb0541d754
commit ecdd7e20cb
4 changed files with 23 additions and 18 deletions

View File

@ -238,12 +238,15 @@ public class ToOneAttributeMapping
// Simple one-to-one mapped by cases
if ( bidirectionalAttributeName == null ) {
for ( Property property : entityBinding.getPropertyClosure() ) {
if (property.getValue() instanceof OneToOne
&& name.equals(((OneToOne) property.getValue()).getMappedByProperty())
&& ((OneToOne) property.getValue()).getReferencedEntityName().equals(
declaringType.getJavaType().getJavaType().getTypeName())) {
bidirectionalAttributeName = property.getName();
break;
final Value value = property.getValue();
if ( value instanceof OneToOne ) {
final OneToOne oneToOne = (OneToOne) value;
if ( name.equals( oneToOne.getMappedByProperty() )
&& oneToOne.getReferencedEntityName()
.equals( declaringType.getJavaType().getJavaType().getTypeName() ) ) {
bidirectionalAttributeName = property.getName();
break;
}
}
}
}
@ -251,12 +254,14 @@ public class ToOneAttributeMapping
else {
for ( Property property : entityBinding.getPropertyClosure() ) {
final Value value = property.getValue();
if (value instanceof Collection
&& name.equals(((Collection) value).getMappedByProperty())
&& ((Collection) value).getElement().getType().getName()
.equals(declaringType.getJavaType().getJavaType().getTypeName())) {
bidirectionalAttributeName = property.getName();
break;
if ( value instanceof Collection ) {
final Collection collection = (Collection) value;
if ( name.equals(collection.getMappedByProperty() )
&& collection.getElement().getType().getName()
.equals( declaringType.getJavaType().getJavaType().getTypeName() ) ) {
bidirectionalAttributeName = property.getName();
break;
}
}
}
}

View File

@ -289,10 +289,10 @@ public class DefaultNamingCollectionElementTest {
String propertyName,
String columnName) {
final Collection collection = metadataImplementor.getCollectionBinding( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumns().iterator();
final Iterator<Column> columnIterator = collection.getCollectionTable().getColumns().iterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
Column column = (Column) columnIterator.next();
Column column = columnIterator.next();
if ( columnName.equals( column.getName() ) ) {
hasDefault = true;
}

View File

@ -88,10 +88,10 @@ public class IndexedCollectionTest {
private boolean isDefaultColumnPresent(SessionFactoryScope scope, String collectionOwner, String propertyName, String suffix) {
final Collection collection = scope.getMetadataImplementor().getCollectionBinding( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumns().iterator();
final Iterator<Column> columnIterator = collection.getCollectionTable().getColumns().iterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
Column column = (Column) columnIterator.next();
Column column = columnIterator.next();
if ( ( propertyName + suffix ).equals( column.getName() ) ) hasDefault = true;
}
return hasDefault;

View File

@ -43,10 +43,10 @@ public class EagerIndexedCollectionTest extends BaseNonConfigCoreFunctionalTestC
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) {
final Collection collection = metadata().getCollectionBinding( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumns().iterator();
final Iterator<Column> columnIterator = collection.getCollectionTable().getColumns().iterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
Column column = (Column) columnIterator.next();
Column column = columnIterator.next();
if ( (propertyName + suffix).equals( column.getName() ) ) hasDefault = true;
}
return hasDefault;