Skip to content

Commit dc4397b

Browse files
committed
extract a tiny method
1 parent 715ea1d commit dc4397b

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,7 @@ public boolean isArray() {
910910

911911
@Override
912912
public String getIdentifierColumnName() {
913-
return collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG
914-
? identifierColumnName
915-
: null;
913+
return hasId() ? identifierColumnName : null;
916914
}
917915

918916
/**
@@ -975,7 +973,7 @@ public String selectFragment(String alias, String columnSuffix) {
975973
i++;
976974
}
977975
}
978-
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
976+
if ( hasId() ) {
979977
sqlSelections.set(
980978
i,
981979
new SqlSelectionImpl(
@@ -1063,6 +1061,10 @@ public boolean hasIndex() {
10631061
return collectionSemantics.getCollectionClassification().isIndexed();
10641062
}
10651063

1064+
private boolean hasId() {
1065+
return collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG;
1066+
}
1067+
10661068
@Override
10671069
public boolean isLazy() {
10681070
return isLazy;
@@ -1394,7 +1396,7 @@ public void initCollectionPropertyMap() {
13941396
if ( hasIndex() ) {
13951397
initCollectionPropertyMap( "index", indexType, indexColumnAliases );
13961398
}
1397-
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
1399+
if ( hasId() ) {
13981400
initCollectionPropertyMap( "id", identifierType, new String[] { identifierColumnAlias } );
13991401
}
14001402
}
@@ -1856,21 +1858,11 @@ public String[] getElementColumnAliases(String suffix) {
18561858

18571859
@Override
18581860
public String[] getIndexColumnAliases(String suffix) {
1859-
if ( hasIndex() ) {
1860-
return new Alias( suffix ).toAliasStrings( indexColumnAliases );
1861-
}
1862-
else {
1863-
return null;
1864-
}
1861+
return hasIndex() ? new Alias( suffix ).toAliasStrings( indexColumnAliases ) : null;
18651862
}
18661863

18671864
@Override
18681865
public String getIdentifierColumnAlias(String suffix) {
1869-
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
1870-
return new Alias( suffix ).toAliasString( identifierColumnAlias );
1871-
}
1872-
else {
1873-
return null;
1874-
}
1866+
return hasId() ? new Alias( suffix ).toAliasString( identifierColumnAlias ) : null;
18751867
}
18761868
}

0 commit comments

Comments
 (0)