You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Frank <fa...@hotmail.com> on 2007/02/14 16:59:05 UTC

How to query a relationship

Hello,

I have as AS400 relationship defined between two tables.
I need to include a column from the second table in my list.

Here is my error:
No matching getter method found for property Pcldds on class 
stemc.cayenne.as400.Bsypemp

Thanks
Frank

Here is my query:
Expression e = ExpressionFactory.matchDbExp

(Bsypemp.EMHSPPOUND_PK_COLUMN, new Integer(1));

e = e.andExp(ExpressionFactory.likeExp(Bsypemp.EMYLNM_PROPERTY, lname

+"%"));


SelectQuery query = new SelectQuery(Bsypemp.class,e);

List records = context.performQuery(query);

Here is my first table:
package stemc.cayenne.as400.auto;


/** Class _Bsypemp was generated by Cayenne.

* It is probably a good idea to avoid changing this class manually,

* since it may be overwritten next time code is regenerated.

* If you need to make any customizations, please use subclass.

*/

public class _Bsypemp extends org.objectstyle.cayenne.CayenneDataObject {


public static final String E_MEMPPOUND_PROPERTY = "eMEMPpound";

public static final String E_MHSPPOUND_PROPERTY = "eMHSPpound";

public static final String E_MWPHPOUND_PROPERTY = "eMWPHpound";

public static final String EMDEP4_PROPERTY = "emdep4";

public static final String EMYFNM_PROPERTY = "emyfnm";

public static final String EMYLNM_PROPERTY = "emylnm";


public static final String EMEMPPOUND_PK_COLUMN = "EMEMP#";

public static final String EMHSPPOUND_PK_COLUMN = "EMHSP#";


public void setEMEMPpound(java.math.BigDecimal eMEMPpound) {

writeProperty("eMEMPpound", eMEMPpound);

}

public java.math.BigDecimal getEMEMPpound() {

return (java.math.BigDecimal)readProperty("eMEMPpound");

}



public void setEMHSPpound(java.math.BigDecimal eMHSPpound) {

writeProperty("eMHSPpound", eMHSPpound);

}

public java.math.BigDecimal getEMHSPpound() {

return (java.math.BigDecimal)readProperty("eMHSPpound");

}



public void setEMWPHpound(java.math.BigDecimal eMWPHpound) {

writeProperty("eMWPHpound", eMWPHpound);

}

public java.math.BigDecimal getEMWPHpound() {

return (java.math.BigDecimal)readProperty("eMWPHpound");

}



public void setEmdep4(java.math.BigDecimal emdep4) {

writeProperty("emdep4", emdep4);

}

public java.math.BigDecimal getEmdep4() {

return (java.math.BigDecimal)readProperty("emdep4");

}



public void setEmyfnm(String emyfnm) {

writeProperty("emyfnm", emyfnm);

}

public String getEmyfnm() {

return (String)readProperty("emyfnm");

}



public void setEmylnm(String emylnm) {

writeProperty("emylnm", emylnm);

}

public String getEmylnm() {

return (String)readProperty("emylnm");

}



}

Here is my second table

package stemc.cayenne.as400.auto;


/** Class _Bprppcp was generated by Cayenne.

* It is probably a good idea to avoid changing this class manually,

* since it may be overwritten next time code is regenerated.

* If you need to make any customizations, please use subclass.

*/

public class _Bprppcp extends org.objectstyle.cayenne.CayenneDataObject {


public static final String P_CHSPPOUND_PROPERTY = "pCHSPpound";

public static final String PCDEP4_PROPERTY = "pcdep4";

public static final String PCLDDS_PROPERTY = "pcldds";


public static final String PCDEP4_PK_COLUMN = "PCDEP4";

public static final String PCHSPPOUND_PK_COLUMN = "PCHSP#";


public void setPCHSPpound(java.math.BigDecimal pCHSPpound) {

writeProperty("pCHSPpound", pCHSPpound);

}

public java.math.BigDecimal getPCHSPpound() {

return (java.math.BigDecimal)readProperty("pCHSPpound");

}



public void setPcdep4(java.math.BigDecimal pcdep4) {

writeProperty("pcdep4", pcdep4);

}

public java.math.BigDecimal getPcdep4() {

return (java.math.BigDecimal)readProperty("pcdep4");

}



public void setPcldds(String pcldds) {

writeProperty("pcldds", pcldds);

}

public String getPcldds() {

return (String)readProperty("pcldds");

}



}


Re: How to query a relationship

Posted by Frank <fa...@hotmail.com>.
Here is my original query string:

String sql = "SELECT BSYDTAA.BSYPEMP.EMYLNM, BSYDTAA.BSYPEMP.EMYFNM, 
BSYDTAC.BPRPPCP.PCDEP4, BSYDTAC.BPRPPCP.PCLDDS, BSYDTAA.BSYPEMP.EMEMP# AS 
EMEMP, BSYDTAA.BSYPEMP.EMWPH# AS WPHONE FROM BSYDTAA.BSYPEMP, 
BSYDTAC.BPRPPCP WHERE BSYDTAA.BSYPEMP.EMHSP# = BSYDTAC.BPRPPCP.PCHSP# AND 
BSYDTAA.BSYPEMP.EMDEP4 = BSYDTAC.BPRPPCP.PCDEP4 AND (BSYDTAA.BSYPEMP.EMHSP# 
IN (1,5)) AND (BSYDTAA.BSYPEMP.EMDOT=0)";

sql += " AND EMYLNM like ?";

sql += " AND EMYFNM like ?";

sql += " ORDER BY EMYLNM";



Thanks

Frank

----- Original Message ----- 
From: "Michael Gentry" <bl...@gmail.com>
To: <us...@cayenne.apache.org>
Sent: Thursday, February 15, 2007 10:06 AM
Subject: Re: How to query a relationship


> When you were using JDBC, did you have something like a right outer
> join?  (An optional relationship?)
>
> /dev/mrg
>
>
> On 2/15/07, Frank <fa...@hotmail.com> wrote:
>> Hi Michael,
>>
>> I looked at your tutorial in motion, (it has hellped me understand 
>> cayenne
>> better)
>> and have tried setting one to many on the department table.
>>
>> It still fails trying to query department # = 0 and hsp#=5
>> because there is no match in th erelated table.
>>
>> Should I just filter out records where department # is 0?
>> I did not have this problem when I did a jdbc join prior to using 
>> cayenne.
>>
>> I am kinda lost at how to resolve this.
>>
>> Regards,
>>
>> Frank
>>
>>
> 


Re: How to query a relationship

Posted by Michael Gentry <bl...@gmail.com>.
When you were using JDBC, did you have something like a right outer
join?  (An optional relationship?)

/dev/mrg


On 2/15/07, Frank <fa...@hotmail.com> wrote:
> Hi Michael,
>
> I looked at your tutorial in motion, (it has hellped me understand cayenne
> better)
> and have tried setting one to many on the department table.
>
> It still fails trying to query department # = 0 and hsp#=5
> because there is no match in th erelated table.
>
> Should I just filter out records where department # is 0?
> I did not have this problem when I did a jdbc join prior to using cayenne.
>
> I am kinda lost at how to resolve this.
>
> Regards,
>
> Frank
>
>

Re: How to query a relationship

Posted by Frank <fa...@hotmail.com>.
Hi Michael,

I looked at your tutorial in motion, (it has hellped me understand cayenne 
better)
and have tried setting one to many on the department table.

It still fails trying to query department # = 0 and hsp#=5
because there is no match in th erelated table.

Should I just filter out records where department # is 0?
I did not have this problem when I did a jdbc join prior to using cayenne.

I am kinda lost at how to resolve this.

Regards,

Frank 


Re: How to query a relationship

Posted by Frank <fa...@hotmail.com>.
I traced this to the first table bsypemp has many records where the 
department #  (emdep4) is 0
So I think cayenne is trying to join these records to bprppcp and fails.

By join is:
bsypemp->emhsp# to brpppcp->pchsp#
bsypemp->emdep4 to brpppcp->pcdep4

dep4 is the department #

Thanks
Frank
----- Original Message ----- 
From: "Michael Gentry" <bl...@gmail.com>
To: <us...@cayenne.apache.org>
Sent: Thursday, February 15, 2007 9:08 AM
Subject: Re: How to query a relationship


