Overview
Span | ||
---|---|---|
| ||
|
Div |
---|
Shows use of |
@PersistenceContext to have an EntityManager with an EXTENDED persistence context injected into a |
@Stateful bean. An EJB 3 @Entity bean is used with the EntityManager to create, persist and merge data to a database. If you need to use a TRANSACTION persistence context, see this example. The source for this example is in the "injection-of-entitymanager" directory located in the openejb-examples.zip available on the download page. |
Div | ||
---|---|---|
| ||
The Code
The Stateful bean
...
Wiki Markup |
---|
{snippet:id=code|url=openejb3/examples/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java|lang=java} |
Curious on the InitialContext parameters used? See the Injection of DataSource Example for an explanation of how any Resource can be configured via properties in the TestCase itself or via an openejb.xml file.
Running
Running the example is fairly simple. In the "injection-of-entitymanager" directory of the examples zip, just run:
...