You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SaurabhNayar <Na...@gmail.com> on 2016/01/04 21:25:33 UTC

Re: entity manager is injected as null in a camel bean but jpa: endpoint works fine

Be aware of the fact that the entity manager that is getting imported is a
Spring resource and may not be present in Camel Registry.

You may have tough time joining the existing Camel transactions - if you
have transactions.

Don't know your business requirements - but better to use Camel JPA
component instead of custom JPA code.



--
View this message in context: http://camel.465427.n5.nabble.com/entity-manager-is-injected-as-null-in-a-camel-bean-but-jpa-endpoint-works-fine-tp5775308p5775768.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: entity manager is injected as null in a camel bean but jpa: endpoint works fine

Posted by amitmahesh <la...@yahoo.com>.

So effectively you are suggesting to always use jpa: uri in the camel route
for all my database access part, and to avoid injecting entity manager in a
camel bean. Means I will have to keep multiple intermediate data processing
beans in camel route to generate/consume entity beans data.



--
View this message in context: http://camel.465427.n5.nabble.com/entity-manager-is-injected-as-null-in-a-camel-bean-but-jpa-endpoint-works-fine-tp5775308p5775867.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: entity manager is injected as null in a camel bean but jpa: endpoint works fine

Posted by SaurabhNayar <Na...@gmail.com>.
The EntityManager will not automatically join the transaction by using
@Transactional annotation.

You will have to write your transaction management code - and make entity
manager participate in the transaction. Kind of beats the purpose of using
Camel - if you have to take all that pain.



--
View this message in context: http://camel.465427.n5.nabble.com/entity-manager-is-injected-as-null-in-a-camel-bean-but-jpa-endpoint-works-fine-tp5775308p5775857.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: entity manager is injected as null in a camel bean but jpa: endpoint works fine

Posted by amitmahesh <la...@yahoo.com>.

Hello Saurabh,
    Even I was worried about the transaction handling part if I inject
entity manager from Spring instead of using the jpa://  endpoint supported
by the Camel JPA component. Our developers felt that jpa:// was helpful only
for Simple CRUD operations but in our case we do a lot of complex SQL and
joins so we wanted some way to inject entity manager in some DAO where we
can write our DB specific code. Pls suggest how to use JPA Component inside
some Camel bean. Currently we were able to get a handle to entity manager
using @PersistenceContext annotation inside a bean which is called from a
camel route and all data access methods in that bean are annotated as
@Transactional.



--
View this message in context: http://camel.465427.n5.nabble.com/entity-manager-is-injected-as-null-in-a-camel-bean-but-jpa-endpoint-works-fine-tp5775308p5775783.html
Sent from the Camel - Users mailing list archive at Nabble.com.