Show TOC Start of Content Area

Procedure documentation Packaging Persistent Entities  Locate the document in its SAP Library structure

Use

You use this procedure to specify how persistent entities are packaged into persistence units. A persistence unit is a logical grouping of persistent classes and holds:

      An entity manager factory and its entity managers

      The set of persistent classes managed by these entity managers

      A persistence.xml file in the META-INF directory of the root of the persistence unit that defines the unit

Persistence units may be packaged into an EJB-JAR file, the WEB-INF/classes directory of a WAR file, a JAR file in the WEB-INF/lib directory of a WAR file, a JAR file in the root of the EAR, a JAR file in the EAR library directory, and in an application client JAR file.

Caution

The JPA specification requires that persistence units have a persistence.xml. When you specify entity packaging in the SAP NetWeaver Developer Studio, you can choose if you want to create the persistence.xml. If you choose not to create it at this point, you can still create it at a later point. We recommend that you create the persistence.xml when you specify entity packaging.

Prerequisites

You have:

      Created an EJB 3.0 project

More information: Creating EJB 3.0 Projects

      Opened the Java Persistence perspective

More information: Java Persistence Perspective

Procedure

To specify entity packaging, you create a persistence.xml file.

...

       1.      Select your project in the Package Explorer.

       2.      Choose Java Persistence Add Java Persistence.

       3.      Select the Create persistence.xml checkbox.

       4.      Complete the following fields:

      Persistence provider: name of the persistence provider’s javax.persistence.spi.PersistenceProvider class.

      Persistence unit name: an arbitrary name to identify the persistence unit. This name is used in the @PersistenceContext and @PersistenceUnit annotations.

       5.      Choose Finish.

Result

The SAP NetWeaver Developer Studio creates the persistence.xml file in the META-INF directory.

End of Content Area