JPA Structure panel is responsible for everything related to DB configurations. To create a new DB connection, click on the "Plus" button and choose "DB Connection". To use Reverse Engineering and Database Versioning features, the first thing you will need to do is create a database connection.
For now, JPA Buddy supports the following databases:
JPA Buddy offers a convenient way to automatically detect data source configurations from the *.properties file and fills in the required connection settings for you.
To use this feature, simply click on the "Detect Connections" button in the JPA Structure tab, and JPA Buddy will automatically populate the corresponding fields.
Starting from version 2023.2, JPA Buddy seamlessly integrates with IntelliJ IDEA Ultimate's robust options for data source configurations. For more information, refer to the relevant JetBrains documentation page.
JPA Buddy provides a similar mechanism for the IntelliJ IDEA Community edition.
It’s worth noting that JPA Buddy is compatible with any property file that adheres to the standard naming convention for property files. This includes YAML files, environment-specific properties files, test-specific properties files, and more. E.g.: 'application.properties', 'application-test.properties', 'application.yaml', 'application-prod.yaml', etc.
Additionally, JPA Buddy can help you generate *.properties files based on your data source configuration. This feature will save you time and effort in configuring your application.
To do so, open the relevant property file, then access the "Generate" menu by pressing Alt+Insert/⌘+N. Select the "Data source" option from the menu.
This will open the Data Source window, as shown in the screenshot below.
From the Data Source window, select the appropriate data source for your application. You can choose the DDL auto mode you need in the drop-down menu below.
Additionally, there are two other options available in the Data Source window: 'Show SQL' and 'Format SQL'. These options allow you to choose whether to show SQL statements that are executed by Hibernate on your standard output for debugging purposes and whether to format those statements for readability, respectively.
Once you have selected the data source and any other options you need, JPA Buddy will fill in the selected property file with the necessary configuration for you.
Some RDBMSs that JPA Buddy supports provide the possibility to create non-default schemas, but not all of them work well with JDBC. That's why you may encounter some known issues when generating diffs or reverse engineering. For now, these issues can only be solved with some workaround. Below are examples of connecting to non-default schemas for all databases supported by JPA Buddy.
The default PostgreSQL schema is "public". For other schemes you need to specify desired schema name in the Connection params field via "currentSchema" parameter:
The default Microsoft SQL Server schema is "dbo". To connect to the non-default scheme in Microsoft SQL Server, you should follow the steps described below:
Create a login:
create login JohnDoe with password='saPassword1'
Create a user with a default schema from which you want to create an entity:
create user JohnDoe for login JohnDoe with default_schema = my_schema
Give it owner rights:
exec sp_addrolemember 'db_owner', 'JohnDoe'
Create a new connection with the newly created user’s credentials and add a schema name in the database URL field
For JDBC the connection setup will look like this:
And for JTDS like this:
In Oracle, schema, user and database are the same thing. Hence, to connect to the non-default scheme you need to specify its schema name in the user field.
For the connection via SID setup will look like this:
And for the connection via service name like this:
To connect to the non-default scheme you need to specify the schema name in the Database URL field:
Since IntelliJ IDEA CE doesn't allow configuring database drives, JPA Buddy is to the rescue! Open Tools -> JPA Buddy -> Database Drivers window. Here you can configure drivers for each supported RDBMS by selecting one of the proposed driver versions and adding additional files from your local machine.