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

[#1504] Merge with reference fails if entity is associated to a column (non id) #1685

Closed
wants to merge 2 commits into from

Conversation

blafond
Copy link
Member

@blafond blafond commented Jun 28, 2023

fixes #1504

The two tests were failing because the Bar entity column was still a HibernateProxy object in EntityTypes methods so the identifier Bar.key value was always null.

The fixes I implemented check for the proxy and force a load via reactiveImmediateLoad()

@blafond blafond requested a review from DavideD June 28, 2023 18:39
String uniqueKeyPropertyName = entityType.getRHSUniqueKeyPropertyName();
Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName );
// We now have the value of the property-ref we reference. However,
// we need to dig a little deeper, as that property might also be
// an entity type, in which case we need to resolve its identifier
Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [EntityPersister.getPropertyType](1) should be avoided because it has been deprecated.
// We now have the value of the property-ref we reference. However,
// we need to dig a little deeper, as that property might also be
// an entity type, in which case we need to resolve its identifier
final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [EntityPersister.getPropertyType](1) should be avoided because it has been deprecated.
session
);
loadedUniqueKey = ((CompletableFuture)resultObject).get();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use a .get() because it's a blocking method.
Assuming the logic is correct (I haven't cheked yet), the code should look something like:

.thenCompose ukResult -> {
      ...
      if ( loadedUniqueKey instanceof HibernateProxy ) {
         return   loadHibernateProxyEntity( ... )
                            .thenApply(loadedUniqueKey -> { .... } );
      }  
      ... 
}

@DavideD
Copy link
Member

DavideD commented Jul 5, 2023

Thanks, looks good.

I've just decided to keep the original tests and took the opportunity to clean up a bit the code and remove some warnings in EntityTypes: #1696

@DavideD DavideD closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge with reference fails if entity is associated to a column (non id)
2 participants