(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" <[EMAIL PROTECTED]>
Date: Tuesday, September 17, 2002 10:46 pm
Subject: RE: [Middlegen-user] Relationship roles merged

> 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 
> MiddleGenPopulator.addRelationswon'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 
> 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 
> abovementionedcode 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 
> MySQLJDBC drivers. But it does solve the absence of multi-keyed 
> relationships in
> the MySQL JDBC drivers.
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Ampie
> Barnard
> Sent: 17 September 2002 09:40
> To: [EMAIL PROTECTED]
> 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
> [EMAIL PROTECTED]
> 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
> [EMAIL PROTECTED]
> 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
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/middlegen-user

Reply via email to