Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to propograte entity manager in JBoss?

 
avihai marchiano
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic