You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by David Blevins <da...@visi.com> on 2007/12/08 09:14:26 UTC

Re: JPA Examples (was: Re: Setup tutorial?)

On Nov 24, 2007, at 6:45 PM, openejber wrote:

>
> my replies were kept blocked last couple of days....
>
> indeed, i'd like to see a JPA example below,
>
> - a non-servlet normal unit test class looking up and casting an ejb  
> bean's
> local proxy object(namely OPENEJB IntraVM mode?), which does CRUD on  
> an
> entity
> - a local ejb interface defining CRUD methods
> - a bmt-ejb bean injected with the persistence context consisting of  
> that
> entity, and the bean implementing that ejb interface
> - finally, the entity class itself

Have a new example here that shows JPA usage.  Ant and Maven build  
scripts included.

http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/injection-of-entitymanager/

It shows a Stateful bean using an EntityManager with EXTENDED  
persistence type so the entities won't detach between calls to the  
Stateful bean as they would if when using TRANSACTION (i.e. jta  
scoped) persistence.

-David


Re: JPA Examples (was: Re: Setup tutorial?)

Posted by David Blevins <da...@visi.com>.
On Dec 8, 2007, at 6:25 AM, Jacek Laskowski wrote:

> On Dec 8, 2007 9:14 AM, David Blevins <da...@visi.com> wrote:
>
>> It shows a Stateful bean using an EntityManager with EXTENDED
>> persistence type so the entities won't detach between calls to the
>> Stateful bean as they would if when using TRANSACTION (i.e. jta
>> scoped) persistence.
>
> ...or if using @Stateless. EXTENDED is applicable to @Stateful only.
> One of the reasons @Stateful's so handy.

Exactly.  Last night I added a validation JIRA on this exact thought  
too:

     [OPENEJB-730] Validation: Attempted use of  
PersistenceContextType.EXTENDED by non-Stateful bean

Currently, we aren't checking that people are trying to use EXTENDED  
with Stateless.  I tried it last night and the app totally deployed  
without a peep and just failed silently at runtime.

-David


Re: JPA Examples (was: Re: Setup tutorial?)

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Dec 8, 2007 9:14 AM, David Blevins <da...@visi.com> wrote:

> It shows a Stateful bean using an EntityManager with EXTENDED
> persistence type so the entities won't detach between calls to the
> Stateful bean as they would if when using TRANSACTION (i.e. jta
> scoped) persistence.

...or if using @Stateless. EXTENDED is applicable to @Stateful only.
One of the reasons @Stateful's so handy.

p.s. I had a EJB3 presentation on a Poznan University yesterday. It
took me over 3 hours to talk about it - lots of examples and topic
around EJB3 and JPA and I had only scratched the EJB3/JPA surface. I
had done it with Glassfish as it's nicely integrated with NetBeans IDE
6 that provides features for Java EE development beyond those I could
find in Eclipse (I'm not talking about RAD7.5 though that's around the
corner). Ok, gonna start another thread about it.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl