The abstract classes probably only support limited injection. I wouldn't recommend doing this, if you need access to EntityManager there are helper classes to implement that give you it, e.g. EntityManagerAware.
John On Tue, Dec 19, 2017 at 10:16 AM Luís Alves <[email protected]> wrote: > I have the following code: > > @Repository > public abstract class ConfigurationRepository extends > AbstractEntityRepository<Configuration, Long> implements > EntityRepository<Configuration, Long>, EntityManagerDelegate< > Configuration> > { > > > * // FIXME: why this is null?!? @Inject private > QueryInvocationContext context;* > > @Inject > private EntityManager em; > > /** > * Find by key. > * > * @param key > * the key > * @return the configuration > */ > public Configuration findByKey(String key) > { > QConfiguration c = QConfiguration.configuration; > > return new > JPAQuery<Configuration>(em).from(c).where(c.key.eq(key)). > fetchFirst(); > } > > } > > The *QueryInvocationContext*is null so I had to inject the EM directly. Any > idea why it's null or how to figure out why it's null? > > Regards, > LA >
