I have downloaded the Tools workshop and was successful in doing a bottom-up generation (from database to POJO) using Middlegen and hbm2java.
I have now tried to repeat the same process with an Oracle database, and am running into problems attempting to generate the POJOs using hbm2java. To do this, I am using the Middlegen-Hibernate-r2 distribution. I have been able to run Middlegen and generate the .hbm.xml files, but when I attempt to run hbm2java against those files, I get the following:
Code:
Buildfile: build.xml
hbm2java:
[hbm2java] Processing 44 files.
[hbm2java] Building hibernate objects
BUILD FAILED
C:\Java\Middlegen-Hibernate-r2\build.xml:298: Caused by:
Caused by:
java.lang.NoClassDefFoundError: net/sf/hibernate/MappingException
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:303)
at org.apache.tools.ant.Task.perform(Task.java:401)
at org.apache.tools.ant.Target.execute(Target.java:338)
at org.apache.tools.ant.Target.performTasks(Target.java:365)
at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:220)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:213)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:149)
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:303)
at org.apache.tools.ant.Task.perform(Task.java:401)
at org.apache.tools.ant.Target.execute(Target.java:338)
at org.apache.tools.ant.Target.performTasks(Target.java:365)
at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:220)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:213)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
Since no .java files are generated, I'm assuming it is choking on this file (the first one in the directory, alphabetically -- maybe a bad assumption):
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="timetracker.hibernate.Address"
table="ADDRESSES"
>
<id
name="id"
type="java.math.BigDecimal"
column="ID"
>
<generator class="assigned" />
</id>
<!-- associations -->
<!-- bi-directional many-to-one association to TelephoneAddress -->
<many-to-one
name="telephoneAddress"
class="timetracker.hibernate.TelephoneAddress"
not-null="true"
>
<column name="PHONE_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to MailAddress -->
<many-to-one
name="mailAddress"
class="timetracker.hibernate.MailAddress"
not-null="true"
>
<column name="MAIL_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to EmailAddress -->
<many-to-one
name="emailAddress"
class="timetracker.hibernate.EmailAddress"
not-null="true"
>
<column name="EMAIL_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to Entity -->
<many-to-one
name="entity"
class="timetracker.hibernate.Entity"
not-null="true"
>
<column name="ENTITY_ID" />
</many-to-one>
</class>
</hibernate-mapping>
Would someone point me in the right direction to fix this?
My second question is the following: What needs to be changed to have Middlegen make different choices about the default values for things like: the primary key java data type, the primary key generator class, etc.? If we go ahead with Hibernate in our latest project, I'm not going to want to use the Middlegen gui to change the values in 300+ tables. I was sure I saw something somewhere on the web site that said how to do this, but I have been unable to locate it again.
Thanks in advance...
Maury.