Discussion:
[Middlegen-user] middlegen not auto-detecting relations in MySQL
Timothy Peter Cockle
2003-11-13 08:57:06 UTC
Permalink
Hi,

Does any one else have a problem using MySQL with middlegen?

The relationships are not being detected automatically. I guess I can be
the only one.

Any help greatly appreicated even if it is a simple "It worked fine for
me!"

I create the tables as below:

DROP TABLE IF EXISTS person;
DROP TABLE IF EXISTS information;
DROP TABLE IF EXISTS relationship_type;
DROP TABLE IF EXISTS person_relationship;
DROP TABLE IF EXISTS diary;
DROP TABLE IF EXISTS form;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS question;
DROP TABLE IF EXISTS form_response;
DROP TABLE IF EXISTS wizard;
DROP TABLE IF EXISTS information_request;

CREATE TABLE person(
person_id INT NOT NULL,
//CMP Fields remove to save space
PRIMARY KEY( person_id )
);

CREATE TABLE information(
information_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
information VARCHAR(255) NOT NULL,
person_id_fk INT,
PRIMARY KEY( information_id ),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);


CREATE TABLE relationship_type(
relationship_type_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
PRIMARY KEY( relationship_type_id )
);


CREATE TABLE person_relationship (
person_relationship_id INT NOT NULL,
person_id_fk INT,
relationship_type_id_fk INT,
PRIMARY KEY(person_relationship_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id),
FOREIGN KEY (relationship_type_id_fk) REFERENCES
relationship_type(relationship_type_id)
);



