Search code examples
javasqlhibernateintellij-ideajetbrains-ide

Auto create POJO class from database in IntelliJ


Is there any function in IntelliJ that allows me to generate simple POJO class from database tables (currently using PSQL)? I saw some similar example in Eclipse using "hbm2java".


Solution

  • Yes, it's possible to generate simple POJOs from Database Tables in IntelliJ.

    Just follow this instruction:

    1. Connect your database to IntelliJ.
    2. Right click the tables you want to generate your POJOs for
    3. Right Click on your selection --> Scripted Extensions --> Generate POJOs.groovy
    4. Select where to save your POJO classes
    5. Press OK and your POJO files will be created.

    Hope this helps. - Tested on IntelliJ 2019.1