Skip to content
aadrian edited this page Nov 11, 2017 · 7 revisions

Entity class generation tool

You can generate Entity Classes from DB schemas using com.miragesql.miragesql.tools.EntityGen.

// 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);

Ant task

The generation tool is also available as 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>
Clone this wiki locally