> Well, the error message:
>
> No matching getter method found for property Pcldds on class
> stemc.cayenne.as400.Bsypemp
>
> is indeed correct, because that property is in your Bprppcp class.  I
> didn't see anything else initially in your code that helped me
> understand why you got that, but it is obvious that Cayenne is trying
> to look at Bsypemp instead of Bprppcp for that value (and it is in
> Bprppcp according to your code).  You could try checking the model,
> etc.  If you need more help for relationships, there are several
> documentation pages that talk about constructing them and I do a fair
> number of them in the Cayenne In Motion example.
>
> /dev/mrg
>
>
> On 2/14/07, Frank <fa...@hotmail.com> wrote:
>> Hello,
>>
>> I have as AS400 relationship defined between two tables.
>> I need to include a column from the second table in my list.
>>
>> Here is my error:
>> No matching getter method found for property Pcldds on class
>> stemc.cayenne.as400.Bsypemp
>>
>> Thanks
>> Frank
>>
>> Here is my query:
>> Expression e = ExpressionFactory.matchDbExp
>>
>> (Bsypemp.EMHSPPOUND_PK_COLUMN, new Integer(1));
>>
>> e = e.andExp(ExpressionFactory.likeExp(Bsypemp.EMYLNM_PROPERTY, lname
>>
>> +"%"));
>>
>>
>> SelectQuery query = new SelectQuery(Bsypemp.class,e);
>>
>> List records = context.performQuery(query);
>>
>> Here is my first table:
>> package stemc.cayenne.as400.auto;
>>
>>
>> /** Class _Bsypemp was generated by Cayenne.
>>
>> * It is probably a good idea to avoid changing this class manually,
>>
>> * since it may be overwritten next time code is regenerated.
>>
>> * If you need to make any customizations, please use subclass.
>>
>> */
>>
>> public class _Bsypemp extends org.objectstyle.cayenne.CayenneDataObject {
>>
>>
>> public static final String E_MEMPPOUND_PROPERTY = "eMEMPpound";
>>
>> public static final String E_MHSPPOUND_PROPERTY = "eMHSPpound";
>>
>> public static final String E_MWPHPOUND_PROPERTY = "eMWPHpound";
>>
>> public static final String EMDEP4_PROPERTY = "emdep4";
>>
>> public static final String EMYFNM_PROPERTY = "emyfnm";
>>
>> public static final String EMYLNM_PROPERTY = "emylnm";
>>
>>
>> public static final String EMEMPPOUND_PK_COLUMN = "EMEMP#";
>>
>> public static final String EMHSPPOUND_PK_COLUMN = "EMHSP#";
>>
>>
>> public void setEMEMPpound(java.math.BigDecimal eMEMPpound) {
>>
>> writeProperty("eMEMPpound", eMEMPpound);
>>
>> }
>>
>> public java.math.BigDecimal getEMEMPpound() {
>>
>> return (java.math.BigDecimal)readProperty("eMEMPpound");
>>
>> }
>>
>>
>>
>> public void setEMHSPpound(java.math.BigDecimal eMHSPpound) {
>>
>> writeProperty("eMHSPpound", eMHSPpound);
>>
>> }
>>
>> public java.math.BigDecimal getEMHSPpound() {
>>
>> return (java.math.BigDecimal)readProperty("eMHSPpound");
>>
>> }
>>
>>
>>
>> public void setEMWPHpound(java.math.BigDecimal eMWPHpound) {
>>
>> writeProperty("eMWPHpound", eMWPHpound);
>>
>> }
>>
>> public java.math.BigDecimal getEMWPHpound() {
>>
>> return (java.math.BigDecimal)readProperty("eMWPHpound");
>>
>> }
>>
>>
>>
>> public void setEmdep4(java.math.BigDecimal emdep4) {
>>
>> writeProperty("emdep4", emdep4);
>>
>> }
>>
>> public java.math.BigDecimal getEmdep4() {
>>
>> return (java.math.BigDecimal)readProperty("emdep4");
>>
>> }
>>
>>
>>
>> public void setEmyfnm(String emyfnm) {
>>
>> writeProperty("emyfnm", emyfnm);
>>
>> }
>>
>> public String getEmyfnm() {
>>
>> return (String)readProperty("emyfnm");
>>
>> }
>>
>>
>>
>> public void setEmylnm(String emylnm) {
>>
>> writeProperty("emylnm", emylnm);
>>
>> }
>>
>> public String getEmylnm() {
>>
>> return (String)readProperty("emylnm");
>>
>> }
>>
>>
>>
>> }
>>
>> Here is my second table
>>
>> package stemc.cayenne.as400.auto;
>>
>>
>> /** Class _Bprppcp was generated by Cayenne.
>>
>> * It is probably a good idea to avoid changing this class manually,
>>
>> * since it may be overwritten next time code is regenerated.
>>
>> * If you need to make any customizations, please use subclass.
>>
>> */
>>
>> public class _Bprppcp extends org.objectstyle.cayenne.CayenneDataObject {
>>
>>
>> public static final String P_CHSPPOUND_PROPERTY = "pCHSPpound";
>>
>> public static final String PCDEP4_PROPERTY = "pcdep4";
>>
>> public static final String PCLDDS_PROPERTY = "pcldds";
>>
>>
>> public static final String PCDEP4_PK_COLUMN = "PCDEP4";
>>
>> public static final String PCHSPPOUND_PK_COLUMN = "PCHSP#";
>>
>>
>> public void setPCHSPpound(java.math.BigDecimal pCHSPpound) {
>>
>> writeProperty("pCHSPpound", pCHSPpound);
>>
>> }
>>
>> public java.math.BigDecimal getPCHSPpound() {
>>
>> return (java.math.BigDecimal)readProperty("pCHSPpound");
>>
>> }
>>
>>
>>
>> public void setPcdep4(java.math.BigDecimal pcdep4) {
>>
>> writeProperty("pcdep4", pcdep4);
>>
>> }
>>
>> public java.math.BigDecimal getPcdep4() {
>>
>> return (java.math.BigDecimal)readProperty("pcdep4");
>>
>> }
>>
>>
>>
>> public void setPcldds(String pcldds) {
>>
>> writeProperty("pcldds", pcldds);
>>
>> }
>>
>> public String getPcldds() {
>>
>> return (String)readProperty("pcldds");
>>
>> }
>>
>>
>>
>> }
>>
>>
> 


