Discussion:
[Middlegen-user] FindByForeignKey failed
Steve Knight
2002-02-11 16:04:05 UTC
Permalink
Hello,
First let me just say that Middlegen 1.0 looks great so far...nice work Aslak!
Now, i tried a simple example using two tables as folows:

parent --> parentid, name
child --> childid, name, parentid

where parentid in the child table is the Foreign Key to the parent table.
The problem occurs when I try to call the cmr accessor method getChilds( ), I get the following error:

The Parent is:
1 John Smith
The Children are:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'; nested exception is:
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'


Why is it calling the foreign key field "parent_parentid" when it should be just "parentid"? Why is it creating this column name? Please pardon my ignorance as I am new to both XDoclet and Middlegen (and EJBs for that matter). All of the relationship code was generated by Middlegen and I am calling getChilds( ) from within a remote Parent interface method called getChildrenData( ), which returns a collection of dataobjects (to the remote client) representing the parent's associated children.

Any ideas?

Thanks,
Steve
a***@netcom.no
2002-02-12 05:33:07 UTC
Permalink
----- Original Message -----
From: "Steve Knight" <***@hotmail.com>
Date: Monday, February 11, 2002 7:05 pm
Subject: [Middlegen-user] FindByForeignKey failed
Post by Steve Knight
Hello,
First let me just say that Middlegen 1.0 looks great so far...nice
work Aslak!
Thanks! -And as interest grows, I get more feedback, and the tool gets
better. What is your environment, more specifically:

-database
-ejb container

