• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to propograte entity manager in JBoss?

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I am working with JBoss,
I cant use injection ,so i need to create entity manager by using in factory.createEntityManager.

The issue here that i need in the same transaction (i use JTA) to share the same persistence context (entity manager).

Any suggestion will be more than welcome
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a little bit confused at what you exactly mean with

"I cant use injection ,so i need to create entity manager by using in factory.createEntityManager.

The issue here that i need in the same transaction (i use JTA) to share the same persistence context (entity manager)."

Does this mean you don't want to use injection? or that you think JBoss can't inject for you?

And then you say you need a single transaction to share the same persistence context. Kind o fconsufising, but anyway,

It might be that you are looking for an extended persistence context. If I am correct you can use the LocalThread for that or use the Open Session in view pattern here http://www.hibernate.org/43.html.

Mark
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont want to use injection because i create my schemas and factories at run time.

For that reason i need to create the entity manager via createEntityManager and dont by injection.

The issue here is that i dont want that each time i create entity manager in the same transaction i will get a different persistence context.

In hibernate you can use in "current session".

I dont want to fall down to explicity use of hibernate ,so i am looking for a solution with JPA


Thank you
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you will find in the JPA spec that currentSession is basically built into JPA.

Mark
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that is suppose to attach the current session to the transaction scope in JTA enviroment,

But when i explicity create the entity manager i have differents persistence context in the same transaction.

Is it a good solution to cast the current session to the entity manager?

Thank you
 
This is my favorite tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic