tags:

views:

47

answers:

1

Anyone know a tool for generating Java class with JPA annotations from an SQL script?

Batch process would be a plus since I have a large amount of sql objects.

+2  A: 

The reverse engineering tools (Hibernate Tools, OpenJPA's ReverseMappingTool, Eclipse Dali, etc) I'm aware of work against a database, not an SQL script - and this is actually what I would do: generate the schema from the script and then run the tool.

It should be pretty easy to automate this process (creating the schema, generating the entities, optionaly droping the schema) with Ant (Hibernate and OpenJPA provide an Ant task) or even a script.

If for whatever reason you can't install the target database, try with an H2 in memory database with the appropriate compatibility mode.

Pascal Thivent