Can you send me the deployment descriptors (samples/build/META-
INF/*.xml) and perhaps a screen-shot of Middlegen?

And I'll see if I can help you.

-Aslak
Post by Steve Knight
parent --> parentid, name
child --> childid, name, parentid
where parentid in the child table is the Foreign Key to the parent
table.
The problem occurs when I try to call the cmr accessor method
1 John Smith
java.rmi.ServerException: RemoteException occurred in server
java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'
Why is it calling the foreign key field "parent_parentid" when it
should be just "parentid"? Why is it creating this column name?
Please pardon my ignorance as I am new to both XDoclet and
Middlegen (and EJBs for that matter). All of the relationship
code was generated by Middlegen and I am calling getChilds( ) from
within a remote Parent interface method called getChildrenData( ),
which returns a collection of dataobjects (to the remote client)
representing the parent's associated children.
Any ideas?
Thanks,
Steve
Steve Knight
2002-02-12 14:00:10 UTC
Permalink
Sorry, i forgot to mention that I am using JBoss 3.0 and MySQL.
Now, when I changed the foreign-key column name in my database to
parent_parentid it worked fine. But if I have parentid it complains that it
is looking for parent_parentid:

java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'; nested
exc
eption is:
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'
javax.ejb.EJBException: FindByForeignKey failed


I think this might be a JBoss issue cause in my jbosscmp-jdbc.xml I have the
appropriate mappings, as follows:

<relationships>
<ejb-relation>
<ejb-relation-name>parent-child</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>

<ejb-relationship-role-name>parent-has-child</ejb-relationship-role-name>
<fk-constraint>true</fk-constraint>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>

<ejb-relationship-role-name>child-has-parent</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>parentid</field-name>
<column-name>parentid</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
</relationships>

But is still tries to use parent_parentid.

Thanks for the help. I will try posting my problem over on JBoss site

Steve


----- Original Message -----
From: <***@netcom.no>
To: "Steve Knight" <***@hotmail.com>
Cc: <middlegen-***@lists.sourceforge.net>
Sent: Tuesday, February 12, 2002 2:27 AM
Subject: Re: [Middlegen-user] FindByForeignKey failed
Post by a***@netcom.no
----- Original Message -----
Date: Monday, February 11, 2002 7:05 pm
Subject: [Middlegen-user] FindByForeignKey failed
Post by Steve Knight
Hello,
First let me just say that Middlegen 1.0 looks great so far...nice
work Aslak!
Thanks! -And as interest grows, I get more feedback, and the tool gets
-database
-ejb container
Can you send me the deployment descriptors (samples/build/META-
INF/*.xml) and perhaps a screen-shot of Middlegen?
And I'll see if I can help you.
-Aslak
Post by Steve Knight
parent --> parentid, name
child --> childid, name, parentid
where parentid in the child table is the Foreign Key to the parent
table.
The problem occurs when I try to call the cmr accessor method
1 John Smith
java.rmi.ServerException: RemoteException occurred in server
java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'
Why is it calling the foreign key field "parent_parentid" when it
should be just "parentid"? Why is it creating this column name?
Please pardon my ignorance as I am new to both XDoclet and
Middlegen (and EJBs for that matter). All of the relationship
code was generated by Middlegen and I am calling getChilds( ) from
within a remote Parent interface method called getChildrenData( ),
which returns a collection of dataobjects (to the remote client)
representing the parent's associated children.
Any ideas?
Thanks,
Steve
a***@netcom.no
2002-02-12 15:09:16 UTC
Permalink
Hi Steve,

One of two diagnostics:

1) Perhaps the <key-fields> for the relation should have been on the
other <ejb-relationship-role>? (I'm not familiar with JBoss, so I don't
know) Try that, repackage your been and see if it works. If it does,
then it's either a Middlegen or a JBoss problem, and I'll investigate
it further.

2) It's JBoss that screws up for you. As you've pointed out yourself,
there is nothing in the Middlegen/XDoclet generated code (and that
would be jbosscmp-jdbc.xml) that mentions parent_parentid anywhere.

Please get back to me and tell me whether 1) works for you or not.
Well, get back anyway ;-)

Aslak


----- Original Message -----
From: "Steve Knight" <***@hotmail.com>
Date: Tuesday, February 12, 2002 5:01 pm
Subject: Re: [Middlegen-user] FindByForeignKey failed
Post by Steve Knight
Sorry, i forgot to mention that I am using JBoss 3.0 and MySQL.
Now, when I changed the foreign-key column name in my database to
parent_parentid it worked fine. But if I have parentid it
complains that it
java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where
clause'; nested
exc
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where clause'
javax.ejb.EJBException: FindByForeignKey failed
I think this might be a JBoss issue cause in my jbosscmp-jdbc.xml
I have the
<relationships>
<ejb-relation>
<ejb-relation-name>parent-child</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>parent-has-child</ejb-relationship-
role-name>
<fk-constraint>true</fk-constraint>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>child-has-parent</ejb-relationship-
role-name>
<key-fields>
<key-field>
<field-name>parentid</field-name>
<column-name>parentid</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
</relationships>
But is still tries to use parent_parentid.
Thanks for the help. I will try posting my problem over on JBoss site
Steve
----- Original Message -----
Sent: Tuesday, February 12, 2002 2:27 AM
Subject: Re: [Middlegen-user] FindByForeignKey failed
Post by a***@netcom.no
----- Original Message -----
Date: Monday, February 11, 2002 7:05 pm
Subject: [Middlegen-user] FindByForeignKey failed
Post by Steve Knight
Hello,
First let me just say that Middlegen 1.0 looks great so far...nice
work Aslak!
Thanks! -And as interest grows, I get more feedback, and the
tool gets
Post by a***@netcom.no
-database
-ejb container
Can you send me the deployment descriptors (samples/build/META-
INF/*.xml) and perhaps a screen-shot of Middlegen?
And I'll see if I can help you.
-Aslak
Post by Steve Knight
parent --> parentid, name
child --> childid, name, parentid
where parentid in the child table is the Foreign Key to the parent
table.
The problem occurs when I try to call the cmr accessor method
1 John Smith
java.rmi.ServerException: RemoteException occurred in server
java.rmi.ServerException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where
javax.ejb.EJBException: FindByForeignKey failed
Embedded Exception
Column not found: Unknown column 'parent_parentid' in 'where
clause'> >
Post by a***@netcom.no
Post by Steve Knight
Why is it calling the foreign key field "parent_parentid" when it
should be just "parentid"? Why is it creating this column name?
Please pardon my ignorance as I am new to both XDoclet and
Middlegen (and EJBs for that matter). All of the relationship
code was generated by Middlegen and I am calling getChilds( ) from
within a remote Parent interface method called
getChildrenData( ),
Post by a***@netcom.no
Post by Steve Knight
which returns a collection of dataobjects (to the remote client)
representing the parent's associated children.
Any ideas?
Thanks,
Steve
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...