camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Update database using Java DSL JPA
Date Thu, 07 Mar 2013 15:03:35 GMT
On Tue, Mar 5, 2013 at 9:55 PM, Baalu <golivamsi84@gmail.com> wrote:
> I looked at your example and it used Camel 2.11, but we are using 2.10.3
> where we dont have a hibernate component.
>
> We are using JPA component, is there any way we can use consumer.query or
> consumer.nativequery or a namedquery on it to update the database. What is
> the best way to update one column in a route something like this:
>

I think these are only in use if you use camel-jpa in the from in a route, eg
from("jpa:....")


> from(direct:input)
> .to(create an update query)
> .to(jpa:entity)
>
> Can we use a parametrized UPDATE query somehow to specify the columns and
> values to update?
>

You can use the JPA API to do that. The idea with JPA is to abstract
the database layer and work with the objects.
So you fetch the entity using the JPA API. And then change the object
(entity) and then use the JPA API to merge / flush the changes.

Though for the latter, you can also use the Camel JPA producer, eg to in a route
.to("jpa:myEntityClassName")


PS: Sometimes working with SQL is easier.


>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Update-database-using-Java-DSL-JPA-tp5728463p5728601.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message