Testing standalone Java Persistence bundle

Yes, I tried it, and it works :)

1. Download the latest bundle from the https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html page and install it following the instructions. The bundle will be unpacked to ./glassfish-persistence directory.

2. Download the Java SE example from the example page: https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html and unzip it. There are rumors that the link to the zip files does not work, but I couldn't reproduce the problem on Solaris or Windows.

3. Copy classes/META-INF/persistence.xml.template to classes/META-INF/persistence.xml and set your database and driver properties. Create the tables using sql/tables_oracle.sql or modify it for your database

4. Change location to classes directory, and execute the test:
java -cp [driver-location]:. -javaagent:[install-location]/glassfish-persistence/toplink-essentials-agent.jar client.Client

You should see the expected output:

Inserting Customer and Orders... OK
Verifying that all are inserted... OK
Removing all... OK
Verifying that all are removed... OK

Notes:
i) toplink-essentials.jar is automatically added to the classpath by the manifest in the agent jar.
ii) All javax.persistence API and xml schemas are part of the toplink-essentials.jar, which means that you don't need any other jar in the classpath for the compilation.
iii) You can skip the -javaagent call if your environment doesn't allow to plug in the agent - the only side effect is loading all relationship as EAGER.

Comments:

Hi Marina, I have downloaded your source code, install and add 2 JPA jar files to Library Manager in Netbeans and run it. However, the below error has been thrown: Exception in thread "main" java.lang.NullPointerException at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60) at client.Client.main(Client.java:45) The line no 45 points to emf = Persistence.createEntityManagerFactory("pu1"); // Persist all entities createTransactionalEntityManager(); Could you kindly tell me how I can solve it? Thanks Dinh

Posted by pcdinh on July 03, 2006 at 06:04 PM PDT #

Hi Dinh, Please check that Netbeans classpath doesn't contain an older version of the JPA libraries, that are bundled with the IDE. thanks, -marina

Posted by guest on July 10, 2006 at 05:42 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

Marina Vatkina

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Blogroll
Related Links