Discussion:
[Middlegen-user] Duplicate attributes
Thomas Breitler
2002-09-16 12:55:02 UTC
Permalink
Hi!

I try to generate some Enterpriease Java Beans using the latest CVS
version of middlegen (and the latest of XDoclet). Connection to Oracle
DB works fine, but all the bean classes generated by middlegen have
duplicated attributes.
An Oracle table called TEST with two attributes ID and NAME will result
in an entity bean like this (comments stripped):

public abstract class TestBean implements javax.ejb.EntityBean {

public abstract java.lang.Long getId();
public abstract void setId(java.lang.Long id);
public abstract java.lang.Long getName();
public abstract void setName(java.lang.String name);
public abstract java.lang.Long getId();
public abstract void setId(java.lang.Long id);
public abstract java.lang.Long getName();
public abstract void setName(java.lang.String name);

}

The classes generated by XDoclet are OK - i.e. extensions like
TestCMP.java and the data object classes doesn't have duplicate
attributes.

Any ideas?

Thomas
Ampie Barnard
2002-09-17 05:36:02 UTC
Permalink
Hi!

In a case where I have 2 different foreign keys (fkX and fkY) from table A
to table B, a previous version of Middlegen would pick up two different
relationship roles in B: B.aByFkX and B.aByFkY. This was quite a cool
feature!

Since I have checked out the latest version from CVS though, it seems to
confuse these two different roles with a foreign key consisting of two
fields. In other word, it only sees one relationship role, but two column
maps.

Is this an intended change?

Regards

Ampie
Ampie Barnard
2002-09-17 08:41:05 UTC
Permalink
OK, here's the deal.

I am using MySQL 4 and the latest Connector drivers, but I get this
behaviour in all the drivers I tried.
The guys at MySQL seem to believe that the field "KEY_SEQ" in the resultset
returned by DatabaseMetaDAta.getExportedKeys
is the sequence of all key fields for all relationships for the table. As I
understand, is should be the sequence of the key in the current
relationship. The Middlegen code shares this understanding. Unfortunately,
the MySQL guys also see no use for the concept of of foreign key name. For
these two reasons, the following code in MiddleGenPopulator.addRelations
won't work on MySQL:

String pkColumnName = exportedKeyRs.getString("PKCOLUMN_NAME");
String fkColumnName = exportedKeyRs.getString("FKCOLUMN_NAME");
String fkName = exportedKeyRs.getString("FK_NAME");
short keySeq = exportedKeyRs.getShort("KEY_SEQ");
// Warn if there is a relation to a column which is not a pk

if (keySeq == 0) {
bogusFkName++;
}
if (fkName == null) {
fkName = String.valueOf(bogusFkName);
}

addCrossref(pkTable, pkColumnName, fkTableName, fkColumnName, fkName,
fkTables);


But I don't think it is worth while code for bugs in MySQL. What I have
found was that the MySQL JDBC drivers' metadata is not up to standard - they
lose all multi-keyed relationships - very bad! For my fellow MySQL-Middlegen
users I would recommend using the ODBC driver (which is much stronger on
metadata) and access it with the JDBC-ODBC bridge.
Unfortunately, here the "KEY_SEQ" field is 1 based as opposed to 0 based.
Since mySQL does not store foreign key names, all the "FK_NAME" values are
"NULL" (the string value "NULL"). I replaced (apologies!) the abovementioned
code with the following, and it seems to work:
String pkColumnName = exportedKeyRs.getString("PKCOLUMN_NAME");
String fkColumnName = exportedKeyRs.getString("FKCOLUMN_NAME");
short keySeq = exportedKeyRs.getShort("KEY_SEQ");
// Warn if there is a relation to a column which is not a pk

if (keySeq < lastKeySeq) {
bogusFkName++;
}
lastKeySeq=keySeq;
fkName = String.valueOf(bogusFkName);//Just force it (ODBC-bridge has
the string value "NULL")

addCrossref(pkTable, pkColumnName, fkTableName, fkColumnName, fkName,
fkTables);

This works perfectly for the MySQL ODBC drivers as well as for the MySQL
JDBC drivers. But it does solve the absence of multi-keyed relationships in
the MySQL JDBC drivers.


-----Original Message-----
From: middlegen-user-***@lists.sourceforge.net
[mailto:middlegen-user-***@lists.sourceforge.net]On Behalf Of Ampie
Barnard
Sent: 17 September 2002 09:40
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] Relationship roles merged


Hi!

In a case where I have 2 different foreign keys (fkX and fkY) from table A
to table B, a previous version of Middlegen would pick up two different
relationship roles in B: B.aByFkX and B.aByFkY. This was quite a cool
feature!

Since I have checked out the latest version from CVS though, it seems to
confuse these two different roles with a foreign key consisting of two
fields. In other word, it only sees one relationship role, but two column
maps.

Is this an intended change?

Regards

Ampie



-------------------------------------------------------
Sponsored by: AMD - Your access to the experts on Hammer Technology!
Open Source & Linux Developers, register now for the AMD Developer
Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
a***@netcom.no
2002-09-17 11:32:04 UTC
Permalink
(cc to Mark Matthews)

Aaah, if everybody could debug like you :-)

Since I started with Middlegen I (or others) have found bugs in the
following JDBC drivers (metadata part of them):
-hsqldb
-postgresql
-mysql
-oracle

The JDBC spec is so fuzzy that you can't expect people to implement
drivers correctly. -And who uses metadata anyway? Only obscure tools
like Middlegen and a few others.

I have already told Mark Matthews (who wrote the MySQL JDBC driver)
about another bug. I tried to post a bug report (basically a copy of
your mail) at http://sf.net/projects/mysql/ but it was lost for some
reason. I don't even know if that is the right place to post
Connector/J bugs. Mark Matthews isn't on the mysql SF project team, but
his driver has moved to MySQL (!?!?!)

Mark, wise man. Can you help us?

Aslak

----- Original Message -----
From: "Ampie Barnard" <***@mweb.co.za>
Date: Tuesday, September 17, 2002 10:46 pm
Subject: RE: [Middlegen-user] Relationship roles merged
Post by Ampie Barnard
OK, here's the deal.
I am using MySQL 4 and the latest Connector drivers, but I get this
behaviour in all the drivers I tried.
The guys at MySQL seem to believe that the field "KEY_SEQ" in the
resultsetreturned by DatabaseMetaDAta.getExportedKeys
is the sequence of all key fields for all relationships for the
table. As I
understand, is should be the sequence of the key in the current
relationship. The Middlegen code shares this understanding.
Unfortunately,the MySQL guys also see no use for the concept of of
foreign key name. For
these two reasons, the following code in
String pkColumnName =
exportedKeyRs.getString("PKCOLUMN_NAME");
String fkColumnName = exportedKeyRs.getString("FKCOLUMN_NAME");
String fkName =
exportedKeyRs.getString("FK_NAME");
short keySeq = exportedKeyRs.getShort("KEY_SEQ");
// Warn if there is a relation to
a column which is not a pk
if (keySeq == 0) {
bogusFkName++;
}
if (fkName == null) {
fkName =
String.valueOf(bogusFkName); }
addCrossref(pkTable, pkColumnName,
fkTableName, fkColumnName, fkName,
fkTables);
But I don't think it is worth while code for bugs in MySQL. What I
havefound was that the MySQL JDBC drivers' metadata is not up to
standard - they
lose all multi-keyed relationships - very bad! For my fellow MySQL-
Middlegenusers I would recommend using the ODBC driver (which is
much stronger on
metadata) and access it with the JDBC-ODBC bridge.
Unfortunately, here the "KEY_SEQ" field is 1 based as opposed to 0
based.Since mySQL does not store foreign key names, all the
"FK_NAME" values are
"NULL" (the string value "NULL"). I replaced (apologies!) the
String pkColumnName =
exportedKeyRs.getString("PKCOLUMN_NAME");
String fkColumnName = exportedKeyRs.getString("FKCOLUMN_NAME");
short keySeq =
exportedKeyRs.getShort("KEY_SEQ");
// Warn if there is a relation to a column which is not a pk
if (keySeq < lastKeySeq) {
bogusFkName++;
}
lastKeySeq=keySeq;
fkName =
String.valueOf(bogusFkName);//Just force it (ODBC-bridge has
the string value "NULL")
addCrossref(pkTable, pkColumnName,
fkTableName, fkColumnName, fkName,
fkTables);
This works perfectly for the MySQL ODBC drivers as well as for the
MySQLJDBC drivers. But it does solve the absence of multi-keyed
relationships in
the MySQL JDBC drivers.
-----Original Message-----
Barnard
Sent: 17 September 2002 09:40
Subject: [Middlegen-user] Relationship roles merged
Hi!
In a case where I have 2 different foreign keys (fkX and fkY) from
table A
to table B, a previous version of Middlegen would pick up two
differentrelationship roles in B: B.aByFkX and B.aByFkY. This was
quite a cool
feature!
Since I have checked out the latest version from CVS though, it
seems to
confuse these two different roles with a foreign key consisting of two
fields. In other word, it only sees one relationship role, but two
columnmaps.
Is this an intended change?
Regards
Ampie
-------------------------------------------------------
Sponsored by: AMD - Your access to the experts on Hammer Technology!
Open Source & Linux Developers, register now for the AMD Developer
Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
Sponsored by: AMD - Your access to the experts on Hammer
Technology!
Open Source & Linux Developers, register now for the AMD Developer
Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Mark Matthews
2002-09-17 11:34:02 UTC
Permalink
----- Original Message -----
From: <***@netcom.no>
To: <***@mweb.co.za>
Cc: <middlegen-***@lists.sourceforge.net>;
<***@users.sourceforge.net>
Sent: Tuesday, September 17, 2002 8:29 AM
Subject: Re: RE: [Middlegen-user] Relationship roles merged
Post by a***@netcom.no
(cc to Mark Matthews)
Aaah, if everybody could debug like you :-)
Since I started with Middlegen I (or others) have found bugs in the
-hsqldb
-postgresql
-mysql
-oracle
The JDBC spec is so fuzzy that you can't expect people to implement
drivers correctly. -And who uses metadata anyway? Only obscure tools
like Middlegen and a few others.
I have already told Mark Matthews (who wrote the MySQL JDBC driver)
about another bug. I tried to post a bug report (basically a copy of
your mail) at http://sf.net/projects/mysql/ but it was lost for some
reason. I don't even know if that is the right place to post
Connector/J bugs. Mark Matthews isn't on the mysql SF project team, but
his driver has moved to MySQL (!?!?!)
Mark, wise man. Can you help us?
I've got this fixed in version 3.0.1 of the driver, to be released probably
by the end of this week.

