Hello,
Currently only the javaee.jar file is available from glassfish. There are plans, however, to generate a separate bundle specifically for the persistence module which will contain the required java.persistence classes. I expect there to be an announcement on the Glassfish project pages when this is completed.
The toplink-essentials-agent.jar is used to provide transparent lazy 1-1, m-1 support at runtime. Without using the javaagent option all 1-1 and m-1 will be eagerly loaded.
Given the restrictions on the usage of the EMF defined in the specification (an application server is only allowed to create a single EMF for any PU, EMF.close closes allocated EMs) an application server would be required to maintain a reference to the EMF and use it on subsequent calls.
--Gordon
-----Original Message-----
From: Marcel Overdijk [mailto:marceloverdijk_at_hotmail.com]
Sent: Monday, April 17, 2006 6:52 AM
To: persistence_at_glassfish.dev.java.net
Subject: Some question regarding JPA
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