deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Roytman <roytm...@gmail.com>
Subject Re: Transactional with extended EntityManager is not working?
Date Mon, 18 Jan 2016 02:09:03 GMT
Hello Gerhard,

thank you for the reference. I've read it but my problem is right here as
 described in this article:

As you see the usage is the same. You *do not* have to use
ExtendedEntityManager at the injection point. It is just needed in the
producer-method:

I do need to use not only my own implementation of EntityManager but also
my own interface extending EntityManager and when II use it, transactional
interceptor does not seem to recognize it

the reason I need to extend EntityManager interface is that I need to
access few of my own methods on it and when injecting it I can't get to
them in the implementation class via field injected as EntityManager (it is
proxied and only recognizes interface methods and of course there is not
way to typecast it)

To give you some background on what I am trying to do:

I need to gradually transition an application written a while ago using JDO
as persistence. It is a pretty sophisticated domain model, several modules
with lots of logic baked into it. We do not want to rewrite it at the
moment but we want too take advantage of @Transactional semantic and also
 wrap it into entity manager so we can do access as much of JDO
functionality via EntityManager as possible (pretty much majority can be
done but for queries) as a way to gradually move to JPA and eventually
remove JDO (sad - it was a great spec with some excellent commercial
implementations still superior to JPA but unfortunatelly killed and dead)

Anyway, I would like to extent EntityManager interface with one method
getJdo() while implementing as many EntityManager method to delegate to
wrapped JDO PersistenceManager instance. I need getJdo() because we can't
quite wrap all JDO functionality and need access to the underlying
EntityManager's JDO PersistenceManager instance.

Everything works fine except that if I inject

@Inject private EntityManager entityManager;

into my bean I can't get to getJdo()

if I inject it as

@Inject private JdoEntityManager entityManager;

@Transactional stops working

Thanks,
Alex


On Sun, Jan 17, 2016 at 6:07 PM Gerhard Petracek <gerhard.petracek@gmail.com>
wrote:

> hi alex,
>
> please have a look at [1].
>
> regards,
> gerhard
>
> [1]
>
> http://deltaspike.apache.org/documentation/jpa.html#ExtendedPersistenceContexts
>
>
>
> 2016-01-17 23:44 GMT+01:00 Alex Roytman <roytmana@gmail.com>:
>
> > It looks like of a bean is injected with a field of type not
> EntityManager
> > but an interface extending it, transactional annotation does not work. Is
> > there any way to have transactional to recognize interfaces that extend
> > from EntityManager
> >
> > Thanks
> > Alex
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message