File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes How to propograte entity manager in JBoss? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "How to propograte entity manager in JBoss?" Watch "How to propograte entity manager in JBoss?" New topic
Author

How to propograte entity manager in JBoss?

avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
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

Joined: Feb 05, 2001
Posts: 16624

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
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

Joined: Feb 05, 2001
Posts: 16624

I believe you will find in the JPA spec that currentSession is basically built into JPA.

Mark
avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
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
 
IntelliJ Java IDE
 
subject: How to propograte entity manager in JBoss?
 
Threads others viewed
Use transaction with add/update and delete?
Need a little help with EJB, jBoss and Hibernate
Persistence Context Question
Entity manager in Hibernate
Resource Local Transactions
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture