You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ablevine1 <ab...@gmail.com> on 2015/04/21 00:11:02 UTC

Re: Hibernate with restlet

I see this post is from about a year ago and have not been able to find any
other information regarding updates on this kind of use case.  Does anyone
know if there are any new capabilities or plans to add them that would allow
a webservice to pull data via the jpa component?  

It would be really great to be able to support full CRUD operations using
only the REST DSL and JPA.  Currently it is easy to support POST/CREATE via
code like the following:
<post type="com.bn.model.User" id="createUser">
   <to uri="jpa://com.bn.model.User" />
</post>

however, it does not appear work for RETRIEVE/GET operations like
<get uri="/list" outType="com.bn.model.User[]">
    <to uri="jpa:com.bn.model.User?consumer.query=from com.bn.model.User"/>
</get>

OR 

<get uri="/{id}" outType="com.bn.model.User">
    <to uri="jpa:com.bn.model.User?consumer.query=from com.bn.model.User u
where u.id = ${header.id}"/>
</get>


To work around it you either need to use the jdbc component, as mentioned,
which does not allow you to map to POJOs or alternatively, to use a bean
that then does the data access.
Should I make a feature request for this functionality, or is something
along these lines potentially already in the works?



--
View this message in context: http://camel.465427.n5.nabble.com/Hibernate-with-restlet-tp5734306p5766083.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Hibernate with restlet

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah sure we love contributions
http://camel.apache.org/contributing.html

On Mon, Apr 27, 2015 at 12:35 AM, ablevine1 <ab...@gmail.com> wrote:
> Thank you Claus. The SQL component works great for my use case, although I
> can see where there would a few minor drawbacks to using it versus updating
> the JPA component to work in a similar fashion (Perhaps something I could
> contribute to if I get the time).
>
> 1. In my use case, my database fields are not named the same as the fields
> in my bean, which requires me to always select all of the fields and use
> "select x as y" statements to rename the queried values so that they match
> the name of the setters on my POJO.  This adds slightly more room for error
> as you have to do this for every query for the given entity.  If JPA was
> being used the column name mapping would be done only once when annotating
> the entity POJO.
>
> 2.  If I want to have my queried entity have a relation to other objects
> that are also loaded in the query things will get more complex.  E.g, a User
> has a collection of Address objects and I want to return User object
> containing that Address collection. That could get pretty tricky to do with
> the sql-component (I'm not sure whether or not its supported) whereas JPA
> would handle that mapping for you.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Hibernate-with-restlet-tp5734306p5766357.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Hibernate with restlet

Posted by ablevine1 <ab...@gmail.com>.
Thank you Claus. The SQL component works great for my use case, although I
can see where there would a few minor drawbacks to using it versus updating
the JPA component to work in a similar fashion (Perhaps something I could
contribute to if I get the time).

1. In my use case, my database fields are not named the same as the fields
in my bean, which requires me to always select all of the fields and use
"select x as y" statements to rename the queried values so that they match
the name of the setters on my POJO.  This adds slightly more room for error
as you have to do this for every query for the given entity.  If JPA was
being used the column name mapping would be done only once when annotating
the entity POJO.

2.  If I want to have my queried entity have a relation to other objects
that are also loaded in the query things will get more complex.  E.g, a User
has a collection of Address objects and I want to return User object
containing that Address collection. That could get pretty tricky to do with
the sql-component (I'm not sure whether or not its supported) whereas JPA
would handle that mapping for you.



--
View this message in context: http://camel.465427.n5.nabble.com/Hibernate-with-restlet-tp5734306p5766357.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Hibernate with restlet

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Have you tried the sql component it can map to objects also
http://camel.apache.org/sql-component

On Tue, Apr 21, 2015 at 12:11 AM, ablevine1 <ab...@gmail.com> wrote:
> I see this post is from about a year ago and have not been able to find any
> other information regarding updates on this kind of use case.  Does anyone
> know if there are any new capabilities or plans to add them that would allow
> a webservice to pull data via the jpa component?
>
> It would be really great to be able to support full CRUD operations using
> only the REST DSL and JPA.  Currently it is easy to support POST/CREATE via
> code like the following:
> <post type="com.bn.model.User" id="createUser">
>    <to uri="jpa://com.bn.model.User" />
> </post>
>
> however, it does not appear work for RETRIEVE/GET operations like
> <get uri="/list" outType="com.bn.model.User[]">
>     <to uri="jpa:com.bn.model.User?consumer.query=from com.bn.model.User"/>
> </get>
>
> OR
>
> <get uri="/{id}" outType="com.bn.model.User">
>     <to uri="jpa:com.bn.model.User?consumer.query=from com.bn.model.User u
> where u.id = ${header.id}"/>
> </get>
>
>
> To work around it you either need to use the jdbc component, as mentioned,
> which does not allow you to map to POJOs or alternatively, to use a bean
> that then does the data access.
> Should I make a feature request for this functionality, or is something
> along these lines potentially already in the works?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Hibernate-with-restlet-tp5734306p5766083.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/