Friday, December 3, 2010

DB Importer

I often need to use an existing database from Java. I like JPA, so I usually want to generate JPA @Entity classes for the existing tables. There are some tools out there that does this, but they are not exactly easy to use. I tried several, and I could not get them to work in a reasonable time. (I have more important things to do than to fight a complicated tool.)

I also want to configure the import, for instance to generate @Version and @GeneratedValue annotations, to tweak the generated class names, to generate @ManyToMany relations from connection tables, etc.

So, I decided to write a tool myself. (Why spend a day getting a tool to work when you can make your own in a few weeks?)

I have already made one tool like this: HiberObjects Import DB Pro, but I realize that most programmers don't want to use UML. So, I made a similar tool but without UML.

The code generation can be configured with a Groovy script. To keep this simple, I use plain Java syntax in the script.

The tool is an Eclipse plug-in called DB Importer. It will be available in a free edition and a commercial edition. DB Importer is currently in Beta. Please try it out and let me know what you think.

No comments: