openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Generic setParameter on createNamedQuery.query.
Date Fri, 13 Aug 2010 21:58:49 GMT
No I don't think there is a generic "JPA proper" way of doing it... but you
could cast your Query to the SPI and dig in a little bit. Just be aware that
this is a SPI so it won't be portable, it's not recommended, and be aware
that it may change.

Take a look at:
        org.apache.openjpa.persistence.OpenJPAQuerySPI s =
(OpenJPAQuerySPI)em.createNamedQuery("query");
        s.getNamedParameters()

Thanks,
Rick

On Fri, Aug 13, 2010 at 1:34 PM, Kelly Kerr <kelly.kerr@sympatico.ca> wrote:

>
> I want to pass to a generic EntityManager an Entity and the name of a
> NamedQuery. I then want to createNamedQuery using the name passed as a
> parameter. Now the problem - I need to setParameter, the parameter
> name/value would be different for each NamedQuery. Is there a way to
> dynamically determine the name of the expected parameters? Then I could use
> reflection to extract the value from the input Entity bean and supply as
> input to the setParameter.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message