users@glassfish.java.net

Re: Specification question related to overriding annotations

From: <glassfish_at_javadesktop.org>
Date: Wed, 19 Mar 2008 08:25:57 PST

OK, since none of the permutations work, I'm going to settle on one that I'd like to [i]get[/i] working. What I mean is, I [i]could[/i] change the @PersistenceContext annotation to have an explicit name attribute, but I'm not going to.

So I'm going to hold constant the fact that my AbstractStatelessSessionBean will look, in part, like this:
[code]package foo.bar;

public abstract class AbstractStatelessSessionBean {
  @PersistenceContext protected EntityManager entityManager;
}[/code]

Having made that change, I pack it into its normal plain-jane jar file:[code]abstract-beans.jar[/code].

My concrete EJB is just a straight extension:
[code]package biz.baw;

public class FrobnicatorBean extends foo.bar.AbstractStatelessSessionBean {

}[/code]

Next, I edit his ejb-jar.xml file to read, in part:
[code]<persistence-context-ref>
  <description>Persistence context for Frobnicator.</description>
  <persistence-context-ref-name>foo.bar.AbstractStatelessSessionBean/entityManager</persistence-context-ref-name>
  <persistence-unit-name>MyPersistenceUnit</persistence-unit-name>
</persistence-context-ref>[/code]

I pack it into its own EJB jar file:
[code]frobnicator-ejb.jar[/code]

I make an ear with, among other things a persistence.xml file that defines the MyPersistenceUnit persistence unit. The ear's structure looks like this, in part:
[code]frobnicator-ejb.jar
lib/abstract-beans.jar[/code]

So, then, that's the scenario I'd like to get working; i.e. I'd only like to edit XML files.

Thanks as always for your time and help.

Best,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=264810