persistence.xml Visual Editor

Use to view the persistence units defined in persistence.xml. You open the persistence.xml Visual Editor from the Projects window by expanding the Configuration Files node and then double-clicking the persistence.xml file. You can use the visual editor to create, delete, and modify the persistence units. You can also click XML in the visual editor toolbar to access the XML view of persistence.xml.

In the persistence.xml Visual Editor, you can perform the following tasks:

Element Description

Create a persistence unit

Click Add in the top right corner of the visual editor.

Delete a persistence unit

Click Remove next to the name of the persistence unit you want to delete.

Modify a persistence unit

Click the expand icon to the left of the name of the persistence unit to display the editable properties of the persistence unit.


The visual editor displays the properties of each persistence unit in persistence.xml. Depending on your project configuration, for each persistence unit, you can modify the following properties:

Element Description

Persistence Unit Name

Each persistence unit in persistence.xml must have a unique name.

Persistence Provider or Persistence Library

The persistence provider or library determines the entity manager that is used to manage the entities scoped by the persistence unit.

Data Source or JDBC Connection

This is the JNDI name of the data source or the JDBC connection to the database.

Use Java Transaction APIs

If selected, the Java EE container manages the lifecycle of entities. If not selected, the entities are managed by the application. (If the target container is not a Java EE container, then this option is not available and the entities must be managed by the application.)

Table Generation Strategy

Select the table generation strategy for the data source.

Validation Strategy

(EclipseLink) Select the validation mode for the persistence unit (default is Auto).

Caching Type

(EclipseLink) Select a caching type to explicitly specify if entities and entity-related data is cached.

Include All Entity Classes in "<project>" Module

If selected, all entity classes in the persistence unit's root are included in the persistence unit. If not selected, only the classes listed in the Include Entity Classes textfield are included in the scope of the persistence unit.

In Java EE projects, you do not need to explicitly specify which entity classes to include in the scope, because all entity classes in the persistence unit's root are included by default.

In Java SE projects, the option to include all entity classes is not available. Instead, you need to explicitly specify which classes to include in the scope. Only the classes listed in the Include Entity Classes textfield are included.

Include Entity Classes

The textfield lists the entity classes explicitly included in the scope of the persistence unit. By default, entity classes in the persistence unit's root are included in the scope and listed in the textfield. You can remove entity classes from the scope by selecting the class name and clicking Remove.



Related Topics

Developing Applications with NetBeans IDE,

Developing Applications with NetBeans IDE,

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.