Associating data sources with session factories and persistence units
- Your source code that references database tables will automatically be validated against the corresponding data source.
- When using the JPA or Hibernate console, you won't need to additionally specify the database connection settings. The corresponding settings configured for the associated DB data source will automatically be used.
If the persistence units or session factories are generated by importing a database schema, the association between the corresponding persistence units or session factories and the data source is set automatically.
To associate a data source with a persistence unit or session factory
- Open the Persistence tool window (e.g View | Tool Windows | Persistence ).
- Right-click the necessary module, persistence unit or session factory, and select Assign Data Sources in the context menu.
- In the Assign Data Sources dialog that opens, click the Data Source field and select the necessary data source. (To remove the association with the data source, select <none>.)