-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Middlegen & hbm2java problems/questions
PostPosted: Wed Oct 15, 2003 4:59 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 8:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The Mapping document looks fine. There is an Ant task that can validate the XML against the DTD. The error is a class path problem so I would be double checking your environment. You can execute hbm2java from the command prompt so that Ant issues are removed. Once it works you can then move forward working out the Ant script and associated class paths.

Middlegen allows you to change the settings in the GUI and it will remember those settings hence you would do it only once. Now you could do one table and look at the preferences file and update (using vi, sed or some other tool) all the other key types for all the tables. Alternatively, some of the settings can be setup from the Ant script itself as it follows the Ant sub-task model. If you look at the code the Primary entry point for the plugin will indicate what can and cannot be set by default. The defaults only apply if plugin preferences does not have an existing preference value.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 8:59 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
Okay, forget the error -- it's a classpath problem. I guess I should have my hand slapped for putting a 'NoClassDefFoundError' in the forum.

David:

Quote:
Now you could do one table and look at the preferences file and update (using vi, sed or some other tool) all the other key types for all the tables.


Yes, I was thinking of that, as a last resort, but I was hoping for something more elegant.

Quote:
Alternatively, some of the settings can be setup from the Ant script itself as it follows the Ant sub-task model. If you look at the code the Primary entry point for the plugin will indicate what can and cannot be set by default.


Okay, I think I've found the source on Middlegen's site (the new one on codehaus). I'll have a look there.


Maury...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.