You have:
Created the entities
Configured the DataSource and data source alias of your application
If you are using the system DataSource, you must have defined a data source alias only.
The data model of a JPA application typically consists of several related entity classes, which have to be mapped together to one and the same database. These entity classes form a logical unit, which is called a “persistence unit” . Within a JPA application, you have to define the persistence unit by the persistence.xml configuration file. It is possible to list the entities explicitly that form the persistence unit. If you do not do so, the JPA implementation scans the application for entities and detects them automatically.
The name of the persistence unit specified in the persistence-unit tag can be chosen arbitrarily.
Due to the specifics of the Dali JPA Tools project, we recommend that you define only one persistence unit within the persistence.xml file.
The persistence.xml is also the configuration file where you can use tags to define any global settings for the persistence unit. This is, for example, jta-data-source , which is the name of the DataSource that is used to connect to the database.
If you do not specify the jta-data-source tag explicitly, a vendor-specific default is used. In AS Java, the preconfigured default name is SAP/JPA_DEFAULT , which is a DataSource alias that maps to the System DataSource.
You can also add other configuration elements to the persistence.xml file, such as transaction-type , provider , non-jta-data-source , mapping-file , jar-file , class , exclude-unlisted-classes , and so on. The only mandatory element is the name property of the persistence-unit tag, which the SAP NetWeaver Developer Studio includes in the file automatically.
For a complete listing of elements and their semantics, refer to the JPA specification at http://java.sun.com .
In the Developer Studio, the persistence.xml file is located under the META-INF directory of the JPA project or another project with JPA support enabled.
The following is an example of how the basic persistence.xml code and the persistence unit definition look like:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="JPAModel"> <jta-data-source>MY_DATA_SOURCE</jta-data-source> <properties> <property name="com.sap.jpa.versioning.generator.tablename" value="TMP_VERSION_GEN"> <property name="com.sap.jpa.versioning.generator.allocation-size" value="1000"> </properties> <class>com.sap.demo.package</class> </persistence-unit> </persistence>