Discussion:
[Middlegen-user] many2many problem
Tanner, Brian
2003-01-30 18:20:06 UTC
Permalink
Hello, this is my first time sending to this list. I'm using middlegen
as CMP2 generator for Jboss 3.0 with a MySql database. I'm receiving a
"RelationshipRole.compareTo" error when I try to create a many to many
relationship across item, category, and category_item tables. I've
included the stack trace, my middlegen ant task, and the Sql DDL used to
gen my three tables. Can anyone help me with a workaround on this
issue?

===========
[middlegen] java.lang.IllegalStateException: RelationshipRole.compareTo
bug

[middlegen] PLEASE FILE A BUG REPORT TO
http://sourceforge.net/tracker/?group_id=36044&atid=415990.
[middlegen] ENCLOSE THE FOLLOWING INFORMATION:
[middlegen] -THIS STACK TRACE
[middlegen] -THE VERSION YOU'RE USING (DATE IF YOU'RE USING CVS VERSION)



[middlegen] at
middlegen.DbTable.addRelationshipRole(DbTable.java:328)
[middlegen] at middlegen.Relation.<init>(Relation.java:142)
[middlegen] at
middlegen.MiddlegenPopulator.addMany2ManyRelations(MiddlegenPopulator.ja
va:846)
[middlegen] at
middlegen.MiddlegenPopulator.populate(MiddlegenPopulator.java:265)
[middlegen] at
middlegen.MiddlegenTask.execute(MiddlegenTask.java:398)
[middlegen] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:166)
[middlegen] at org.apache.tools.ant.Task.perform(Task.java:319)
[middlegen] at org.apache.tools.ant.Target.execute(Target.java:309)
[middlegen] at
org.apache.tools.ant.Target.performTasks(Target.java:336)
[middlegen] at
org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[middlegen] at
org.apache.tools.ant.Project.executeTargets(Project.java:1250)
[middlegen] at org.apache.tools.ant.Main.runBuild(Main.java:610)
[middlegen] at org.apache.tools.ant.Main.start(Main.java:196)
[middlegen] at org.apache.tools.ant.Main.main(Main.java:235)

===============
CREATE TABLE category (
category_id INTEGER(12) NOT NULL,
parent_category_id INTEGER(12) ,
store_id INTEGER(8) NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY( category_id ) ) Type = InnoDB;

CREATE TABLE category_item (
category_id INTEGER(12) NOT NULL,
item_id INTEGER(12) NOT NULL,
PRIMARY KEY( category_id, item_id ) ) Type = InnoDB;

CREATE TABLE item (
item_id INTEGER(12) NOT NULL,
product_id INTEGER(12) NOT NULL,
store_id INTEGER(8) NOT NULL,
description TEXT,
PRIMARY KEY( item_id ) ) Type = InnoDB;

ALTER TABLE category_item ADD INDEX (item_id), ADD INDEX (category_id),
ADD FOREIGN KEY (item_id) REFERENCES item (item_id), ADD FOREIGN KEY
(category_id) REFERENCES category (category_id);
===============

<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}"
<!--
We can specify what tables we want EJBs generated for.
If none are specified, EJBs will be generated for all tables.
Comment out the <table> elements if you want to generate for
all tables.
Also note that table names are CASE SENSITIVE for certain
databases,
so on e.g. Oracle you should specify table names in upper case.

The sequencename attribute is optional and will be used from
the oraclesequence extension. If no sequencename is present
it will be the name attribute suffixed by _SEQ.

-->
<table name="product"/>
<table name="product_state"/>
<table name="store"/>
<table name="category"/>
<table name="item"/>

<many2many>
<tablea name="category" generate="true"/>
<jointable name="category_item" generate="false"/>
<tableb name="item" generate="true"/>
</many2many>

<cmp20
destination="${build.gen-src.dir}"
package="${name}.ejb"
interfacepackage="${name}.interfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="true"
guid="true"
<!-- Let the EJBs use The portable Sequence Block PK
generation pattern -->
<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
/>

<!-- We can use predicates to specify what columns we want
finders for -->
<!--finders>
<and>
<indexed/>
<notkey/>
</and>
</finders-->

<!--
EJB containers can be specified here. They add aditional
features and perform additional validations. You don't have
to
add them, they just provide "goodies".
-->
<jboss/>

</cmp20>

<!-- generate som read-only beans too -->
<!--cmp20
name="cmp20_ro"
destination="${build.gen-src.dir}"
package="${name}.ejb"
interfacepackage="${name}.interfaces"
jndiprefix="${unique.name}"
generatepk="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="true"
fkcmp="true"
suffix="RO"
<jboss/>
</cmp20-->

<html destination="${build.html.dir}">
<!--
We can override the plugin's templates
by specifying the id of the original template
and providing a new one from the file system.

Uncomment the line below to see it in action.
(This technique can be used for all plugins).
-->
<!--fileproducer
id="single-table"
template="${basedir}/src/templates/single-table.vm"
/-->
</html>

<!--
This illustrates the use of custom templates without the need
to write
a custom plugin. Just use the <plugin> task directly and
specify as many
<fileproducers> as you like. If the filename attribute contains
a {0},
one file will be generated per table, and the {0} will be
substituted by
the table name in the generated files. If there is no {0}, only
one file
will be generated. You can also narrow down the number of
tables by
explicitly specifying nested <table> elements. If you don't
specify
nested <table> elements, all tables will be used.
-->
<simple
destination="${basedir}"
<fileproducer
destination="${basedir}/build"
filename="toto-{0}.txt"
template="${basedir}/src/templates/simple.vm"
<table name="RESERVATIONS"/>
<table name="PERSONS"/>
</fileproducer>
</simple>

<!-- Plugins "under construction" -->
<!--xmi
destination="${build.xmi.dir}"
/-->
<struts
destination="${build.gen-src.dir}"
package="${name}.web.struts"
<!-- provides a list strut action to enable the list jsp -->
<fileproducer
destination="${build.gen-src.dir}"
filename="List{0}Action.java"
template="${basedir}/src/templates/list-action.vm"
/>
<jsp
name="myjsp"
destination="${build.gen-webui.dir}"
<fileproducer
id="list-jsp"
template="${basedir}/src/templates/list-jsp.vm"
/>
<!-- overrides the existing list jsp for a cleaner list
-->
<fileproducer
id="menu-jsp"
template="${basedir}/src/templates/menu-jsp.vm"
/>
</jsp>
</struts>
<!--
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
/>
-->
</middlegen>
Aslak Hellesoy
2003-01-30 20:04:05 UTC
Permalink
-----Original Message-----
Brian
Sent: 30. januar 2003 21:19
Subject: [Middlegen-user] many2many problem
Hello, this is my first time sending to this list. I'm using middlegen
as CMP2 generator for Jboss 3.0 with a MySql database. I'm receiving a
"RelationshipRole.compareTo" error when I try to create a many to many
relationship across item, category, and category_item tables. I've
included the stack trace, my middlegen ant task, and the Sql DDL used to
gen my three tables. Can anyone help me with a workaround on this
issue?
You're not the first.
http://tinyurl.com/54au

This is the most high priority bug to fix ATM. I won't have time to fix it
until next week though. In the meanwhile I suggest you use the latest
released version or do a CVS update specifying approx. 2 weeks back from
today (it's a rather new bug).

Sorry for the inconvenience.

Aslak

Loading...