users@jersey.java.net

Re: [Jersey] Jersey and JPA best practices?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 18 Dec 2008 15:45:01 +0100

On Dec 18, 2008, at 11:54 AM, Julio Faerman wrote:

> Well, i am using Jersey + JPA + Spring, so the EntityManager gets
> injected using the @PersistenceContext annotation.
> Works fine for me.
>

+1

Such best practices will also become clearer for Java EE 6. Namely you
will be able to:

1) Use session beans as resource classes; or

2) Inject stuff onto a resource classes like you can do for a Servlet.


We do have some basic form of persistence support with resource
classes to allow the injection of an EntityManagerFactory, see the
bookmark example:

http://download.java.net/maven/2/com/sun/jersey/samples/bookmark/1.0.1/bookmark-1.0.1-project.zip

but i think the Jersey + JPA + Spring is a more complete solution.

Paul.

> On Thu, Dec 18, 2008 at 7:46 AM, Florian Hars <hars_at_bik-gmbh.de>
> wrote:
>> What is the best way to use jersey with JPA?
>>
>> I found most of the necessary magic incantations (like the
>> WEB-INF/classes/META-INF/persistence.xml madness and telling
>> glassfish
>> not to throw "java.lang.AbstractMethodError:
>> org.postgresql.jdbc3.Jdbc3Connection.getClientInfo()Ljava/util/
>> Properties"
>> by setting JDBC30DataSource to true in the properties of the pool)
>> and now I
>> can ask Persistence to give me an EntityManagerFactory and it will
>> do so.
>>
>> But what is the best way to manage these ManagerFactories and their
>> assorted
>> Managers? I can't seem to find the right set of annotations to get
>> container managed persistence to work, do I have to write my own
>> EntityManagerFactoryManager?
>>
>> Any hints/tips/experiences?
>>
>> - Florian.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>