You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by DRy <di...@itellium.com> on 2009/10/29 19:43:10 UTC

JPA: How to pass parameters to namedQuery

Hi,

I defined two named-queries in my orm.xml:

<named-query name="findAll">
    <query>SELECT c FROM Customer c</query>
</named-query>
<named-query name="findByOid">
    <query>SELECT c FROM Customer c WHERE c.oid = :oid</query>
</named-query>

I can use the "findAll" named-query to consume customer-objects

       
from("jpa:com.test.entity.Customer?consumer.namedQuery=findAll&delay=10000&consumeLockEntity=true&consumeDelete=true")

but how can I pass parameter(s) to the "findByOid" named-query ... ?
:confused:

Sorry if this might be a beginner question ... :working:
-- 
View this message in context: http://www.nabble.com/JPA%3A-How-to-pass-parameters-to-namedQuery-tp26118566p26118566.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JPA: How to pass parameters to namedQuery

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 30, 2009 at 9:00 AM, DRy <di...@itellium.com> wrote:
>
> Hi,
>
>
> Claus Ibsen-2 wrote:
>>
>>
>>> from("jpa:com.test.entity.Customer?consumer.namedQuery=findAll&delay=10000&consumeLockEntity=true&consumeDelete=true")
>>
>> See the unit tests of camel-jpa, for example JpaWithNamedQueryTest
>> It could maybe inspire you.
>>
>>
>
> Sorry, but that didn't help at all ...
>
> I want to know how to pass a parameter for a namedQuery-based jpa consume in
> something like that
>
> from("jpa:com.test.entity.Customer?consumer.namedQuery=findByOid)
>
> where findByOid is defined in my orm.ml
>
> <named-query name="findByOid">
>    <query>SELECT c FROM Customer c WHERE c.oid = :oid</query>
> </named-query>
>

I dont think you can do it on the consumer side (eg in the from). Use
a fixed value or do something else.
Or create a ticket in JIRA so we can see how we can implemented this in camel.



>
> ... DRy
> --
> View this message in context: http://old.nabble.com/JPA%3A-How-to-pass-parameters-to-namedQuery-tp26118566p26126224.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JPA: How to pass parameters to namedQuery

Posted by DRy <di...@itellium.com>.
Hi,


Claus Ibsen-2 wrote:
> 
> 
>> from("jpa:com.test.entity.Customer?consumer.namedQuery=findAll&delay=10000&consumeLockEntity=true&consumeDelete=true")
> 
> See the unit tests of camel-jpa, for example JpaWithNamedQueryTest
> It could maybe inspire you.
> 
> 

Sorry, but that didn't help at all ... 

I want to know how to pass a parameter for a namedQuery-based jpa consume in
something like that 

from("jpa:com.test.entity.Customer?consumer.namedQuery=findByOid) 

where findByOid is defined in my orm.ml

<named-query name="findByOid">
    <query>SELECT c FROM Customer c WHERE c.oid = :oid</query>
</named-query> 


... DRy
-- 
View this message in context: http://old.nabble.com/JPA%3A-How-to-pass-parameters-to-namedQuery-tp26118566p26126224.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JPA: How to pass parameters to namedQuery

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Oct 29, 2009 at 7:43 PM, DRy <di...@itellium.com> wrote:
>
> Hi,
>
> I defined two named-queries in my orm.xml:
>
> <named-query name="findAll">
>    <query>SELECT c FROM Customer c</query>
> </named-query>
> <named-query name="findByOid">
>    <query>SELECT c FROM Customer c WHERE c.oid = :oid</query>
> </named-query>
>
> I can use the "findAll" named-query to consume customer-objects
>
>
> from("jpa:com.test.entity.Customer?consumer.namedQuery=findAll&delay=10000&consumeLockEntity=true&consumeDelete=true")
>
> but how can I pass parameter(s) to the "findByOid" named-query ... ?
> :confused:
>
> Sorry if this might be a beginner question ... :working:
> --

See the unit tests of camel-jpa, for example JpaWithNamedQueryTest
It could maybe inspire you.


> View this message in context: http://www.nabble.com/JPA%3A-How-to-pass-parameters-to-namedQuery-tp26118566p26118566.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus