Discussion:
[Middlegen-user] Re: bug in 1-to-many relationship
Adrian Hallam
2002-10-04 16:13:05 UTC
Permalink
Hello,

Thanks very much to Joe and Asluk for info on my last
post. My problem was with not having InnoDB enabled in
MySQL. Since then I have been busy building stuff and
learning how this all works. I am now at a point where
I have the same problem as Kasper in his post with the
same subject as this post. I thought I'd try out
something similar with the airline example and I got
the same problem there.

I got the latest version out of CVS a few hours ago
and re-tested. The JBoss server is 3.0.2 and the
airline-ejb.jar file deploys with no problems.
However, when I run the following code:

// Start code snippet
FlightLocalHome ejbFlightLH =
FlightUtil.getLocalHome();
FlightLocal ejbFlight = ejbFlightLH.create("String1",
new Timestamp(new
GregorianCalendar().getTimeInMillis()),
new Timestamp(new
GregorianCalendar().getTimeInMillis()));
myLogger.info("This Works");

PersonLocalHome ejbPersonLH =
PersonUtil.getLocalHome();
PersonLocal ejbPerson = ejbPersonLH.create("Adrian",
"Hallam");
myLogger.info("This Works");

ReservationLocalHome ejbReservationLH =
ReservationUtil.getLocalHome();
ReservationLocal ejbReservation =
ejbReservationLH.create(
new Timestamp(new
GregorianCalendar().getTimeInMillis()), ejbPerson,
ejbFlight);
myLogger.info("This doesn't work");

// End code snippet


The above code causes the following error message in
the JBoss log:

Executing SQL: INSERT INTO reservations
(reservation_id, person_id_fk, flight_id_fk,
registration_utc, comment, person_id_fk, flight_id_fk)
VALUES (?, ?, ?, ?, ?, ?, ?)
...
java.sql.SQLException: General error: Column
'flight_id_fk' specified twice



The problem obviously being the two instances of
person_id_fk in the INSERT statement. Kasper got this
problem with a Sapdb datasource and I am getting it
with MySql so it is probably not a data source issue.
It may be a JBoss bug though?

Is the code above that I used to populate the objects
close enough to correct?

Has anyone else got this working with some differences
(such as different JBoss version or different
database)?

I have attached more info from the Jboss logs. If it
doesn't come through or it would help to have a copy
of the .war used to test this then let me know and
I'll send it.

cheers,
Adrian

http://mobile.yahoo.com.au - Yahoo! Messenger for SMS
- Always be connected to your Messenger Friends
Aslak Hellesøy
2002-10-05 01:10:02 UTC
Permalink
Hi,

I probably shouldn't be answering technical emails 04.52 in the morning
after a night on town, but I'll give it a shot anyway...
-----Original Message-----
Hallam
Sent: 4. oktober 2002 20:13
Subject: [Middlegen-user] Re: bug in 1-to-many relationship
Hello,
Thanks very much to Joe and Asluk for info on my last
Fantastic! I have collected Aksal, Alsak, Alask and Alkas until this post.
Asluk is my favourite so far. I like it.. :-) Any better? (Don't worry,
Ardian, I actually enjoy this).
post. My problem was with not having InnoDB enabled in
MySQL. Since then I have been busy building stuff and
learning how this all works. I am now at a point where
I have the same problem as Kasper in his post with the
same subject as this post. I thought I'd try out
something similar with the airline example and I got
the same problem there.
I got the latest version out of CVS a few hours ago
and re-tested. The JBoss server is 3.0.2 and the
airline-ejb.jar file deploys with no problems.
// Start code snippet
FlightLocalHome ejbFlightLH =
FlightUtil.getLocalHome();
FlightLocal ejbFlight = ejbFlightLH.create("String1",
new Timestamp(new
GregorianCalendar().getTimeInMillis()),
new Timestamp(new
GregorianCalendar().getTimeInMillis()));
myLogger.info("This Works");
PersonLocalHome ejbPersonLH =
PersonUtil.getLocalHome();
PersonLocal ejbPerson = ejbPersonLH.create("Adrian",
"Hallam");
myLogger.info("This Works");
ReservationLocalHome ejbReservationLH =
ReservationUtil.getLocalHome();
ReservationLocal ejbReservation =
ejbReservationLH.create(
new Timestamp(new
GregorianCalendar().getTimeInMillis()), ejbPerson,
ejbFlight);
myLogger.info("This doesn't work");
// End code snippet
The above code causes the following error message in
Executing SQL: INSERT INTO reservations
(reservation_id, person_id_fk, flight_id_fk,
registration_utc, comment, person_id_fk, flight_id_fk)
VALUES (?, ?, ?, ?, ?, ?, ?)
...
java.sql.SQLException: General error: Column
'flight_id_fk' specified twice
IIRC, this is related to a limitation in JBoss:
http://sourceforge.net/mailarchive/message.php?msg_id=1809808
http://boss.bekk.no/boss/middlegen/faq.html (last paragraph)
http://boss.bekk.no/boss/middlegen/plugins/cmp20.html#fkcmp
The problem obviously being the two instances of
person_id_fk in the INSERT statement. Kasper got this
problem with a Sapdb datasource and I am getting it
with MySql so it is probably not a data source issue.
It may be a JBoss bug though?
Yup. Maybe the very latest JBoss (CVS) has got this fixed. -Otherwise, maybe
this warrants a JBoss bug report?
Is the code above that I used to populate the objects
close enough to correct?
Has anyone else got this working with some differences
(such as different JBoss version or different
database)?
I have attached more info from the Jboss logs. If it
doesn't come through or it would help to have a copy
of the .war used to test this then let me know and
I'll send it.
I'll try to try this out tomorrow and see if I can reproduce the situation.

The majority of the last Middlegen issues are related to relations, so
everybody's feedback is very welcome. We'll do our best to find workarounds
for these things before the final release (if we can).
cheers,
Adrian
Thanks,
Aslak
http://mobile.yahoo.com.au - Yahoo! Messenger for SMS
- Always be connected to your Messenger Friends
Loading...