-->
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.  [ 9 posts ] 
Author Message
 Post subject: middlegen with hibernate 3
PostPosted: Mon Aug 08, 2005 7:24 pm 
Newbie

Joined: Wed May 25, 2005 11:32 am
Posts: 14
Does anyone know how to use middlegen to generate hbm file reference hibernate 3 dtd.

in http://www.hibernate.org/98.thml, I found following statement:

"The Hibernate plugin generates the XML mapping document for Hibernate 2 only (This can be easily changed with additional templates). "

Does anyone know how to use additional templates?


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 7:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The CVS version can generate H3 mappings. Use a version="3.0" attribute in the Ant script for the middlegen hibernate sub task.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 7:58 pm 
Newbie

Joined: Wed Aug 31, 2005 7:49 pm
Posts: 3
Location: Moss Landing, CA
I've tried mapping using the H3 mappings in middlegen. It works fine except I'm unable to get my many-to-many mappings to work. When I try to run middlegen with references to many2many tables I get the following exception:
Code:

java.lang.NullPointerException
     at middlegen.plugins.hibernate.HibernateRelationshipRole.init(HibernateRelationshipRole.java:259)
    at middlegen.Plugin.decorateAll(Plugin.java:387)
     at middlegen.Middlegen.decorateAll(Middlegen.java:312)
    at middlegen.MiddlegenTask.execute(MiddlegenTask.java:406)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
     at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
     at org.apache.tools.ant.Main.startAnt(Main.java:188)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)


My ant task looks like:
Code:
<target name="classgen" description="Generate Java classes from database schema">
    <middlegen
        appname="somedatabase"
        prefsdir="doc/middlegen"
        gui="true"
        databaseurl="jdbc:jtds:sqlserver://someserver:1433/SOMEDB"
        driver="net.sourceforge.jtds.jdbcx.JtdsDataSource"
        username="A_USER"
        password="secretpassword"
        schema="dbo"
        catalog="SOMEDB">
      <!-- Optionally declare table elements -->
      <table name="EventDataStream" />
      <table name="EventDetectionParams" />
      <table name="FrameEventSet" />
      <table name="EventObject" />
      <table name="BoundingBox" />
      <table name="SourceMetadata" />
      <table name="Classifier" />
      <table name="TrainingSet" />
      <table name="ClassImageSet" />
      <table name="ValidationResults" />
      <table name="Image" />
      <table name="EventDataStream_Classifier" generate="false" />
      <table name="TrainingSet_ClassImageSet" generate="false" />
      <table name="ValidationResults_ClassImageSet" generate="false" />
      <table name="ClassImageSet_Image" generate="false" />
      <!-- Optionally declare many2many elements -->
      <many2many>
        <tablea name="EventDataStream"/>
        <jointable name="EventDataStream_Classifier" generate="false"/>
        <tableb name="Classifier"/>
      </many2many>
      <many2many>
        <tablea name="TrainingSet"/>
        <jointable name="TrainingSet_ClassImageSet" generate="false"/>
        <tableb name="ClassImageSet"/>
      </many2many>
      <many2many>
        <tablea name="ValidationResults"/>
        <jointable name="ValidationResults_ClassImageSet" generate="false"/>
        <tableb name="ClassImageSet"/>
      </many2many>
      <many2many>
        <tablea name="ClassImageSet"/>
        <jointable name="ClassImageSet_Image" generate="false"/>
        <tableb name="Image"/>
      </many2many>
      <!-- One or more plugins -->
      <hibernate
          version="3.0"
          destination="${src.java}"
          package="${project}.hibernate"
          javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper" />
    </middlegen>
  </target>


If I remove the lines:
Code:
<table name="EventDataStream_Classifier" generate="false" />
<table name="TrainingSet_ClassImageSet" generate="false" />
<table name="ValidationResults_ClassImageSet" generate="false" />
<table name="ClassImageSet_Image" generate="false" />

Then it runs fine, except of course, I don't get my many-to-many mappings.

Any suggestions?

Thanks
Brian


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 6:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hmmmmm..... I'll have to give it a try.
Did it work if you don't use the table tag at all so it picks up all tables?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 6:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Also, what if you did not have generate="false" on that set of table tags?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 8:14 pm 
Newbie

Joined: Wed Aug 31, 2005 7:49 pm
Posts: 3
Location: Moss Landing, CA
I'll try out your suggestions in the morning and see what happens.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 11:37 am 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
Did this work?

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 3:18 pm 
Newbie

Joined: Wed Aug 31, 2005 7:49 pm
Posts: 3
Location: Moss Landing, CA
david wrote:
Hmmmmm..... I'll have to give it a try.
Did it work if you don't use the table tag at all so it picks up all tables?


david wrote:
Also, what if you did not have generate="false" on that set of table tags?



Nope...In both cases, I get the following error:
Code:
No <table> elements specified. Reading all tables. This might take a while...
java.lang.NullPointerException
     at middlegen.plugins.hibernate.HibernateRelationshipRole.init(HibernateRelationshipRole.java:259)
     at middlegen.Plugin.decorateAll(Plugin.java:387)
     at middlegen.Middlegen.decorateAll(Middlegen.java:312)
     at middlegen.MiddlegenTask.execute(MiddlegenTask.java:406)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
     at org.apache.tools.ant.Task.perform(Task.java:364)
     at org.apache.tools.ant.Target.execute(Target.java:341)
     at org.apache.tools.ant.Target.performTasks(Target.java:369)
     at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
     at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
     at org.apache.tools.ant.Main.runBuild(Main.java:673)
     at org.apache.tools.ant.Main.startAnt(Main.java:188)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 7:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If you have the time to send me a small DDL script for the tables I will see if I can find the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.