- Open Persistence tool window.
- Right-click the desired module with JPA facet, and choose
- In the New Persistent Unit dialog box, specify the name of the new persistent unit, or accept default. A
new persistence unit node is added to the module, and created in the Persistence.xml
By default, according to the JPA specification, a persistence unit in Java EE environment includes all the available annotated entities, which are displayed in the Persistence tool window. If you want a particular persistence unit to contain the entities that are unique to this unit only, in the editor add the exclude-unlisted-classes element with the value true to the source code of the persistence unit.
- Open the persistence.xml file for editing.
- Start typing the persistence-unit tag, and see code completion in action:
- Type the name of the new persistence unit. Note that the corresponding persistence unit node is immediately created in the Persistence tool window.