Re: How to query a relationship

Posted by Michael Gentry <bl...@gmail.com>.
Well, the error message:

No matching getter method found for property Pcldds on class
stemc.cayenne.as400.Bsypemp

is indeed correct, because that property is in your Bprppcp class.  I
didn't see anything else initially in your code that helped me
understand why you got that, but it is obvious that Cayenne is trying
to look at Bsypemp instead of Bprppcp for that value (and it is in
Bprppcp according to your code).  You could try checking the model,
etc.  If you need more help for relationships, there are several
documentation pages that talk about constructing them and I do a fair
number of them in the Cayenne In Motion example.

/dev/mrg


On 2/14/07, Frank <fa...@hotmail.com> wrote:
> Hello,
>
> I have as AS400 relationship defined between two tables.
> I need to include a column from the second table in my list.
>
> Here is my error:
> No matching getter method found for property Pcldds on class
> stemc.cayenne.as400.Bsypemp
>
> Thanks
> Frank
>
> Here is my query:
> Expression e = ExpressionFactory.matchDbExp
>
> (Bsypemp.EMHSPPOUND_PK_COLUMN, new Integer(1));
>
> e = e.andExp(ExpressionFactory.likeExp(Bsypemp.EMYLNM_PROPERTY, lname
>
> +"%"));
>
>
> SelectQuery query = new SelectQuery(Bsypemp.class,e);
>
> List records = context.performQuery(query);
>
> Here is my first table:
> package stemc.cayenne.as400.auto;
>
>
> /** Class _Bsypemp was generated by Cayenne.
>
> * It is probably a good idea to avoid changing this class manually,
>
> * since it may be overwritten next time code is regenerated.
>
> * If you need to make any customizations, please use subclass.
>
> */
>
> public class _Bsypemp extends org.objectstyle.cayenne.CayenneDataObject {
>
>
> public static final String E_MEMPPOUND_PROPERTY = "eMEMPpound";
>
> public static final String E_MHSPPOUND_PROPERTY = "eMHSPpound";
>
> public static final String E_MWPHPOUND_PROPERTY = "eMWPHpound";
>
> public static final String EMDEP4_PROPERTY = "emdep4";
>
> public static final String EMYFNM_PROPERTY = "emyfnm";
>
> public static final String EMYLNM_PROPERTY = "emylnm";
>
>
> public static final String EMEMPPOUND_PK_COLUMN = "EMEMP#";
>
> public static final String EMHSPPOUND_PK_COLUMN = "EMHSP#";
>
>
> public void setEMEMPpound(java.math.BigDecimal eMEMPpound) {
>
> writeProperty("eMEMPpound", eMEMPpound);
>
> }
>
> public java.math.BigDecimal getEMEMPpound() {
>
> return (java.math.BigDecimal)readProperty("eMEMPpound");
>
> }
>
>
>
> public void setEMHSPpound(java.math.BigDecimal eMHSPpound) {
>
> writeProperty("eMHSPpound", eMHSPpound);
>
> }
>
> public java.math.BigDecimal getEMHSPpound() {
>
> return (java.math.BigDecimal)readProperty("eMHSPpound");
>
> }
>
>
>
> public void setEMWPHpound(java.math.BigDecimal eMWPHpound) {
>
> writeProperty("eMWPHpound", eMWPHpound);
>
> }
>
> public java.math.BigDecimal getEMWPHpound() {
>
> return (java.math.BigDecimal)readProperty("eMWPHpound");
>
> }
>
>
>
> public void setEmdep4(java.math.BigDecimal emdep4) {
>
> writeProperty("emdep4", emdep4);
>
> }
>
> public java.math.BigDecimal getEmdep4() {
>
> return (java.math.BigDecimal)readProperty("emdep4");
>
> }
>
>
>
> public void setEmyfnm(String emyfnm) {
>
> writeProperty("emyfnm", emyfnm);
>
> }
>
> public String getEmyfnm() {
>
> return (String)readProperty("emyfnm");
>
> }
>
>
>
> public void setEmylnm(String emylnm) {
>
> writeProperty("emylnm", emylnm);
>
> }
>
> public String getEmylnm() {
>
> return (String)readProperty("emylnm");
>
> }
>
>
>
> }
>
> Here is my second table
>
> package stemc.cayenne.as400.auto;
>
>
> /** Class _Bprppcp was generated by Cayenne.
>
> * It is probably a good idea to avoid changing this class manually,
>
> * since it may be overwritten next time code is regenerated.
>
> * If you need to make any customizations, please use subclass.
>
> */
>
> public class _Bprppcp extends org.objectstyle.cayenne.CayenneDataObject {
>
>
> public static final String P_CHSPPOUND_PROPERTY = "pCHSPpound";
>
> public static final String PCDEP4_PROPERTY = "pcdep4";
>
> public static final String PCLDDS_PROPERTY = "pcldds";
>
>
> public static final String PCDEP4_PK_COLUMN = "PCDEP4";
>
> public static final String PCHSPPOUND_PK_COLUMN = "PCHSP#";
>
>
> public void setPCHSPpound(java.math.BigDecimal pCHSPpound) {
>
> writeProperty("pCHSPpound", pCHSPpound);
>
> }
>
> public java.math.BigDecimal getPCHSPpound() {
>
> return (java.math.BigDecimal)readProperty("pCHSPpound");
>
> }
>
>
>
> public void setPcdep4(java.math.BigDecimal pcdep4) {
>
> writeProperty("pcdep4", pcdep4);
>
> }
>
> public java.math.BigDecimal getPcdep4() {
>
> return (java.math.BigDecimal)readProperty("pcdep4");
>
> }
>
>
>
> public void setPcldds(String pcldds) {
>
> writeProperty("pcldds", pcldds);
>
> }
>
> public String getPcldds() {
>
> return (String)readProperty("pcldds");
>
> }
>
>
>
> }
>
>