Webcam Chat QuickBooks Advice international calling cards international phone cards
JavaBeat Java Books Certifications Certifications Kits Articles Tutorials Tips QNA Book Store Interview Questions SCJP 1.5 SCJP 1.6 SCWCD 5.0 SCBCD 5.0 SCEA SCJA Feeds

How to use Middlegen?

Topic :
Feedback Request New QnA Print Email

Middlegen provides an Ant task from which to initiate the code generation for the target platforms. The task can include more than a single target, eg, Hibernate and EJB target. The following task is configured for the Hibernate plugin only.

<!-- ============================================================== -->
<!-- Run Middlegen -->
<!-- ============================================================== -->

<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
>
<mkdir dir="${build.gen-src.dir}"/>
<echo message="Class path = ${basedir}"/>

<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>

<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
>

<!-- Plugins -->
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>

</middlegen>
<mkdir dir="${build.classes.dir}"/>
</target>

The majority of the task options involves setting up the data source. Fine-tuning of the generation process is provide primarily through a Java Swing based GUI. This is activated when the gui option in the Middlegen Ant task is true. Middlegen has a sample application that can provide a guide for your own project adoption of Middlegen.

Middlgen by default creates Hibernate 2.x mapping files. Middlgen 2.2 introduced the option of creating Hibernate 3.0 mapping files by using the version element. For example;

  ....

<!-- Plugins -->
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
version="3.0"
/>

...

Note: hibernate tools package has vastly improved and is worth considering as an alternative for hibernate 3.x features.

Topic :
Feedback Request New QnA Print Email

All api java java 6.0 java 7.0 jdbc jsp servlet ejb jndi jms ejb 3.0 j2ee jee 5.0 jee 6.0 jsf struts spring Hibernate ajax JBoss Seam netbeans eclipse ant xml maven dojo junit javafx j2me log4j ESB JBoss Apache Quartz scjp mysql oracle gwt openjpa jmx yui google-guice android JBoss scwcd 5.0 scjp 1.5 scjp 1.6 scja scbcd 5.0

JavaBeat Website (2004-2011), India
javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2011), JavaBeat


Technology Blogs
Technology blogs Technology Blogs
blog log