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" #29460

Open
njr-11 opened this issue Aug 21, 2024 · 1 comment
Labels
bug This bug is not present in a released version of Open Liberty in:JPA team:Blizzard

Comments

@njr-11
Copy link
Contributor

njr-11 commented Aug 21, 2024

After the fix for #29117 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="Participant"/>
  <attributes>
   <id name="id">
   </id>
   <embedded name="name">
    <attribute-override name="first">
     <column name="NAME_FIRST"/>
    </attribute-override>
    <attribute-override name="last">
     <column name="NAME_LAST"/>
    </attribute-override>
   </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)
	at jakarta.persistence.TypedQuery.getResultStream(TypedQuery.java:93)
	at io.openliberty.data.internal.persistence.RepositoryImpl.invoke(RepositoryImpl.java:1153)
	at jdk.proxy14/jdk.proxy14.$Proxy60.withSurname(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:109)
	at test.jakarta.data.web.Participants$496247257$Proxy$_$$_WeldClientProxy.withSurname(Unknown Source)
	at test.jakarta.data.web.DataTestServlet.testRecordAsEmbeddable(DataTestServlet.java:3879)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at componenttest.app.FATServlet.doGet(FATServlet.java:74)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:633)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:723)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1266)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:754)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:451)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1362)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1078)
	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:77)
	at com.ibm.ws.webcontainer40.servlet.CacheServletWrapper40.handleRequest(CacheServletWrapper40.java:87)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:978)
	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:293)
	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1260)
	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:476)
	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:435)
	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:569)
	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:503)
	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:363)
	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:330)
	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:169)
	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:77)
	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:516)
	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:586)
	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:970)
	at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1059)
	at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:298)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
@Riva-Tholoor-Philip
Copy link
Contributor

See the eclipselink issue: 2245

anija-anil added a commit to anija-anil/open-liberty that referenced this issue Oct 15, 2024
anija-anil added a commit to anija-anil/open-liberty that referenced this issue Oct 16, 2024
anija-anil added a commit that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This bug is not present in a released version of Open Liberty in:JPA team:Blizzard
Projects
None yet
Development

No branches or pull requests

2 participants