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

Query on entity with embeddable record fails with "A reference class must be provided #2245

Open
Riva-Tholoor-Philip opened this issue Aug 22, 2024 · 0 comments

Comments

@Riva-Tholoor-Philip
Copy link
Contributor

After the fix for #2214 went in, entities with an embeddable record fail further along when trying to query for the entity. EclipseLink fails with A reference class must be provided/

Entity:

 <entity class="test.jakarta.data.web.Participant">
  <table name="WLPParticipant"/>
  <attributes>
   <id name="id">
   </id>
   <embedded name="name">
   </embedded>
  </attributes>
 </entity>

Class for entity and embeddable record:

public class Participant {

    public Integer id;

    public Name name;

    public static record Name(String first, String last) {
    }

    public static Participant of(String firstName, String lastName, int id) {
        Participant p = new Participant();
        p.id = id;
        p.name = new Name(firstName, lastName);
        return p;
    }
}

JPQL:

SELECT o FROM Participant o WHERE (o.name.last=?1) ORDER BY o.name.first, o.id
[8/21/24, 13:16:26:979 CDT] 00000070 id=00000000 eclipselink.ps.sql                                           3 SELECT ID, NAMEFIRST, NAMELAST FROM WLPParticipant WHERE (NAMELAST = ?) ORDER BY NAMEFIRST, ID
	bind => [1 parameter bound]
[8/21/24, 13:16:26:980 CDT] 00000070 id=00000000 eclipselink.ps.connection                                    3 Connection released to connection pool [read].
[8/21/24, 13:16:26:983 CDT] 00000070 id=00000000 eclipselink.ps                                               3 CWWKD0291W: Exception [EclipseLink-6029] (Eclipse Persistence Services - 5.0.0.v202408200932-f556522e743c87b8097f78cefe2b8f24f68cf79e): org.eclipse.persistence.exceptions.QueryException
Exception Description: A reference class must be provided.
Query: ReadObjectQuery()
[8/21/24, 13:16:26:983 CDT] 00000070 id=00000000 eclipselink.ps                                               3 throwable 
                                                                                                               Local Exception Stack: 
Exception [EclipseLink-6029] (Eclipse Persistence Services - 5.0.0.v202408200932-f556522e743c87b8097f78cefe2b8f24f68cf79e): org.eclipse.persistence.exceptions.QueryException
Exception Description: A reference class must be provided.
Query: ReadObjectQuery()
	at org.eclipse.persistence.exceptions.QueryException.referenceClassMissing(QueryException.java:1072)
	at org.eclipse.persistence.queries.ReadObjectQuery.checkDescriptor(ReadObjectQuery.java:237)
	at org.eclipse.persistence.internal.sessions.IsolatedClientSession.isIsolatedQuery(IsolatedClientSession.java:74)
	at org.eclipse.persistence.internal.sessions.IsolatedClientSession.shouldExecuteLocally(IsolatedClientSession.java:63)
	at org.eclipse.persistence.internal.sessions.IsolatedClientSession.getExecutionSession(IsolatedClientSession.java:142)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.getExecutionSession(UnitOfWorkImpl.java:2199)
	at org.eclipse.persistence.queries.DatabaseQuery.getExecutionSession(DatabaseQuery.java:1396)
	at org.eclipse.persistence.mappings.DatabaseMapping.valueFromRow(DatabaseMapping.java:1889)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildNewRecordInstance(ObjectBuilder.java:776)
	at org.eclipse.persistence.mappings.AggregateObjectMapping.buildAggregateFromRow(AggregateObjectMapping.java:475)
	at org.eclipse.persistence.mappings.AggregateObjectMapping.buildCloneFromRow(AggregateObjectMapping.java:804)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:2165)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:2418)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:1012)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInternal(ObjectBuilder.java:898)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:853)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:831)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:924)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:987)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:598)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1297)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:934)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1256)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:485)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1344)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3015)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1848)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1830)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1795)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:263)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:480)
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

No branches or pull requests

1 participant