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

Left Join Fetch on Embeddable ElementColection fails & NamedQuery with QueryHints.REFRESH fails to execute #1465

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jGauravGupta
Copy link
Member

@jGauravGupta jGauravGupta commented Apr 1, 2022

Fixes issue 1:
JPA Left Join Fetch on Embeddable ElementColection fails
#858

Fixes issue 2:
When defining a NamedQuery that has EclipseLink hints, the query fails with an exception

Exception [EclipseLink-7081] (Eclipse Persistence Services - 2.7.6.payara-p1): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The aggregate object [class be.rubus.payara.support.ticket1455.model.Tag] cannot be directly registered in the UnitOfWork.  It must be associated with the source (owner) object.
	at org.eclipse.persistence.exceptions.ValidationException.cannotRegisterAggregateObjectInUnitOfWork(ValidationException.java:622)

The offending NamedQuery, org.eclipse.persistence.config.QueryHints

@NamedQuery(
        name = "getAllBlogPosts_fail",
        query = "SELECT i FROM BlogPost i",
        hints = {
                @QueryHint(
                        name = QueryHints.REFRESH,
                        value = HintValues.TRUE
                ),
                @QueryHint(
                        name = QueryHints.LEFT_FETCH,
                        value = "i.tags"
                )
        }
)

Sample test app:
fish-406.zip

Pandrex247 and others added 3 commits April 1, 2022 11:36
Signed-off-by: Gaurav Gupta <gaurav.gupta@payara.fish>
Signed-off-by: Gaurav Gupta <gaurav.gupta@payara.fish>
…tions in UnitOfWork

Signed-off-by: Jonathan Coustick <jonathan.coustick@payara.fish>
Copy link
Member

@lukasj lukasj left a comment

Choose a reason for hiding this comment

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

Needs a test, reliance on NPE being thrown is not an acceptable solution.

try {
mapping.preInitialize(session);
} catch (NullPointerException npe) {
// A NPE gets thrown if the expected method is not present for the mapping

Choose a reason for hiding this comment

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

Should be fixed at the origin of failure.

@@ -3021,7 +3021,7 @@ public Object internalRegisterObject(Object object, ClassDescriptor descriptor,
return null;
}
if (descriptor.isDescriptorTypeAggregate()) {
throw ValidationException.cannotRegisterAggregateObjectInUnitOfWork(object.getClass());
return null;

Choose a reason for hiding this comment

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

Can you elaborate why this is fixing the issue? Technically I see you are stopping the exception from being thrown, of course. Is this a try-and-error fix, or some deeper understanding? To me it seems the method should not have been called in the first place for those aggregates.

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.

None yet

5 participants