Skip to content

Commit 67bd785

Browse files
committed
more misc cleanups
Signed-off-by: Gavin King <[email protected]>
1 parent ab12b43 commit 67bd785

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BytecodeProviderImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import net.bytebuddy.jar.asm.Type;
6969
import net.bytebuddy.matcher.ElementMatcher;
7070
import net.bytebuddy.matcher.ElementMatchers;
71-
import net.bytebuddy.pool.TypePool;
7271
import org.checkerframework.checker.nullness.qual.Nullable;
7372

7473
public class BytecodeProviderImpl implements BytecodeProvider {

hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.hibernate.internal.CoreMessageLogger;
2828
import org.hibernate.persister.collection.CollectionPersister;
2929
import org.hibernate.persister.entity.EntityPersister;
30-
import org.hibernate.pretty.MessageHelper;
31-
import org.hibernate.proxy.HibernateProxy;
3230
import org.hibernate.type.AnyType;
3331
import org.hibernate.type.AssociationType;
3432
import org.hibernate.type.CollectionType;
@@ -38,13 +36,11 @@
3836
import org.hibernate.type.ForeignKeyDirection;
3937
import org.hibernate.type.ManyToOneType;
4038
import org.hibernate.type.OneToOneType;
41-
import org.hibernate.type.OneToOneType;
4239
import org.hibernate.type.Type;
4340

4441
import static org.hibernate.engine.internal.ManagedTypeHelper.isHibernateProxy;
4542
import static org.hibernate.engine.spi.CascadingActions.CHECK_ON_FLUSH;
4643
import static org.hibernate.pretty.MessageHelper.infoString;
47-
import static org.hibernate.type.ForeignKeyDirection.TO_PARENT;
4844

4945
/**
5046
* Delegate responsible for, in conjunction with the various
@@ -364,10 +360,9 @@ private static <T> void cascadeLogicalOneToOneOrphanRemoval(
364360
);
365361
}
366362

367-
if ( type instanceof CollectionType
368-
|| type instanceof OneToOneType && ( (OneToOneType) type ).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT ) {
363+
if ( isForeignKeyToParent( type ) ) {
369364
// If FK direction is to-parent, we must remove the orphan *before* the queued update(s)
370-
// occur. Otherwise, replacing the association on a managed entity, without manually
365+
// occur. Otherwise, replacing the association on a managed entity, without manually
371366
// nulling and flushing, causes FK constraint violations.
372367
eventSource.removeOrphanBeforeUpdates( entityName, loadedValue );
373368
}
@@ -381,6 +376,12 @@ private static <T> void cascadeLogicalOneToOneOrphanRemoval(
381376
}
382377
}
383378

379+
private static boolean isForeignKeyToParent(Type type) {
380+
return type instanceof CollectionType
381+
|| type instanceof OneToOneType
382+
&& ((OneToOneType) type).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT;
383+
}
384+
384385
/**
385386
* Check if the association is a one to one in the logical model (either a shared-pk
386387
* or unique fk).

hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key
889889
private Object removeProxyByKey(final EntityKey key) {
890890
final EntityHolderImpl entityHolder;
891891
if ( entitiesByKey != null && ( entityHolder = entitiesByKey.get( key ) ) != null ) {
892-
Object proxy = entityHolder.proxy;
892+
final Object proxy = entityHolder.proxy;
893893
entityHolder.proxy = null;
894894
return proxy;
895895
}
@@ -901,17 +901,16 @@ public Object proxyFor(EntityPersister persister, EntityKey key, Object impl) th
901901
if ( !persister.hasProxy() ) {
902902
return impl;
903903
}
904-
final Object proxy = getProxy( key );
905-
return ( proxy != null ) ? narrowProxy( proxy, persister, key, impl ) : impl;
904+
else {
905+
final Object proxy = getProxy( key );
906+
return proxy != null ? narrowProxy( proxy, persister, key, impl ) : impl;
907+
}
906908
}
907909

908910
@Override
909911
public Object proxyFor(Object impl) throws HibernateException {
910912
final EntityEntry e = getEntry( impl );
911-
if ( e == null ) {
912-
return impl;
913-
}
914-
return proxyFor( e.getPersister(), e.getEntityKey(), impl );
913+
return e == null ? impl : proxyFor( e.getPersister(), e.getEntityKey(), impl );
915914
}
916915

917916
@Override

hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.hibernate.boot.cfgxml.spi.MappingReference;
3434
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
3535
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
36-
import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
3736
import org.hibernate.boot.jaxb.spi.Binding;
3837
import org.hibernate.boot.model.TypeContributor;
3938
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;

hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/PersistenceUnitInfoDescriptor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
package org.hibernate.jpa.boot.internal;
88

99
import java.net.URL;
10-
import java.util.ArrayList;
11-
import java.util.Collection;
1210
import java.util.List;
1311
import java.util.Properties;
1412

hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceUnitDescriptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.hibernate.jpa.boot.spi;
88

99
import java.net.URL;
10-
import java.util.Collection;
1110
import java.util.List;
1211
import java.util.Properties;
1312
import jakarta.persistence.SharedCacheMode;

0 commit comments

Comments
 (0)