Hi there,

i am going to write my diploma thesis about an application build with
ejb3.0

I am studying now for about 3 weeks on this topic. I built a simple
database and tried to generate the 2.1 bean classes using middlegen. I
had some problems with the version from the cvs (1.2.2), porting back to
1.2.1 fixed that.
But now i am trying to get the same database running with middlegen
1.2.2, directly from cvs, and got issues with many2many relations.
First my db:

+++++++++++++++++++++++++++++++++++++++++++++++++++
-- a little soup for all

CREATE TABLE Recipe (
    Recipe_Id           integer UNIQUE Not NULL,
    Recipe_Author       varchar(30),
    Recipe_Name         varchar(40),
    Recipe_Price        float,
    CONSTRAINT PK_Recipe_Id PRIMARY KEY (Recipe_Id)
);


CREATE TABLE Cook (
    Cook_Id             integer UNIQUE Not NULL,
    Cook_Name           varchar(30),
    Cook_Prename        varchar(30),
    Cook_Address        varchar(50),
    Cook_Zip            varchar(10),
    Cook_Town           varchar(30),
    Cook_Phone          varchar(50),
    CONSTRAINT PK_Cook_Id PRIMARY KEY (Cook_Id)
);

CREATE TABLE Common_Bean (
    Common_Bean_Id       integer UNIQUE Not NUll,
    Common_Bean_Color    varchar(10),
    Common_Bean_Size     integer, 
    Common_Bean_Type     varchar(30),
    CONSTRAINT PK_Common_Bean_Id PRIMARY KEY (Common_Bean_Id)
);

CREATE TABLE Bean_Soup (
    Bean_Soup_Id         integer UNIQUE Not NULL,
    Bean_Soup_Name       varchar(30),
    Bean_Soup_CookingTime varchar(20),
    Bean_Soup_Endurance  integer,
    Bean_Soup_Recipe_Id  integer,
    CONSTRAINT PK_Bean_Soup_Id PRIMARY KEY (Bean_Soup_Id),
    CONSTRAINT FK_Bean_Soup_Recipe_id FOREIGN KEY (Bean_Soup_Recipe_Id)
        REFERENCES Recipe (Recipe_Id)
);

CREATE TABLE Bean_2_Soup (
    Bean_Soup_Id         integer Not NULL,
    Common_Bean_Id       integer Not NULL,
    CONSTRAINT PK_Bean_2_Soup PRIMARY KEY (Bean_Soup_Id,
Common_Bean_Id),
    CONSTRAINT FK_Bean_2_Soup_List_Of_The_Soups 
        FOREIGN KEY (Bean_Soup_Id) REFERENCES Bean_Soup (Bean_Soup_Id),
    CONSTRAINT FK_Bean_2_Soup_List_Of_The_Beans
        FOREIGN KEY (Common_Bean_Id) REFERENCES Common_Bean
(Common_Bean_Id)
);

CREATE TABLE Cook_2_Soup (
    Bean_Soup_Id         integer Not NULL,
    Cook_Id             integer Not NULL,
    CONSTRAINT PK_Cook_2_Soup PRIMARY KEY (Bean_Soup_Id, Cook_Id),
    CONSTRAINT FK_Cook_2_Soup_List_Of_The_Soups
        FOREIGN KEY (Bean_Soup_Id) REFERENCES Bean_Soup (Bean_Soup_Id),
    CONSTRAINT FK_Bean_2_Soup_List_Of_The_Cooks
        FOREIGN KEY (Cook_Id) REFERENCES Cook (Cook_Id)
);

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

There are two tables for the many2many realtions. One Soup can have
several beans, and one soup can have quite a bunch of cooks, if this is
helpfull for the soup... =)

Now the ant script for building the classes:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


<!DOCTYPE project [
    <!--<!ENTITY database SYSTEM "file:./config/database/hsqldb.xml">
-->
    <!ENTITY database SYSTEM "file:./config/database/postgresql.xml">
    
    <!ENTITY ejb      SYSTEM "file:./config/ejb/jboss.xml">
]>

<project name="BeanSoup EJB3.0" default="all" basedir=".">
 
   <property file="${user.home}/build.properties"/>
   <property file="${basedir}/build.properties"/>
   <property name="middlegen.home"
value="${basedir}/.."/>
   <property name="xdoclet.version" value="1.2"/>
   
   <property name="name"            value="beansoup.entity"/>
    <property name="unique.name"    value="${name}"/>
   <property name="appxml.src.file"
value="${basedir}/src/application.xml"/>
   <property name="lib.dir" value="${basedir}/lib"/>
   <property name="src.dir" value="${basedir}/src"/>
   <property name="java.src.dir"  value="${src.dir}/java"/>
   <property name="web.src.dir"  value="${src.dir}/web"/>

   <property name="build.dir" value="${basedir}/build"/>
   <property name="build.java.dir"  value="${build.dir}/java"/>
   <property name="build.gen-src.dir" value="${build.dir}/gen-src"/>
   <property name="build.classes.dir"  value="${build.dir}/classes"/>
   <property name="persistencelayer.plugin"  value="cmp30"/>

   &database;
   &ejb;
   
   <property name="datasource.jndi.name"
value="${name}/datasource"/>

   <path id="lib.class.path">
      <pathelement path="${basedir}"/>
      <pathelement path="${database.driver.classpath}"/>
      <fileset dir="${lib.dir}">
         <include name="*.jar"/>
      </fileset>
      <!-- The middlegen jars -->
      <fileset dir="${middlegen.home}">
         <include name="*.jar"/>
      </fileset>
   </path>
   
   <target name="init">
      <available property="xdoclet1.2+"
classname="xdoclet.modules.ejb.EjbDocletTask"
classpathref="lib.class.path"/>
      <available property="xdoclet-jars-installed"
file="lib/xdoclet-${xdoclet.version}.jar"/>
   </target>

   <!-- Run Middlegen
-->
   <!--
=================================================================== -->
   <target 
      name="middlegen" 
      description="Run Middlegen" 
      depends="init,fail-if-no-xdoclet-1.2"  
      unless="middlegen.skip"
   >
      <mkdir dir="${build.gen-src.dir}"/>

      <taskdef
         name="middlegen"
         classname="middlegen.MiddlegenTask"
         classpathref="lib.class.path"
      />

      <middlegen
         appname="${name}"
         prefsdir="${src.dir}"
         gui="${gui}"
         databaseurl="${database.url}"
         initialContextFactory="${java.naming.factory.initial}"
         providerURL="${java.naming.provider.url}"
         datasourceJNDIName="${datasource.jndi.name}"
         driver="${database.driver}"
         username="${database.userid}"
         password="${database.password}"
         schema="${database.schema}"
         catalog="${database.catalog}"
         includeViews="false"
      >

         <!-- Tables for the Beansoup  -->
         <table generate="true" name="recipe"/>
         <table generate="true" name="common_bean"/>
         <table generate="true" name="bean_soup"/>
         <table generate="true" name="cook"/>
         <table generate="true" name="bean_2_soup"/>
         <table generate="true" name="cook_2_soup"/>
                
        
        
         <many2many>
                <tableb generate="true" name="bean_soup"/>
            <jointable name="bean_2_soup" generate="true"/>
                <tablea generate="true" name="common_bean"/>
         </many2many>
         
         <many2many>
            <tablea generate="true" name="bean_soup"/>
            <jointable name="cook_2_soup" generate="true"/>
            <tableb generate="true" name="cook"/>
         </many2many>
        
        <cmp30
                    destination="${build.gen-src.dir}"
                    package="${name}.ejb"
                    mergedir="${basedir}/src/middlegen"
                 >
                 </cmp30>
        <!--
         <cmp20
            destination="${build.gen-src.dir}"
            package="${name}.ejb"
            interfacepackage="${name}.interfaces"
            jndiprefix="${unique.name}"
            pkclass="false"
            dataobject="false"
            valueobject="true"
            sessionfacade="true"
            viewtype="local"
            mergedir="${basedir}/src/middlegen"
            readonly="false"
            fkcmp="true"
            guid="true"
         > 
         -->
            </middlegen>
        </target>


        <!--
=================================================================== -->
        <!-- Build everything
-->
        <!--
=================================================================== -->
        <target name="all" description="Build everything"
depends="clean,middlegen" />

        <!--
=================================================================== -->
        <!-- Clean everything
-->
        <!--
=================================================================== -->
        <target name="clean" description="Clean all generated stuff">
            <delete dir="${build.dir}" />
        </target>

        <target name="ejb-jar" description="just to prevent error
message ;-)" />

