[
https://issues.apache.org/jira/browse/OPENJPA-2985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107001#comment-18107001
]
ASF subversion and git services commented on OPENJPA-2985:
----------------------------------------------------------
Commit 674fe11d36ed0eddb41821815f55e5e50cf08283 in openjpa's branch
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=674fe11d3 ]
[OPENJPA-2985] Implement EntityManager.createQuery(TypedQueryReference)
EntityManagerImpl.createQuery(TypedQueryReference<T>) no longer throws
UnsupportedOperationException. It now:
- calls assertNotCloseInvoked() first, so a closed EntityManager yields
IllegalStateException;
- rejects a null reference (and a null reference name) with
IllegalArgumentException;
- delegates to createNamedQuery(name, resultType) so the named query
metadata (query string, hints, flush mode, max results, lock mode) is
applied and the reference's result type becomes the query result class;
an unknown query name propagates as ArgumentException, which extends
IllegalArgumentException, matching the createNamedQuery contract;
- applies the hints carried by the reference afterwards, so they take
precedence over hints declared on the @NamedQuery itself; failures there
go through translateException like the rest of the named query path.
A null result type falls back to createNamedQuery(name) defensively.
Tested by the new TestTypedQueryReference in
org.apache.openjpa.persistence.query, which covers query creation and
execution from a reference, the applied result class, reference hints
surviving in getHints(), positional parameters of the named query, null
reference, unknown query name and a closed EntityManager. All seven cases
failed against the previous UnsupportedOperationException.
> Mandatory JPA 3.2 methods throw UnsupportedOperationException
> -------------------------------------------------------------
>
> Key: OPENJPA-2985
> URL: https://issues.apache.org/jira/browse/OPENJPA-2985
> Project: OpenJPA
> Issue Type: Sub-task
> Reporter: Maxim Solodovnik
> Priority: Major
>
> Discussion thread:
> https://github.com/apache/openjpa/pull/144#discussion_r3683005795
> **(low)** `getNamedQueries(Class)` still throws
> UnsupportedOperationException, as do
> `EntityManagerImpl.createQuery(TypedQueryReference)`
> (EntityManagerImpl.java:2779) and `find(EntityGraph, Object, FindOption...)`
> (EntityManagerImpl.java:2645). These are mandatory JPA 3.2 API - planned
> before merge, or tracked in a follow-up JIRA? Worth referencing the issue in
> the exception message.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)