mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
misc code cleanups
This commit is contained in:
parent
205eb0dc38
commit
0cb6679f6e
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
Loading…
x
Reference in New Issue
Block a user