</project>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I left some target in order to retain the clarity.
ant tells me about an error: 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[middlegen] 2005-09-22 15:25:32,919 ERROR [middlegen.FileProducer]
Invocation of method 'getColumn' in  class
middlegen.plugins.entitybean.CMP30Table threw exception class
java.lang.IllegalArgumentException : There is no column named
common_bean_id in the table named bean_soup
[middlegen] org.apache.velocity.exception.MethodInvocationException:
Invocation of method 'getColumn' in  class
middlegen.plugins.entitybean.CMP30Table threw exception class
java.lang.IllegalArgumentException : There is no column named
common_bean_id in the table named bean_soup
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:291)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:218)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.java:350)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:84)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
[middlegen] at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:216)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
[middlegen] at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:216)
[middlegen] at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
[middlegen] at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
[middlegen] at
org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:358)
[middlegen] at middlegen.FileProducer.generate(FileProducer.java:328)
[middlegen] at
middlegen.FileProducer.generateForTable(FileProducer.java:246)
[middlegen] at middlegen.Plugin.doIt(Plugin.java:587)
[middlegen] at middlegen.Plugin.generate(Plugin.java:445)
[middlegen] at middlegen.Middlegen.writeSource(Middlegen.java:355)
[middlegen] at middlegen.swing.JMiddlegenFrame
$1.actionPerformed(JMiddlegenFrame.java:75)
[middlegen] at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
[middlegen] at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2169)
[middlegen] at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
[middlegen] at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
[middlegen] at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
[middlegen] at java.awt.Component.processMouseEvent(Component.java:5488)
[middlegen] at
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
[middlegen] at java.awt.Component.processEvent(Component.java:5253)
[middlegen] at java.awt.Container.processEvent(Container.java:1966)
[middlegen] at java.awt.Component.dispatchEventImpl(Component.java:3955)
[middlegen] at java.awt.Container.dispatchEventImpl(Container.java:2024)
[middlegen] at java.awt.Component.dispatchEvent(Component.java:3803)
[middlegen] at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
[middlegen] at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
[middlegen] at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
[middlegen] at java.awt.Container.dispatchEventImpl(Container.java:2010)
[middlegen] at java.awt.Window.dispatchEventImpl(Window.java:1774)
[middlegen] at java.awt.Component.dispatchEvent(Component.java:3803)
[middlegen] at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
[middlegen] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
[middlegen] at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
[middlegen] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
[middlegen] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
[middlegen] at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
[middlegen] middlegen.MiddlegenException: Invocation of method
'getColumn' in  class middlegen.plugins.entitybean.CMP30Table threw
exception class java.lang.IllegalArgumentException : There is no column
named common_bean_id in the table named bean_soup
[middlegen] at middlegen.FileProducer.generate(FileProducer.java:342)
[middlegen] at
middlegen.FileProducer.generateForTable(FileProducer.java:246)
[middlegen] at middlegen.Plugin.doIt(Plugin.java:587)
[middlegen] at middlegen.Plugin.generate(Plugin.java:445)
[middlegen] at middlegen.Middlegen.writeSource(Middlegen.java:355)
[middlegen] at middlegen.swing.JMiddlegenFrame
$1.actionPerformed(JMiddlegenFrame.java:75)
[middlegen] at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
[middlegen] at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2169)
[middlegen] at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
[middlegen] at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
[middlegen] at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
[middlegen] at java.awt.Component.processMouseEvent(Component.java:5488)
[middlegen] at
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
[middlegen] at java.awt.Component.processEvent(Component.java:5253)
[middlegen] at java.awt.Container.processEvent(Container.java:1966)
[middlegen] at java.awt.Component.dispatchEventImpl(Component.java:3955)
[middlegen] at java.awt.Container.dispatchEventImpl(Container.java:2024)
[middlegen] at java.awt.Component.dispatchEvent(Component.java:3803)
[middlegen] at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
[middlegen] at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
[middlegen] at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
[middlegen] at java.awt.Container.dispatchEventImpl(Container.java:2010)
[middlegen] at java.awt.Window.dispatchEventImpl(Window.java:1774)
[middlegen] at java.awt.Component.dispatchEvent(Component.java:3803)
[middlegen] at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
[middlegen] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
[middlegen] at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
[middlegen] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
[middlegen] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
[middlegen] at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
when i deactivate the <many2many> Elements, everything works, but the
many2many mapping in the class files are missing.
Whats wrong with it?

Thanks for your help

martin




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
middlegen-user mailing list
middlegen-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/middlegen-user

Reply via email to