CREATE TABLE diary(
diary_id INT NOT NULL,
//CMP Fields remove to save space
person_id_fk INT,
PRIMARY KEY(diary_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);



And run middlegen like this:

<!-- For the Person Entities -->
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${databaseSource}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
<!-- Define Relationships -->


<many2many>
<tablea name="person">
<!-- <crossref fktable="person_relationship"
fkcolumn="person_id_fk"/> -->
</tablea>
<jointable name="person_relationship"
generate="false"/>
<!-- <jointable name="person_relationship"/> -->
<tableb name="relationship_type">
<!-- <crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/> -->
</tableb>
</many2many>
<!--
<table name="information"/>
<table name="relationship_type">
<crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/>
</table>
<table name="diary"/>
<table name="person">
<crossref fktable="information"
fkcolumn="person_id_fk"/>
<crossref fktable="diary"
fkcolumn="person_id_fk"/>
<crossref fktable="person_relationship"
fkcolumn="person_id_fk"/>
</table>
<table name ="person_relationship">
</table>
-->
<!-- Let Middlegen find Relationships -->
<table name="information"/>
<table name="relationship_type"/>
<table name="diary"/>
<table name="person"/>
<!-- <table name="person_relationship"/> -->

<cmp20
destination="${build.gen-src.dir}"
package="alpha.personEntities"
interfacepackage="alpha.personEntitiesInterfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="false"
guid="true"
<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
package="alpha.miscEntities"
interfacepackage="alpha.miscEntitiesInterfaces"
/>

<jboss/>
</cmp20>
</middlegen>


Cheers,

Tim
Markus Härnvi
2003-11-13 09:07:08 UTC
Permalink
Hi!

Isn't MySQL clueless about relations? Use PostgreSQL instead perhaps?
Post by Timothy Peter Cockle
Hi,
Does any one else have a problem using MySQL with middlegen?
The relationships are not being detected automatically. I guess I can be
the only one.
Any help greatly appreicated even if it is a simple "It worked fine for
me!"
DROP TABLE IF EXISTS person;
DROP TABLE IF EXISTS information;
DROP TABLE IF EXISTS relationship_type;
DROP TABLE IF EXISTS person_relationship;
DROP TABLE IF EXISTS diary;
DROP TABLE IF EXISTS form;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS question;
DROP TABLE IF EXISTS form_response;
DROP TABLE IF EXISTS wizard;
DROP TABLE IF EXISTS information_request;
CREATE TABLE person(
person_id INT NOT NULL,
//CMP Fields remove to save space
PRIMARY KEY( person_id )
);
CREATE TABLE information(
information_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
information VARCHAR(255) NOT NULL,
person_id_fk INT,
PRIMARY KEY( information_id ),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
CREATE TABLE relationship_type(
relationship_type_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
PRIMARY KEY( relationship_type_id )
);
CREATE TABLE person_relationship (
person_relationship_id INT NOT NULL,
person_id_fk INT,
relationship_type_id_fk INT,
PRIMARY KEY(person_relationship_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id),
FOREIGN KEY (relationship_type_id_fk) REFERENCES
relationship_type(relationship_type_id)
);
CREATE TABLE diary(
diary_id INT NOT NULL,
//CMP Fields remove to save space
person_id_fk INT,
PRIMARY KEY(diary_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
<!-- For the Person Entities -->
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${databaseSource}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
<!-- Define Relationships -->
<many2many>
<tablea name="person">
<!-- <crossref fktable="person_relationship"
fkcolumn="person_id_fk"/> -->
</tablea>
<jointable name="person_relationship"
generate="false"/>
<!-- <jointable name="person_relationship"/> -->
<tableb name="relationship_type">
<!-- <crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/> -->
</tableb>
</many2many>
<!--
<table name="information"/>
<table name="relationship_type">
<crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/>
</table>
<table name="diary"/>
<table name="person">
<crossref fktable="information"
fkcolumn="person_id_fk"/>
<crossref fktable="diary"
fkcolumn="person_id_fk"/>
<crossref fktable="person_relationship"
fkcolumn="person_id_fk"/>
</table>
<table name ="person_relationship">
</table>
-->
<!-- Let Middlegen find Relationships -->
<table name="information"/>
<table name="relationship_type"/>
<table name="diary"/>
<table name="person"/>
<!-- <table name="person_relationship"/> -->
<cmp20
destination="${build.gen-src.dir}"
package="alpha.personEntities"
interfacepackage="alpha.personEntitiesInterfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="false"
guid="true"
<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
package="alpha.miscEntities"
interfacepackage="alpha.miscEntitiesInterfaces"
/>
<jboss/>
</cmp20>
</middlegen>
Cheers,
Tim
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Timothy Peter Cockle
2003-11-13 09:41:05 UTC
Permalink
Thanks for the quick reply I will look into it.

Tim
Post by Markus Härnvi
Hi!
Isn't MySQL clueless about relations? Use PostgreSQL instead perhaps?
Post by Timothy Peter Cockle
Hi,
Does any one else have a problem using MySQL with middlegen?
The relationships are not being detected automatically. I guess I can be
the only one.
Any help greatly appreicated even if it is a simple "It worked fine for
me!"
DROP TABLE IF EXISTS person;
DROP TABLE IF EXISTS information;
DROP TABLE IF EXISTS relationship_type;
DROP TABLE IF EXISTS person_relationship;
DROP TABLE IF EXISTS diary;
DROP TABLE IF EXISTS form;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS question;
DROP TABLE IF EXISTS form_response;
DROP TABLE IF EXISTS wizard;
DROP TABLE IF EXISTS information_request;
CREATE TABLE person(
person_id INT NOT NULL,
//CMP Fields remove to save space
PRIMARY KEY( person_id )
);
CREATE TABLE information(
information_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
information VARCHAR(255) NOT NULL,
person_id_fk INT,
PRIMARY KEY( information_id ),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
CREATE TABLE relationship_type(
relationship_type_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
PRIMARY KEY( relationship_type_id )
);
CREATE TABLE person_relationship (
person_relationship_id INT NOT NULL,
person_id_fk INT,
relationship_type_id_fk INT,
PRIMARY KEY(person_relationship_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id),
FOREIGN KEY (relationship_type_id_fk) REFERENCES
relationship_type(relationship_type_id)
);
CREATE TABLE diary(
diary_id INT NOT NULL,
//CMP Fields remove to save space
person_id_fk INT,
PRIMARY KEY(diary_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
<!-- For the Person Entities -->
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${databaseSource}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
<!-- Define Relationships -->
<many2many>
<tablea name="person">
<!-- <crossref fktable="person_relationship"
fkcolumn="person_id_fk"/> -->
</tablea>
<jointable name="person_relationship"
generate="false"/>
<!-- <jointable name="person_relationship"/> -->
<tableb name="relationship_type">
<!-- <crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/> -->
</tableb>
</many2many>
<!--
<table name="information"/>
<table name="relationship_type">
<crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/>
</table>
<table name="diary"/>
<table name="person">
<crossref fktable="information"
fkcolumn="person_id_fk"/>
<crossref fktable="diary"
fkcolumn="person_id_fk"/>
<crossref fktable="person_relationship"
fkcolumn="person_id_fk"/>
</table>
<table name ="person_relationship">
</table>
-->
<!-- Let Middlegen find Relationships -->
<table name="information"/>
<table name="relationship_type"/>
<table name="diary"/>
<table name="person"/>
<!-- <table name="person_relationship"/> -->
<cmp20
destination="${build.gen-src.dir}"
package="alpha.personEntities"
interfacepackage="alpha.personEntitiesInterfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="false"
guid="true"
<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
package="alpha.miscEntities"
interfacepackage="alpha.miscEntitiesInterfaces"
/>
<jboss/>
</cmp20>
</middlegen>
Cheers,
Tim
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
M.-Leander Reimer
2003-11-13 16:44:02 UTC
Permalink
Hey Tim,

well mySQL itself is clueless about relations, you have to use the
InnoDB extension instead!!!!!

CU
Leander
Post by Timothy Peter Cockle
Thanks for the quick reply I will look into it.
Tim
Post by Markus Härnvi
Hi!
Isn't MySQL clueless about relations? Use PostgreSQL instead perhaps?
Post by Timothy Peter Cockle
Hi,
Does any one else have a problem using MySQL with middlegen?
The relationships are not being detected automatically. I guess I can be
the only one.
Any help greatly appreicated even if it is a simple "It worked fine for
me!"
DROP TABLE IF EXISTS person;
DROP TABLE IF EXISTS information;
DROP TABLE IF EXISTS relationship_type;
DROP TABLE IF EXISTS person_relationship;
DROP TABLE IF EXISTS diary;
DROP TABLE IF EXISTS form;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS question;
DROP TABLE IF EXISTS form_response;
DROP TABLE IF EXISTS wizard;
DROP TABLE IF EXISTS information_request;
CREATE TABLE person(
person_id INT NOT NULL,
//CMP Fields remove to save space
PRIMARY KEY( person_id )
);
CREATE TABLE information(
information_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
information VARCHAR(255) NOT NULL,
person_id_fk INT,
PRIMARY KEY( information_id ),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
CREATE TABLE relationship_type(
relationship_type_id INT NOT NULL,
type VARCHAR(255) NOT NULL,
PRIMARY KEY( relationship_type_id )
);
CREATE TABLE person_relationship (
person_relationship_id INT NOT NULL,
person_id_fk INT,
relationship_type_id_fk INT,
PRIMARY KEY(person_relationship_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id),
FOREIGN KEY (relationship_type_id_fk) REFERENCES
relationship_type(relationship_type_id)
);
CREATE TABLE diary(
diary_id INT NOT NULL,
//CMP Fields remove to save space
person_id_fk INT,
PRIMARY KEY(diary_id),
FOREIGN KEY (person_id_fk) REFERENCES person(person_id)
);
<!-- For the Person Entities -->
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${databaseSource}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
<!-- Define Relationships -->
<many2many>
<tablea name="person">
<!-- <crossref fktable="person_relationship"
fkcolumn="person_id_fk"/> -->
</tablea>
<jointable name="person_relationship"
generate="false"/>
<!-- <jointable name="person_relationship"/> -->
<tableb name="relationship_type">
<!-- <crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/> -->
</tableb>
</many2many>
<!--
<table name="information"/>
<table name="relationship_type">
<crossref fktable="person_relationship"
fkcolumn="relationship_type_id_fk"/>
</table>
<table name="diary"/>
<table name="person">
<crossref fktable="information"
fkcolumn="person_id_fk"/>
<crossref fktable="diary"
fkcolumn="person_id_fk"/>
<crossref fktable="person_relationship"
fkcolumn="person_id_fk"/>
</table>
<table name ="person_relationship">
</table>
-->
<!-- Let Middlegen find Relationships -->
<table name="information"/>
<table name="relationship_type"/>
<table name="diary"/>
<table name="person"/>
<!-- <table name="person_relationship"/> -->
<cmp20
destination="${build.gen-src.dir}"
package="alpha.personEntities"
interfacepackage="alpha.personEntitiesInterfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="false"
guid="true"
<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
package="alpha.miscEntities"
interfacepackage="alpha.miscEntitiesInterfaces"
/>
<jboss/>
</cmp20>
</middlegen>
Cheers,
Tim
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
--
GnuPG Fingerprint = FC88 7806 111C 9DD5 1136 B311 EF00 4F8F A6D1 DC79
José Manuel Molina Pascual
2003-11-14 07:02:03 UTC
Permalink
Loading...