misc code cleanups

This commit is contained in:
Gavin King 2024-12-17 21:28:19 +01:00
parent 205eb0dc38
commit 0cb6679f6e
4 changed files with 18 additions and 18 deletions

View File

@ -25,7 +25,7 @@
import static org.hibernate.internal.util.NullnessUtil.castNonNull;
/**
* The action for performing entity insertions when entity is using IDENTITY column identifier generation
* The action for performing entity insertions when entity is using {@code IDENTITY} column identifier generation
*
* @see EntityInsertAction
*/
@ -184,8 +184,8 @@ protected void postCommitInsert(boolean success) {
}
private void postCommitInsertOnFailure(PostInsertEventListener listener, PostInsertEvent event) {
if ( listener instanceof PostCommitInsertEventListener ) {
((PostCommitInsertEventListener) listener).onPostInsertCommitFailed( event );
if ( listener instanceof PostCommitInsertEventListener postCommitInsertEventListener ) {
postCommitInsertEventListener.onPostInsertCommitFailed( event );
}
else {
//default to the legacy implementation that always fires the event

View File

@ -30,7 +30,7 @@
import org.hibernate.stat.spi.StatisticsImplementor;
/**
* The action for performing an entity insertion, for entities not defined to use IDENTITY generation.
* The action for performing an entity insertion, for entities not defined to use {@code IDENTITY} generation.
*
* @see EntityIdentityInsertAction
*/

View File

@ -393,7 +393,7 @@ protected Map<Object,Object> getMergeMap(C anything) {
}
/**
* After the save, will te version number be incremented
* After the save, will the version number be incremented
* if the instance is modified?
*
* @return True if the version will be incremented on an entity change after save;

View File

@ -59,7 +59,6 @@
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.LazyInitializer;
@ -585,25 +584,26 @@ private void firePostDelete(Object entity, Object id, EntityPersister persister)
private void forEachOwnedCollection(
Object entity, Object key,
EntityPersister persister, BiConsumer<CollectionPersister, PersistentCollection<?>> action) {
persister.visitAttributeMappings( att -> {
if ( att.isPluralAttributeMapping() ) {
final PluralAttributeMapping pluralAttributeMapping = att.asPluralAttributeMapping();
final CollectionPersister descriptor = pluralAttributeMapping.getCollectionDescriptor();
persister.visitAttributeMappings( attribute -> {
if ( attribute.isPluralAttributeMapping() ) {
final CollectionPersister descriptor =
attribute.asPluralAttributeMapping().getCollectionDescriptor();
if ( !descriptor.isInverse() ) {
final Object collection = att.getPropertyAccess().getGetter().get(entity);
final PersistentCollection<?> persistentCollection;
if (collection instanceof PersistentCollection) {
persistentCollection = (PersistentCollection<?>) collection;
final Object value = attribute.getPropertyAccess().getGetter().get(entity);
final PersistentCollection<?> collection;
if ( value instanceof PersistentCollection<?> persistentCollection ) {
if ( !persistentCollection.wasInitialized() ) {
return;
}
collection = persistentCollection;
}
else {
persistentCollection = collection == null
? instantiateEmpty(key, descriptor)
: wrap(descriptor, collection);
collection =
value == null
? instantiateEmpty( key, descriptor )
: wrap( descriptor, value );
}
action.accept(descriptor, persistentCollection);
action.accept( descriptor, collection );
}
}
} );