Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a miscellaneous collection of warnings #2080

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ subprojects {

ext.publishScript = rootProject.rootDir.absolutePath + '/publish.gradle'

tasks.withType( JavaCompile ) {
tasks.withType( JavaCompile ).configureEach {
options.encoding = 'UTF-8'
}

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ org.gradle.java.installations.auto-download=false
#db = MSSQL

# Enable the SonatypeOS maven repository (mainly for Vert.x snapshots) when present (value ignored)
#enableSonatypeOpenSourceSnapshotsRep = true
enableSonatypeOpenSourceSnapshotsRep = true

# Enable the maven local repository (for local development when needed) when present (value ignored)
#enableMavenLocalRepo = true

# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
hibernateOrmVersion = 7.0.0.Beta3
hibernateOrmVersion = 7.0.0-SNAPSHOT

# Override default Hibernate ORM Gradle plugin version
# Using the stable version because I don't know how to configure the build to download the snapshot version from
Expand All @@ -44,7 +44,7 @@ hibernateOrmGradlePluginVersion = 7.0.0.Beta2

# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)
# this is required when using intervals or weird versions or the build will fail
#skipOrmVersionParsing = true
skipOrmVersionParsing = true

# Override default Vert.x Sql client version
#vertxSqlClientVersion = 4.5.11-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
false
) );
}
else {
// Nothing to do, so just skip cascading to this lazy attribute.
continue;
}
// Nothing to do, so just skip cascading to this lazy attribute.
}
else {
Object child = persister.getValue( parent, i );
Expand Down Expand Up @@ -447,7 +444,7 @@ private static <T> CompletionStage<Void> cascadeLogicalOneToOneOrphanRemoval(
*
* @param type The type representing the attribute metadata
*
* @return True if the attribute represents a logical one to one association
* @return True if the attribute represents a logical one-to-one association
*/
private static boolean isLogicalOneToOne(Type type) {
return type.isEntityType() && ( (EntityType) type ).isLogicalOneToOne();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public static CompletionStage<Object> resolve(EntityType entityType, Object idOr
* @see OneToOneType#isNull(Object, SharedSessionContractImplementor)
*/
static boolean isNull(EntityType entityType, Object owner, SharedSessionContractImplementor session) {
if ( entityType instanceof OneToOneType ) {
OneToOneType type = (OneToOneType) entityType;
if ( entityType instanceof OneToOneType type ) {
String propertyName = type.getPropertyName();
if ( propertyName != null ) {
final EntityPersister ownerPersister = session.getFactory()
Expand Down Expand Up @@ -126,7 +125,7 @@ static CompletionStage<Object> loadByUniqueKey(
entityName,
uniqueKeyPropertyName,
key,
entityType.getIdentifierOrUniqueKeyType( factory ),
entityType.getIdentifierOrUniqueKeyType( factory.getRuntimeMetamodels() ),
factory
);

Expand Down Expand Up @@ -273,7 +272,7 @@ private static CompletionStage<Object> resolveIdOrUniqueKey(
.reactiveFetch( id, true )
.thenCompose( fetched -> {
Object idOrUniqueKey = entityType
.getIdentifierOrUniqueKeyType( session.getFactory() )
.getIdentifierOrUniqueKeyType( session.getFactory().getRuntimeMetamodels() )
.replace( fetched, null, session, owner, copyCache );
if ( idOrUniqueKey instanceof CompletionStage ) {
return ( (CompletionStage<?>) idOrUniqueKey )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void execute() throws HibernateException {
}

private void preRecreate() {
getFastSessionServices()
getEventListenerGroups()
.eventListenerGroup_PRE_COLLECTION_RECREATE
.fireLazyEventOnEachListener( this::newPreCollectionRecreateEvent, PreCollectionRecreateEventListener::onPreRecreateCollection );
}
Expand All @@ -66,7 +66,7 @@ private PreCollectionRecreateEvent newPreCollectionRecreateEvent() {
}

private void postRecreate() {
getFastSessionServices()
getEventListenerGroups()
.eventListenerGroup_POST_COLLECTION_RECREATE
.fireLazyEventOnEachListener( this::newPostCollectionRecreateEvent, PostCollectionRecreateEventListener::onPostRecreateCollection );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public void execute() throws HibernateException {
}

private void preRemove() {
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_REMOVE
getEventListenerGroups()
.eventListenerGroup_PRE_COLLECTION_REMOVE
.fireLazyEventOnEachListener( this::newPreCollectionRemoveEvent,
PreCollectionRemoveEventListener::onPreRemoveCollection );
}
Expand All @@ -115,7 +116,8 @@ private PreCollectionRemoveEvent newPreCollectionRemoveEvent() {
}

private void postRemove() {
getFastSessionServices().eventListenerGroup_POST_COLLECTION_REMOVE
getEventListenerGroups()
.eventListenerGroup_POST_COLLECTION_REMOVE
.fireLazyEventOnEachListener( this::newPostCollectionRemoveEvent,
PostCollectionRemoveEventListener::onPostRemoveCollection );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public void execute() throws HibernateException {
}

private void preUpdate() {
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_UPDATE
getEventListenerGroups()
.eventListenerGroup_PRE_COLLECTION_UPDATE
.fireLazyEventOnEachListener( this::newPreCollectionUpdateEvent,
PreCollectionUpdateEventListener::onPreUpdateCollection );
}
Expand All @@ -132,7 +133,8 @@ private PreCollectionUpdateEvent newPreCollectionUpdateEvent() {
}

private void postUpdate() {
getFastSessionServices().eventListenerGroup_POST_COLLECTION_UPDATE
getEventListenerGroups()
.eventListenerGroup_POST_COLLECTION_UPDATE
.fireLazyEventOnEachListener( this::newPostCollectionUpdateEvent,
PostCollectionUpdateEventListener::onPostUpdateCollection );
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private ReactiveActionQueue actionQueue(EventSource session) {

/**
* Coordinates the processing necessary to get things ready for executions
* as db calls by preping the session caches and moving the appropriate
* as db calls by prepping the session caches and moving the appropriate
* entities and collections to their respective execution queues.
*
* @param event The flush event.
Expand Down Expand Up @@ -139,9 +139,8 @@ protected void logFlushResults(FlushEvent event) {
session.getActionQueue().numberOfCollectionRemovals(),
persistenceContext.getCollectionEntriesSize()
);
new EntityPrinter( session.getFactory() ).toString(
persistenceContext.getEntityHoldersByKey().entrySet()
);
new EntityPrinter( session.getFactory() )
.logEntities( persistenceContext.getEntityHoldersByKey().entrySet() );
}

/**
Expand Down Expand Up @@ -227,7 +226,7 @@ private int flushEntities(final FlushEvent event, final PersistenceContext persi
final EventSource source = event.getSession();
final Iterable<FlushEntityEventListener> flushListeners =
source.getFactory()
.getFastSessionServices()
.getEventListenerGroups()
.eventListenerGroup_FLUSH_ENTITY
.listeners();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.hibernate.TransientObjectException;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.classic.Lifecycle;
import org.hibernate.engine.internal.CascadePoint;
import org.hibernate.engine.internal.Nullability;
import org.hibernate.engine.spi.EntityEntry;
Expand All @@ -22,13 +21,13 @@
import org.hibernate.engine.spi.Status;
import org.hibernate.event.internal.OnUpdateVisitor;
import org.hibernate.event.internal.PostDeleteEventListenerStandardImpl;
import org.hibernate.event.service.spi.EventListenerGroups;
import org.hibernate.event.service.spi.JpaBootstrapSensitive;
import org.hibernate.event.spi.DeleteContext;
import org.hibernate.event.spi.DeleteEvent;
import org.hibernate.event.spi.DeleteEventListener;
import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.EmptyInterceptor;
import org.hibernate.internal.FastSessionServices;
import org.hibernate.jpa.event.spi.CallbackRegistry;
import org.hibernate.jpa.event.spi.CallbackRegistryConsumer;
import org.hibernate.jpa.event.spi.CallbackType;
Expand Down Expand Up @@ -205,17 +204,6 @@ private CompletionStage<Void> fetchAndDelete(DeleteEvent event, DeleteContext tr

}

protected boolean invokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister) {
if ( persister.implementsLifecycle() ) {
LOG.debug( "Calling onDelete()" );
if ( ( (Lifecycle) entity ).onDelete( session ) ) {
LOG.debug( "Deletion vetoed by onDelete()" );
return true;
}
}
return false;
}

private CompletionStage<Void> deleteTransientInstance(DeleteEvent event, DeleteContext transientEntities, Object entity) {
LOG.trace( "Entity was not persistent in delete processing" );

Expand Down Expand Up @@ -291,31 +279,27 @@ private CompletionStage<Void> delete(
Object version,
EntityEntry entry) {
callbackRegistry.preRemove( entity );
if ( !invokeDeleteLifecycle( source, entity, persister ) ) {
return deleteEntity(
source,
entity,
entry,
event.isCascadeDeleteEnabled(),
event.isOrphanRemovalBeforeUpdates(),
persister,
transientEntities
)
.thenAccept( v -> {
if ( source.getFactory().getSessionFactoryOptions().isIdentifierRollbackEnabled() ) {
persister.resetIdentifier( entity, id, version, source );
}
} );
}
return voidFuture();
return deleteEntity(
source,
entity,
entry,
event.isCascadeDeleteEnabled(),
event.isOrphanRemovalBeforeUpdates(),
persister,
transientEntities
)
.thenAccept( v -> {
if ( source.getFactory().getSessionFactoryOptions().isIdentifierRollbackEnabled() ) {
persister.resetIdentifier( entity, id, version, source );
}
} );
}

/**
* Can we delete the row represented by the proxy without loading the entity?
*/
private boolean canBeDeletedWithoutLoading(EventSource source, EntityPersister persister) {
return source.getInterceptor() == EmptyInterceptor.INSTANCE
&& !persister.implementsLifecycle()
&& !persister.hasSubclasses() //TODO: should be unnecessary, using EntityPersister.getSubclassPropertyTypeClosure(), etc
&& !persister.hasCascadeDelete()
&& !persister.hasNaturalIdentifier()
Expand All @@ -325,7 +309,7 @@ private boolean canBeDeletedWithoutLoading(EventSource source, EntityPersister p
}

private static boolean hasCustomEventListeners(EventSource source) {
final FastSessionServices fss = source.getFactory().getFastSessionServices();
final EventListenerGroups fss = source.getFactory().getEventListenerGroups();
// Bean Validation adds a PRE_DELETE listener
// and Envers adds a POST_DELETE listener
return fss.eventListenerGroup_PRE_DELETE.count() > 0
Expand Down
Loading
Loading