Discussion:
[Middlegen-user] Problem with relationship in MySQL
Fabio Oliveira
2003-07-03 10:13:16 UTC
Permalink
Dear friends:

I'm having problems with middlegen and MySQL in multiple foreign keys
database relationship.

My configuration:
- MySQL 4.0.13, for pc-linux (i686)
- Driver JDBC mysql-connector-java-3.0.0-beta-bin.jar (I try with the
last version and occurs the same problem)
- middlegen 2.0 b1

If i create only one column in foreign key, the relation work, but when
i put more 1 column, middlegen display this warning:

[middlegen] (middlegen.MiddlegenPopulator 222 ) WARNING:
Middlegen couldn't find any relations between any tables. This may be
intentional from the design of the database, but it may also be because
you have incorrectly defined the relationships. It could also be because
the JDBC driver you're using doesn't correctly implement
DatabaseMetaData. See the samples (for an example on how to define
relationships) and verify that your driver correctly implements
DatabaseMetaData.

My Mysql Script is:

create table a (campo1 integer not null,
campo2 integer not null,
primary key (campo1,campo2)
) type=innodb;

create table b(campo3 integer not null,
campo4 integer not null,campo5 integer not null,campo6 integer not null,
primary key (campo3,campo4),
index i2 (campo5,campo6),
foreign key (campo5,campo6) references a (campo1,campo2)
) type=innodb;

I read the instructions of Aslak in Myddlegen page.

" Requires MySQL 3.23.43b (or higher) with InnoDB enabled and MM.MySQL
2.0.9 or higher. The table names must be define in lower case, otherwise
no relations will be discovered. If you have relations using foreign
keys that consist of multiple columns, you should use the driver shipped
with Middlegen. It has a bugfix which isn't yet fixed in the official
driver."

My driver is the same with middlegen distribution, my tables was in
lower case, but don't works!

My mysql.xml

property name="database.script.file"
value="${src.dir}/sql/${name}-mysql.sql"/>
<property name="database.driver.file"
value="${lib.dir}/mysql-connector-java-3.0.0-beta-bin.jar"/>
<property name="database.driver.classpath"
value="${database.driver.file}"/>
<property name="database.driver"
value="org.gjt.mm.mysql.Driver"/>
<property name="database.url"
value="jdbc:mysql://localhost/webfor"/>
<property name="database.userid" value="root"/>
<property name="database.password" value=""/>
<property name="database.schema" value=""/>
<property name="database.catalog" value=""/>

<property name="jboss.datasource.mapping" value="mySQL"/>


I need help...
Fábio.
Aslak Hellesøy
2003-07-03 11:01:36 UTC
Permalink
Post by Fabio Oliveira
I'm having problems with middlegen and MySQL in multiple foreign keys
database relationship.
Your MySQL tables must be of type InnoDB.

Aslak
Fabio Oliveira
2003-07-03 11:55:02 UTC
Permalink
Post by Aslak Hellesøy
Your MySQL tables must be of type InnoDB.
Dear Aslak:
In my script, i was used type InnoDB.
Look the error:
[Middlegen] (middlegen.MiddlegenPopulator 222 ) WARNING:
Middlegen couldn
't find any relations between any tables. This may be intentional from
the desig
n of the database, but it may also be because you have incorrectly
defined the r
elationships. It could also be because the JDBC driver you're using
doesn't corr
ectly implement DatabaseMetaData. See the samples (for an example on how
to defi
ne relationships) and verify that your driver correctly implements
DatabaseMetaD
ata.

Look my script:
drop table if exists a;
drop table if exists b;
create table a (campo1 integer not null,
campo2 integer not null,
primary key (campo1,campo2)
) type=InnoDB;

create table b(campo3 integer not null,
campo4 integer not null,campo5 integer not null,campo6 integer not null,
primary key (campo3,campo4),
index i2 (campo5,campo6),
foreign key (campo5,campo6) references a (campo1,campo2)
) type=InnoDB;

Fabio.
Aslak Hellesøy
2003-07-03 12:03:09 UTC
Permalink
Post by Fabio Oliveira
Post by Aslak Hellesøy
Your MySQL tables must be of type InnoDB.
In my script, i was used type InnoDB.
Middlegen couldn
't find any relations between any tables. This may be intentional from
the desig
n of the database, but it may also be because you have incorrectly
defined the r
elationships. It could also be because the JDBC driver you're using
doesn't corr
ectly implement DatabaseMetaData. See the samples (for an example on how
to defi
ne relationships) and verify that your driver correctly implements
DatabaseMetaD
ata.
drop table if exists a;
drop table if exists b;
create table a (campo1 integer not null,
campo2 integer not null,
primary key (campo1,campo2)
) type=InnoDB;
create table b(campo3 integer not null,
campo4 integer not null,campo5 integer not null,campo6 integer not null,
primary key (campo3,campo4),
index i2 (campo5,campo6),
foreign key (campo5,campo6) references a (campo1,campo2)
) type=InnoDB;
Fabio.
Looks correct. Can you get the samples to work? If they don't work for
you either, you're most likely doing something wrong on the MySQL side.
Maybe InnoDB hasn't been properly installed? It's not enough to just
declare InnoDB in your SQL. See the InnoDB manual. Also make sure you're
using the driver that ships with Middlegen when you run Middlegen.

http://boss.bekk.no/boss/middlegen/platforms/database.html
HTH,
Aslak
Post by Fabio Oliveira
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Fabio Oliveira
2003-07-03 12:19:13 UTC
Permalink
Post by Aslak Hellesøy
Looks correct. Can you get the samples to work? If they don't work for
you either, you're most likely doing something wrong on the MySQL side.
Maybe InnoDB hasn't been properly installed? It's not enough to just
declare InnoDB in your SQL. See the InnoDB manual. Also make sure you're
using the driver that ships with Middlegen when you run Middlegen.
http://boss.bekk.no/boss/middlegen/platforms/database.html
The installation seems ok, and I made the reinstallation...
If i create only one column in foreign key, the relation work's in
Middlegen, but when i put more 1 column, middlegen display that warning.
If the InnoDB is the problem, the relation with 1 column it would have
don't work, i think... The driver is the same it comes middlegen.
I try in another machine with RedHat 8 and the last version of MySQL,
and it persists.

This script works. (One column)

create table a (campo1 integer not null,
campo2 integer not null,
primary key (campo1,campo2)
) type=InnoDB;

create table b(campo3 integer not null,
campo4 integer not null,campo5 integer not null,campo6 integer not null,
primary key (campo3,campo4),
index i2 (campo5),
foreign key (campo5) references a (campo1)
) type=InnoDB;

Thanks.
Fabio.
Fabio Oliveira
2003-07-03 12:27:04 UTC
Permalink
Post by Aslak Hellesøy
Looks correct. Can you get the samples to work? If they don't work for
you either, you're most likely doing something wrong on the MySQL side.
Maybe InnoDB hasn't been properly installed? It's not enough to just
declare InnoDB in your SQL. See the InnoDB manual. Also make sure you're
using the driver that ships with Middlegen when you run Middlegen.
The AirLine example works in HSQLDB and MySQL!
This example use one column in the foreign key.
I change the example to use two columns and the error occurs!
The problem is compose key.

Fabio.
sabat
2003-07-31 15:23:02 UTC
Permalink
Spying this very cool news from Eivind (from back in May), I'm curious
about a couple of things:

- this refactoring is the same refactoring that's going on at codehaus,
correct? Meaning that value objects, facades, JBossQL, etc. are all
going to end up in the refactored version, I hope...

- if one wants to play with the current version of this branch, one
would still check it out from cvs.sf.net (-r
VALUEOBJECT_REFACTORING_BRANCH), or is the codehaus CVS more up-to-date now?

-Steve
Thought I'd send some information about what's been done in the
VALUEOBJECT_REFACTORING_BRANCH branch in CVS.
====================
1. Value Object support. In the build.xml, you can now specify
valueobject="true". There are two value objects for each entity, an
XXLightValue which only has fields and an XXValue which extends
XXLightValue and has relationships.
2. Entity Facade support. By specifying sessionfacade="true" in the
build.xml file, a Middlegen specific version of XDoclet entity facade
objects are generated. These can be used to access all the entities
remotely. Value objects must be generated for this to work, as all data
are transported as value objects (since local entity references can't be
passed remotely).
3. DynamicQL for JBoss. By specifying dynamicQL="true" on the <jboss>
subelement of the <cmp20> plugin, a method for dynamic JBossQL is added to
Eivind Waaler
2003-08-04 08:11:03 UTC
Permalink
Post by sabat
Spying this very cool news from Eivind (from back in May), I'm curious
- this refactoring is the same refactoring that's going on at codehaus,
correct? Meaning that value objects, facades, JBossQL, etc. are all
going to end up in the refactored version, I hope...
Yes I hope to have everything in there once the new core is up and
running.
Post by sabat
- if one wants to play with the current version of this branch, one
would still check it out from cvs.sf.net (-r
VALUEOBJECT_REFACTORING_BRANCH), or is the codehaus CVS more up-to-date now?
Still found at the VO branch at sf.net. I've also added the updated
hibernate plugin submitted some time ago to this one..

.eivind
Post by sabat
-Steve
Thought I'd send some information about what's been done in the
VALUEOBJECT_REFACTORING_BRANCH branch in CVS.
====================
1. Value Object support. In the build.xml, you can now specify
valueobject="true". There are two value objects for each entity, an
XXLightValue which only has fields and an XXValue which extends
XXLightValue and has relationships.
2. Entity Facade support. By specifying sessionfacade="true" in the
build.xml file, a Middlegen specific version of XDoclet entity facade
objects are generated. These can be used to access all the entities
remotely. Value objects must be generated for this to work, as all data
are transported as value objects (since local entity references can't be
passed remotely).
3. DynamicQL for JBoss. By specifying dynamicQL="true" on the <jboss>
subelement of the <cmp20> plugin, a method for dynamic JBossQL is added to
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...