Generating OFX database schema using hyperjaxb
There is a great project at java.net called hyperjaxb (and hyperjaxb2 and hyperjaxb3). It provides JAXB objects with a relational persistence layer, in other words, you can generate database schema right from your XML schema definitions. In the last few days, I tested generating database schema for OFX 2.1.1. The process was not so straightforward, but the following worked in my machine: Download and use hyperjaxb2 (full version). Create a build script. Basically, the whole magic is in two custom ant tasks:
<xjc target="${dir.generated}" schema="${dir.schema.ofx}${file.separator}OFX3_Protocol.xsd" package="${ofx.package.name}" removeOldOutput="yes" extension="true">
<depends dir="${dir.schema.ofx}" includes="*.xsd" />
<produces dir="${dir.generated}" />
<arg line="-Xhyperjaxb2" />
<!--
<arg line="-Xhyperjaxb3" />
//-->
</xjc>
<taskdef name="export.schema" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="classpath.xjc" />
<export.schema properties="hibernate.properties" quiet="no" text="yes" drop="no" delimiter=";" output="${basedir}/sql/schema.sql">
<fileset dir="${dir.generated}${file.separator}${ofx.package.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</export.schema>
I've omitted property definitions, which are obvious. The generated schema file needs some adjustment, but for a large schema, hyperjaxb would save you months of hard work. So far, I had no luck running the whole build process using hyperjaxb3. Hyperjaxb3 is version 0.1.0, so there are some issues... Anyway, I'm looking forward to a stable release (right now, you can get Hyperjaxb3 out of CVS and build yourself). Hyperjaxb3 supports JAXB 2.0, which generates much cleaner code than JAXB 1.X. There are issues to resolve, but hyperjaxb seems to be under active development and the results are promising. More on the development process can be found at lexicore.blogspot.com .
2 Comments:
Hi, I am also studying and using hyperjaxb2/3 now. As you said, hyperjaxb3 has some problems, it seems can't parse the xjb file, which is supported in hyperjaxb2. Do you meet this problem?
BTW, the development of hyperjaxb3 has been suspended for several monthos. I am just afraid whether it will continue.
The development is quite active, BTW.
The task is quite large so we're not doing releases too often, but the project is very active.
Post a Comment
<< Home