camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fharms <flemming.ha...@gmail.com>
Subject Re: Usage JPA in a bean with CamelJPA
Date Sat, 27 Feb 2016 10:19:24 GMT
yes that exactly what I'm talking about.

We have situations where we both use the Camel JPA, together with beans and
only JPA from beans, but we still want it to be part of the route tx.

I have solved it by doing something like this, but was unsure if this was
the proper way to do it.

EntityManager em =
jpaComponent.getEntityManagerFactory().createEntityManager();
em.joinTransaction()

//do my JPA stuff

em.close();


2016-02-27 11:08 GMT+01:00 Claus Ibsen-2 [via Camel] <
ml-node+s465427n5778350h7@n5.nabble.com>:

> Are you talking about writing some Java JPA code in a Java bean? And
> then calling that Java bean from a Camel route?
>
> Then yeah sure, then you are responsible for the JPA code, and to
> obtain the EntityManagerFactory and all that JPA stuff you must do.
> Also to call flush or whatnot so any changes are persistent to the
> database.
>
> You do not have to use Camel JPA component at all. You can just do
> this the regular JPA code way.
>
> And if you talk about a transaction, then you would need to make sure
> the TX manager works with JPA and setup all that correctly as well.
>
>
>
> On Sat, Feb 27, 2016 at 9:59 AM, fharms <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5778350&i=0>> wrote:
>
> > Hi
> >
> > I have question regarding using Camel JPA together with beans
> >
> > Is it correctly understood if I’m using JPA in a bean, but does not
> directly
> > consume or sending to an endpoint via “jpa:”,  then i’m responsible for
> > creating the entity manager because the CamelEntityManager header is
> only
> > set when the route use the JPA URI protocol?
> >
> > Will the solution be to injecting the JpaComponent in my bean, and
> create an
> > EntityManager and join the transaction, will that be a correct way or is
> > there a better way?
> >
> > Thanks!
> >
> > Cheers,
> > Flemming
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Usage-JPA-in-a-bean-with-CamelJPA-tp5778349.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Usage-JPA-in-a-bean-with-CamelJPA-tp5778349p5778350.html
> To unsubscribe from Usage JPA in a bean with CamelJPA, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5778349&code=ZmxlbW1pbmcuaGFybXNAZ21haWwuY29tfDU3NzgzNDl8MjA5MzYyNjQ3>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 

Kind regards / Med Venlig Hilsen
Flemming Harms

   -

https://twitter.com/fnharms
https://dk.linkedin.com/in/fharms




--
View this message in context: http://camel.465427.n5.nabble.com/Usage-JPA-in-a-bean-with-CamelJPA-tp5778349p5778351.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message