1

This REALLY should be documented by the JetBrains folks but I figured out how to stop that eternal import wait. In IntelliJ, you set up a datasource in the Database view. You have added persistence.xml to a module and now want to use the JPA plugin functionality to generate an entity class, probably on a rather large table you do not want to write the class for by hand. You are in the Persistence view, right-click on your module name, choose Generate Persistence Mapping > By Database Schema, and the nice dialog opens. You choose your data source, a package to add the generated class file(s) to, all is fine. Next you click the Refresh icon and you wait for eternity. It should not be this hard. You probably kill IJ a couple times before giving up and wishing you had become an accountant like your mother told you to do. Fortunately there is a fix for this. Keep reading.

IJ version: 2016.3.1 Ultimate

Matt Campbell
  • 1,967
  • 1
  • 22
  • 34
  • What is the database type? Please try latest version from https://www.jetbrains.com/idea/download it has improvements in Database introspection. – Andrey Feb 17 '18 at 03:42
  • @Andrey Database is DB2. I don't think the db type is an issue. It's more to do with just plain selecting the right value for that drop-down box to keep IJ from trying to bring it loads of info from the db that it really doesn't need. – Matt Campbell Feb 17 '18 at 07:19

1 Answers1

0

Assuming you have quit out of IJ/killed it in the Task Manager and now have it restarted. Open the Database tab at the side and pick your datasource. Right-click and choose Properties. Click the Options tab. Now locate "Load sources for" at the bottom of the list of database schemas and select "None". By default, it's "Except system schemas". Click Apply, then OK. Now go back to your Persistence view and do your thing. When you click the Refresh icon, voila, the list of tables in the database will appear. Check one or more to generate persistence class files for and you're off and running.

Matt Campbell
  • 1,967
  • 1
  • 22
  • 34