also, you have to realize that annotation gives you the advantage to get away from XML (config files).
Good points/response, Chris. Also the @PersistenceContext 'annotations' may be more portable. using openejb config files may not be portable, if you try to migrate away from tomee/openejb, or if you ever have a requirement that includes tomee/openejb and other containers. On Thu, Feb 27, 2014 at 7:25 AM, Chris Christo <[email protected]> wrote: > If you have defined only one persistence unit in your config then openejb > will inject that into any bare @PersistenceContext annotations so you don't > need to be explicit by specifying the unit name with the annotation. If you > have multiple defined units in your config, then you must add the (unitName > ="movie-unit") to the annotation. > > > > On 27 Feb 2014, at 08:42, mauro2java2011 <[email protected]> wrote: > > > i know that for inject a EntityManager i have to write: > > > > > > @PersistenceContext(unitName = "movie-unit") > > private EntityManager entityManager; > > > > But from examples i have also found a different use: > > > > @PersistenceContex > > private EntityManager entityManager; > > > > when it is possible use it? > > > > > > > > > > -- > > View this message in context: > http://openejb.979440.n4.nabble.com/when-use-the-inject-EntityManager-without-specify-the-unitname-tp4668006.html > > Sent from the OpenEJB User mailing list archive at Nabble.com. > >
