Skip to end of metadata
Go to start of metadata

In IntelliJ, go to Tools, Data Sources

 

 

 

Click the Plus button and add a DB Data Source

 

 

Type in a name for the data source. Under JDBC Driver Files, select the Oracle driver. Under JDBC Driver Class, select the sun.jdbc.odbc.JdbcOdbcDriver

 

Click on “Click here to download the following files” link.

Select the lib directory of your IntelliJ installation, and click OK.

 

Wait for the download to finish:

 

 

 

Click Test Connection:

 

 

Click OK

 

Go back to the connection properties by going to tools, data sources. Right click on the data source, select “Data Source Properties”:

 

 

 

Select the “Schemas & Tables” tab. Look for the schema that your project uses, and select it:

 

 

Click Refresh Tables:

 

 

 

Go to the Console tab:

Select the Default SQL Dialect to be Oracle:

 

 

Click OK.

 

In the Data Sources window, you should see the schema tables:

 

 

Go to the Project Structure:

 

 

Under Modules, select the JPA module.

Under “Data Sources Mapping”, click the <none> entry in the “data source” column, and select the data source:

 

 

Under the Default JPA Provider, select Hibernate:

 

Click OK

 

Go to Window -> Tool Windows -> Persistence :

 

 

Or simply click the Persistence tab on the bottom left area of IntelliJ:

 

In the Persistence window, click once on the schema name, and then on the “QL” icon, which will open the Query Console:

 

 

Select Hibernate Console:

 

 

 

In the Hibernate Console, enter the query, as you would have it in the orm.xml file, and click the Execute Query green play button:

 

 

You should see the result of the query which you’ve just ran:

 

 

Labels: