Skip to content

Commit de66ab3

Browse files
committed
remove unnecessary LOG in Table
1 parent 9356c50 commit de66ab3

File tree

1 file changed

+22
-23
lines changed
  • hibernate-core/src/main/java/org/hibernate/mapping

1 file changed

+22
-23
lines changed

hibernate-core/src/main/java/org/hibernate/mapping/Table.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.hibernate.dialect.Dialect;
3131

3232
import org.hibernate.resource.transaction.spi.DdlTransactionIsolator;
33-
import org.jboss.logging.Logger;
3433

3534
import static java.util.Collections.emptyList;
3635
import static java.util.Collections.singletonList;
@@ -46,7 +45,6 @@
4645
* @author Gavin King
4746
*/
4847
public class Table implements Serializable, ContributableDatabaseObject {
49-
private static final Logger LOG = Logger.getLogger( Table.class );
5048
private static final Column[] EMPTY_COLUMN_ARRAY = new Column[0];
5149

5250
private final String contributor;
@@ -110,17 +108,19 @@ public Table(
110108
String subselect,
111109
boolean isAbstract) {
112110
this.contributor = contributor;
113-
this.catalog = namespace.getPhysicalName().catalog();
114-
this.schema = namespace.getPhysicalName().schema();
111+
final var physicalName = namespace.getPhysicalName();
112+
this.catalog = physicalName.catalog();
113+
this.schema = physicalName.schema();
115114
this.name = physicalTableName;
116115
this.subselect = subselect;
117116
this.isAbstract = isAbstract;
118117
}
119118

120119
public Table(String contributor, Namespace namespace, String subselect, boolean isAbstract) {
121120
this.contributor = contributor;
122-
this.catalog = namespace.getPhysicalName().catalog();
123-
this.schema = namespace.getPhysicalName().schema();
121+
final var physicalName = namespace.getPhysicalName();
122+
this.catalog = physicalName.catalog();
123+
this.schema = physicalName.schema();
124124
this.subselect = subselect;
125125
this.isAbstract = isAbstract;
126126
}
@@ -247,7 +247,7 @@ public Column getColumn(Column column) {
247247
return null;
248248
}
249249
else {
250-
final Column existing = columns.get( column.getCanonicalName() );
250+
final var existing = columns.get( column.getCanonicalName() );
251251
return column.equals( existing ) ? existing : null;
252252
}
253253
}
@@ -276,15 +276,11 @@ public void addColumn(Column column) {
276276
if ( oldColumn == null ) {
277277
if ( primaryKey != null ) {
278278
for ( var primaryKeyColumn : primaryKey.getColumns() ) {
279-
if ( primaryKeyColumn.getCanonicalName().equals( column.getCanonicalName() ) ) {
279+
if ( Objects.equals( column.getCanonicalName(),
280+
primaryKeyColumn.getCanonicalName() ) ) {
281+
// Force the column to be non-null
282+
// as it is part of the primary key
280283
column.setNullable( false );
281-
if ( LOG.isTraceEnabled() ) {
282-
LOG.tracef(
283-
"Forcing column [%s] to be non-null as it is part of the primary key for table [%s]",
284-
column.getCanonicalName(),
285-
getNameIdentifier().getCanonicalName()
286-
);
287-
}
288284
}
289285
}
290286
}
@@ -452,18 +448,21 @@ public void setPrimaryKey(PrimaryKey primaryKey) {
452448
}
453449

454450
public Index getOrCreateIndex(String indexName) {
455-
Index index = indexes.get( indexName );
456-
if ( index == null ) {
457-
index = new Index();
458-
index.setName( indexName );
459-
index.setTable( this );
460-
indexes.put( indexName, index );
451+
final var index = indexes.get( indexName );
452+
if ( index != null ) {
453+
return index;
454+
}
455+
else {
456+
final var newIndex = new Index();
457+
newIndex.setName( indexName );
458+
newIndex.setTable( this );
459+
indexes.put( indexName, newIndex );
460+
return newIndex;
461461
}
462-
return index;
463462
}
464463

465464
public Index getIndex(String indexName) {
466-
return indexes.get( indexName );
465+
return indexes.get( indexName );
467466
}
468467

469468
public Index addIndex(Index index) {

0 commit comments

Comments
 (0)