-
Notifications
You must be signed in to change notification settings - Fork 24
Tools
aadrian edited this page Nov 30, 2017
·
7 revisions
With Mirage-SQL Tools you can generate Entity Classes for Java, Groovy or XML out of a DB schema using com.miragesql.miragesql.tools.EntityGen#getEntitySource()
(also called database reverse engineering).
// setup
EntityGen gen = new EntityGen();
gen.setPackageName("com.mycorp.myapp.entity");
gen.setNameConverter(new DefaultNameConverter());
gen.setDialect(new StandardDialect());
// generate
String source = gen.getEntitySource(conn, "BOOK", null, null, "java");
// setup
def gen = new EntityGen()
gen.setPackageName("com.mycorp.myapp.entity")
gen.setNameConverter(new DefaultNameConverter())
gen.setDialect(new StandardDialect())
// generate
def source = gen.getEntitySource(conn, "BOOK", null, null, "groovy")
Groovy Entity generation:
The entity generation tool is also available as an Ant task.
<project name="Mirage EntityGen" basedir="." default="gen_entity">
<target name="gen_entity">
<path id="class.path">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="entityGen"
classname="com.miragesql.miragesql.tools.EntityGenTask"
classpathref="class.path" />
<entityGen
driver="org.hsqldb.jdbc.JDBCDriver"
url="jdbc:hsqldb:mem:mirage_test"
user="sa"
password="" />
</target>
</project>