Funny thing is, this bug isn't even detected in the JDBC-compliance
testsuite, so that tells you how much that MetaData is tested amongst all
drivers :)

-Mark
a***@netcom.no
2002-09-17 11:43:02 UTC
Permalink
----- Original Message -----
From: "Mark Matthews" <***@thematthews.org>
Date: Tuesday, September 17, 2002 1:33 pm
Subject: Re: RE: [Middlegen-user] Relationship roles merged
Post by a***@netcom.no
----- Original Message -----
Sent: Tuesday, September 17, 2002 8:29 AM
Subject: Re: RE: [Middlegen-user] Relationship roles merged
Post by a***@netcom.no
(cc to Mark Matthews)
Aaah, if everybody could debug like you :-)
Since I started with Middlegen I (or others) have found bugs in the
-hsqldb
-postgresql
-mysql
-oracle
The JDBC spec is so fuzzy that you can't expect people to implement
drivers correctly. -And who uses metadata anyway? Only obscure tools
like Middlegen and a few others.
I have already told Mark Matthews (who wrote the MySQL JDBC driver)
about another bug. I tried to post a bug report (basically a
copy of
Post by a***@netcom.no
your mail) at http://sf.net/projects/mysql/ but it was lost for some
reason. I don't even know if that is the right place to post
Connector/J bugs. Mark Matthews isn't on the mysql SF project
team, but
Post by a***@netcom.no
his driver has moved to MySQL (!?!?!)
Mark, wise man. Can you help us?
I've got this fixed in version 3.0.1 of the driver, to be released
probablyby the end of this week.
Funny thing is, this bug isn't even detected in the JDBC-compliance
testsuite, so that tells you how much that MetaData is tested
amongst all
drivers :)
Then Middlegen will be your test suite. Where do we report the next bug
we find? (That is, if there are any bugs left :) Do you really want
them mailed to you?

Aslak
Post by a***@netcom.no
-Mark
-------------------------------------------------------
Sponsored by: AMD - Your access to the experts on Hammer
Technology!
Open Source & Linux Developers, register now for the AMD Developer
Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Mark Matthews
2002-09-17 12:02:01 UTC
Permalink
----- Original Message -----
From: <***@netcom.no>
To: "Mark Matthews" <***@thematthews.org>
Cc: <***@mweb.co.za>; <middlegen-***@lists.sourceforge.net>;
<***@users.sourceforge.net>
Sent: Tuesday, September 17, 2002 8:41 AM
Subject: Re: RE: [Middlegen-user] Relationship roles merged


[snip]
Post by a***@netcom.no
Post by Mark Matthews
Funny thing is, this bug isn't even detected in the JDBC-compliance
testsuite, so that tells you how much that MetaData is tested
amongst all
drivers :)
Then Middlegen will be your test suite. Where do we report the next bug
we find? (That is, if there are any bugs left :) Do you really want
them mailed to you?
Report bugs with Connector/J to ***@lists.mysql.com

MySQL-AB is in the process of rolling out a unified bug tracker, which is
just about ready. At that time, it will make more sense to use that. Until
now, the mailing list will work.

-Mark

Loading...