persistence@glassfish.java.net

Some question regarding JPA

From: Marcel Overdijk <marceloverdijk_at_hotmail.com>
Date: Mon, 17 Apr 2006 10:52:01 +0000

Hi,

I'm adding JPA support to a framework and have some questions.
Currently I'm using the Toplink Essentials and javaee.jar from GlassFish M6.

1. The javaee.jar contains more then only the persistence related classes
and therefor is 1mb big. Is there a official Sun jar downloadable containing
only persistence classes. In Spring 2.0 distribution a persistence.jar
(58kb) is included. I can use this but I don't know the origin of it.

2. In the persistence example on the GlassFish page the
toplinks-essentials-agent.jar is used in combination with -javaagent (SE
example). What does the toplink-essentials-agent do? If I just put
toplink-essentials and javaee.jar on the classpath everything seems to work
fine. Is there any drawback?

3. When I want to get an EntityManager based on an persistence unit Name I
don't know at compile time. The only option (I believe) is to create an emf
first:
String pu = "some dynamic pu name";
Persistence.createEntityManagerFactory(pu);
However to create a emf each time is expensive. I could keep a reference to
a pu once created.
But what I'm wondering is how JEE 5 containers handle this. Do they create
subsequent emf's or are they smart that they know it was already created in
a previous call?

Hope you can hekp me on this.

Regards,
Marcel Overdijk