I have hbm files that were generated by middlegen. I then setup to run hbm2java, however, I always get a java null pointer exception.
Here is my ant task for hbm2java
<target name="hbm2java">
<property name="hbm.dir" location="${src.home}/com/sys/dao/"/>
<replaceregexp
match='cascade="none"'
replace='cascade="all"'
byline="true">
<fileset dir="${hbm.dir}" includes="Rxhistry.hbm.xml" />
</replaceregexp>
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>
<hbm2java output="${src.home}/com/sys/dao/src/" classpathref="lib.class.path">
<fileset dir="${src.home}/com/sys/dao/">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
Here is my hbm file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.sys.dao.RxhistryBean"
table="RXHISTRY"
schema="RX2000"
mutable="false"
>
<composite-id name="rxHistoryKey" class="com.sys.dao.RxHistoryComposite">
<key-property
name="rxnumber"
column="RXNUMBER"
type="java.lang.Integer"
length="8"/>
<key-property
name="rxrefill"
column="RXREFILL"
type="java.lang.Integer"
length="2"/>
</composite-id>
<property
name="clientid"
column="CLIENTID"
type="java.lang.String"
length="16"
/>
<property
name="subscnum"
column="SUBSCNUM"
type="java.lang.String"
length="9"
/>
<property
name="person#"
column="PERSON#"
type="java.lang.String"
length="2"
/>
<property
name="subscnam"
column="SUBSCNAM"
type="java.lang.String"
length="24"
/>
<property
name="oaogroup"
column="OAOGROUP"
type="java.lang.String"
length="6"
/>
<property
name="oaosbgrp"
column="OAOSBGRP"
type="java.lang.String"
length="3"
/>
<property
name="plancode"
column="PLANCODE"
type="java.lang.String"
length="3"
/>
<property
name="plantype"
column="PLANTYPE"
type="java.lang.String"
length="1"
/>
<property
name="mbrname"
column="MBRNAME"
type="java.lang.String"
length="24"
/>
<property
name="mbradd1"
column="MBRADD1"
type="java.lang.String"
length="24"
/>
<property
name="mbradd2"
column="MBRADD2"
type="java.lang.String"
length="24"
/>
<property
name="mbrcity"
column="MBRCITY"
type="java.lang.String"
length="15"
/>
<property
name="mbrstate"
column="MBRSTATE"
type="java.lang.String"
length="2"
/>
<property
name="mbrzip5"
column="MBRZIP5"
type="java.lang.String"
length="5"
/>
<property
name="mbrzip4"
column="MBRZIP4"
type="java.lang.String"
length="4"
/>
<property
name="mbrphone"
column="MBRPHONE"
type="java.lang.String"
length="10"
/>
<property
name="brdcopay"
column="BRDCOPAY"
type="java.lang.Double"
length="5"
/>
<property
name="brdawp"
column="BRDAWP"
type="java.lang.Double"
length="3"
/>
<property
name="gencopay"
column="GENCOPAY"
type="java.lang.Double"
length="5"
/>
<property
name="genawp"
column="GENAWP"
type="java.lang.Double"
length="3"
/>
<property
name="nformcop"
column="NFORMCOP"
type="java.lang.Double"
length="5"
/>
<property
name="nformawp"
column="NFORMAWP"
type="java.lang.Double"
length="3"
/>
<property
name="brdcap"
column="BRDCAP"
type="java.lang.Double"
length="5"
/>
<property
name="capdurtn"
column="CAPDURTN"
type="java.lang.Integer"
length="2"
/>
<property
name="capawp"
column="CAPAWP"
type="java.lang.Double"
length="3"
/>
<property
name="sex"
column="SEX"
type="java.lang.String"
length="1"
/>
<property
name="dob"
column="DOB"
type="java.lang.Integer"
length="8"
/>
<property
name="rxbenfit"
column="RXBENFIT"
type="java.lang.String"
length="1"
/>
<property
name="storenum"
column="STORENUM"
type="java.lang.Integer"
length="2"
/>
<property
name="storedea"
column="STOREDEA"
type="java.lang.String"
length="10"
/>
<property
name="storfill"
column="STORFILL"
type="java.lang.Integer"
length="2"
/>
<property
name="mailordr"
column="MAILORDR"
type="java.lang.String"
length="1"
/>
<property
name="drugname"
column="DRUGNAME"
type="java.lang.String"
length="30"
/>
<property
name="genprdid"
column="GENPRDID"
type="java.lang.String"
length="14"
/>
<property
name="formulry"
column="FORMULRY"
type="java.lang.String"
length="1"
/>
<property
name="rxrfllft"
column="RXRFLLFT"
type="java.lang.Integer"
length="2"
/>
<property
name="rxrfltot"
column="RXRFLTOT"
type="java.lang.Integer"
length="2"
/>
<property
name="rxsupply"
column="RXSUPPLY"
type="java.lang.Integer"
length="3"
/>
<property
name="rxqty"
column="RXQTY"
type="java.lang.Integer"
length="5"
/>
<property
name="rxqtylft"
column="RXQTYLFT"
type="java.lang.Integer"
length="5"
/>
<property
name="rxprofit"
column="RXPROFIT"
type="java.lang.Double"
length="7"
/>
<property
name="rxtotawp"
column="RXTOTAWP"
type="java.lang.Double"
length="9"
/>
<property
name="discount"
column="DISCOUNT"
type="java.lang.Double"
length="5"
/>
<property
name="costawp"
column="COSTAWP"
type="java.lang.Double"
length="7"
/>
<property
name="feemrkup"
column="FEEMRKUP"
type="java.lang.Double"
length="7"
/>
<property
name="copaynet"
column="COPAYNET"
type="java.lang.Double"
length="9"
/>
<property
name="priceovr"
column="PRICEOVR"
type="java.lang.Double"
length="7"
/>
<property
name="ndcnumbr"
column="NDCNUMBR"
type="java.lang.String"
length="11"
/>
<property
name="sigcode"
column="SIGCODE"
type="java.lang.String"
length="12"
/>
<property
name="sigtxt1"
column="SIGTXT1"
type="java.lang.String"
length="30"
/>
<property
name="sigtxt2"
column="SIGTXT2"
type="java.lang.String"
length="30"
/>
<property
name="sigtxt3"
column="SIGTXT3"
type="java.lang.String"
length="30"
/>
<property
name="doctorid"
column="DOCTORID"
type="java.lang.String"
length="6"
/>
<property
name="doctrdea"
column="DOCTRDEA"
type="java.lang.String"
length="10"
/>
<property
name="doctname"
column="DOCTNAME"
type="java.lang.String"
length="30"
/>
<property
name="docphone"
column="DOCPHONE"
type="java.lang.String"
length="10"
/>
<property
name="partprov"
column="PARTPROV"
type="java.lang.String"
length="1"
/>
<property
name="refphyid"
column="REFPHYID"
type="java.lang.String"
length="3"
/>
<property
name="dawcode"
column="DAWCODE"
type="java.lang.Integer"
length="1"
/>
<property
name="filldate"
column="FILLDATE"
type="java.sql.Date"
length="26"
/>
<property
name="scrptdat"
column="SCRPTDAT"
type="java.sql.Date"
length="10"
/>
<property
name="exprdate"
column="EXPRDATE"
type="java.sql.Date"
length="10"
/>
<property
name="costtype"
column="COSTTYPE"
type="java.lang.String"
length="1"
/>
<property
name="generic"
column="GENERIC"
type="java.lang.String"
length="1"
/>
<property
name="ddicode"
column="DDICODE"
type="java.lang.Integer"
length="3"
/>
<property
name="ddisvrty"
column="DDISVRTY"
type="java.lang.String"
length="1"
/>
<property
name="histdate"
column="HISTDATE"
type="java.sql.Timestamp"
length="26"
/>
<property
name="workstid"
column="WORKSTID"
type="java.lang.String"
length="10"
/>
<property
name="phrminit"
column="PHRMINIT"
type="java.lang.String"
length="3"
/>
<property
name="techinit"
column="TECHINIT"
type="java.lang.String"
length="3"
/>
<property
name="therclss"
column="THERCLSS"
type="java.lang.String"
length="6"
/>
<property
name="procmpny"
column="PROCMPNY"
type="java.lang.String"
length="1"
/>
<property
name="compound"
column="COMPOUND"
type="java.lang.String"
length="1"
/>
<property
name="authno"
column="AUTHNO"
type="java.lang.String"
length="9"
/>
<property
name="cancelrx"
column="CANCELRX"
type="java.sql.Date"
length="10"
/>
<property
name="reported"
column="REPORTED"
type="java.lang.String"
length="1"
/>
<property
name="bfitcode"
column="BFITCODE"
type="java.lang.String"
length="2"
/>
<property
name="applycap"
column="APPLYCAP"
type="java.lang.String"
length="1"
/>
<property
name="drugxdat"
column="DRUGXDAT"
type="java.sql.Date"
length="10"
/>
<property
name="pos"
column="POS"
type="java.lang.String"
length="1"
/>
<property
name="vhn"
column="VHN"
type="java.lang.String"
length="1"
/>
<property
name="covered"
column="COVERED"
type="java.lang.String"
length="1"
/>
<property
name="drugawp"
column="DRUGAWP"
type="java.lang.Double"
length="8"
/>
<property
name="drugaqc"
column="DRUGAQC"
type="java.lang.Double"
length="8"
/>
<property
name="drugmac"
column="DRUGMAC"
type="java.lang.Double"
length="8"
/>
<property
name="drugeac"
column="DRUGEAC"
type="java.lang.Double"
length="8"
/>
<property
name="doseinit"
column="DOSEINIT"
type="java.lang.String"
length="3"
/>
<property
name="totalqty"
column="TOTALQTY"
type="java.lang.Integer"
length="10"
/>
<property
name="currnqty"
column="CURRNQTY"
type="java.lang.Integer"
length="10"
/>
<property
name="awpinit"
column="AWPINIT"
type="java.lang.String"
length="3"
/>
<property
name="ordreason"
column="ORDREASON"
type="java.lang.String"
length="50"
/>
<property
name="loctype"
column="LOCTYPE"
type="java.lang.String"
length="1"
/>
<property
name="prcexccd"
column="PRCEXCCD"
type="java.lang.String"
length="10"
/>
<property
name="earlyfil"
column="EARLYFIL"
type="java.lang.String"
length="1"
/>
<!-- Associations -->
</class>
</hibernate-mapping>
The one problem I had with middlegen was that the table I was importing (rxhistry) is from an existing database schema that I have no ability to change. The table did not have a primary key defined, however it did have a unique field that I can use as a primary key. When I ran middlegen I could not see how to change this, so, I let it create the hbm file (composit-id and all) and I manually changed it to the above (just did a search / replace).
When I run hbm2java here is the error I see.
Buildfile: C:\eclipse\workspace\memberlookup\WEB-INF\build.xml
hbm2java:
[hbm2java] Processing 8 mapping files.
[hbm2java] log4j:WARN No appenders could be found for logger (net.sf.hibernate.util.DTDEntityResolver).
[hbm2java] log4j:WARN Please initialize the log4j system properly.
[hbm2java] java.lang.NullPointerException
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.initWith(ClassMapping.java:89)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.<init>(ClassMapping.java:82)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.initWith(ClassMapping.java:152)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.<init>(ClassMapping.java:77)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.handleClass(CodeGenerator.java:138)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:112)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:93)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:341)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hbm2java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:379)
[hbm2java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
BUILD SUCCESSFUL
Total time: 4 seconds
Any ideas? I have tried many different configurations for ant, but always get this error.
Thanks!