Generate simple classes from database objects in DataGrip


DataGrip lets you run scripts against the selected schema objects. For example, you can generate Java classes from tables or, if you want, classes in any other language: C#, Python, etc. You can alter or extend the default functionality, for instance, generate an HTML or Markdown report.

Out of the box, DataGrip can generate Java classes. To do this, go to the context menu of a table (or several tables) and press Scripted Extension → Generate POJO.groovy.


Choose a destination folder, and that’s it! The class-file is ready.


Generate POJO.groovy is just a script written in Groovy. It means that you can modify it and create a new script based on it, for example, for generating classes for other languages. From the same context menu, click on Go to scripts directory to see where this file is placed.


You can edit the existing one or create new scripts. Just place your new script into this folder, and it’ll be available from the context menu.

Some examples from our users:
Improvement of default script: comment support and replacing underscores in names.
POJO Generators for Entity
Generator of classes for Kotlin Squash
Export structure as markdown into the clipboard

Groovy is not the only language you can use, JavaScript is also available.

Before we also had Clojure engine and some people used it for scripting. For instance, here is the script for generating C# classes. If you strongly wish to use Clojure for scripting, please download Clojure runtime and scripting engine files here and place them in the lib folder inside the installed DataGrip folder.

We hope this post helps, feel free to ask questions if any.

image description