• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [WO45] Problem with a new EOQualifier subclass in Java
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [WO45] Problem with a new EOQualifier subclass in Java


  • Subject: Re: [WO45] Problem with a new EOQualifier subclass in Java
  • From: Max Muller <email@hidden>
  • Date: Tue, 11 Mar 2003 10:45:24 -0800

Hi Labrie,
	Sorry, my 4.5 memory is getting murky. I had to deal quite a bit with
custom qualifiers in 4.5. What you should try is instead of subclassing
EOQualifier, subclass EOSQLQualifier. This I know works, in fact I have
attached an IN qualifier from the 4.5 version of NetStruxr's open
sourced ER frameworks. Hope this helps.

Regards,
	Max
/*
 * Copyright (C) NetStruxr, Inc. All rights reserved.
 *
 * This software is published under the terms of the NetStruxr
 * Public Software License version 0.5, a copy of which has been
 * included with this distribution in the LICENSE.NPL file.  */

/* ERKeyValueQualifierInSubquery.java created by bposokhow on Tue 25-Jul-2000 */
package er.extensions;

import com.apple.yellow.foundation.*;
import com.apple.yellow.eocontrol.*;
import com.apple.yellow.eoaccess.*;
import com.apple.yellow.webobjects.*;

public class ERQualifierInSubquery extends EOSQLQualifier {

    // generates a subquery for the qualifier given in argument
    //
    //   ...  t0.ID in (SELECT t0.ID FROM X WHERE <your qualifier here> ) ..
    //
    //
    // this class can be used to work around the EOF bug where OR
    // queries involving many-to-manies are incorrectly generated
    //
    //
    // It will also generate
    //
    //  ... t0.FOREIGN_KEY_ID in (select t1.ID from X where <your qualifier here>)
    //
    // with the 3 arg constructor

    private EOQualifier _qualifier;
    private EOEntity _entity;
    private EOAttribute _attribute;

    private ERQualifierInSubquery(EOQualifier q,
                                  EOEntity entity) {
        super(entity,null);
        _qualifier=q;
        _entity=entity;
    }

    public ERQualifierInSubquery(EOEntity entity,
                                 EOQualifier q) {

        /* in theory we should be able to accept any qualifier in here
         but for KeyValueQualifiers, they HAVE to end in an attribute it seems
         coveredCounties.state=<State mass> throws */
        this (q,entity);
        _attribute=(EOAttribute)_entity.primaryKeyAttributes().objectAtIndex(0);
    }



    public ERQualifierInSubquery(EOEntity entity,
                                 EOAttribute att,
                                 EOQualifier q) {

        this(q,entity);
        _attribute=att;
    }







    public String sqlStringForSQLExpression(EOSQLExpression e) {
        StringBuffer sb=new StringBuffer();
        sb.append(e.sqlStringForAttribute(_attribute));
        sb.append(" IN ( ");
        EOFetchSpecification fs=new EOFetchSpecification(_entity.name(),
                                                         _qualifier,
                                                         null,
                                                         false,
                                                         true,
                                                         null);
        EOSQLExpression expression=EOSQLExpression.
            selectStatementForAttributes( _entity.primaryKeyAttributes(),
                                           false,
                                           fs,
                                           _entity);

        sb.append(expression.statement());

        sb.append(" ) ");
        return sb.toString();
    }

    public String description() { return " <subquery> '"+_qualifier.toString()+"'"; }
    public String toString() { return description(); }

    /*
     EOF seems to be wanting to clone qualifiers when the are inside an and-or qualifier
     without this method, EOToManyQualifier is cloned into an EOSQLQualifier and the generated SQL is incorrect..
        */
    public Object clone() {
        return new ERQualifierInSubquery(_entity, _qualifier);
    }
}
On Tuesday, March 11, 2003, at 10:15 AM, Labrie, Francis (Liste de
distribution) wrote:

> Hi,
>
>
> Max Muller wrote:
>> 	Is this qualifier being used with an AND or an OR?
>
> 	Yes.
>
>> If so then you actually need to implement the Cloneable
>> interface (not mentioned in the doc anywhere). For some
>> strange reason in the 4.5 code qualifiers need to be
>> cloned when they are used with AND and OR qualifiers on
>> the Java side (not on the ObjC side, go figure).
>
> Yes, Cloneable interface is already implemented on both
> SoundExQualifier and InQualifier.  The SQL query is correctly
> constructed and sent, and the ODBCAdaptor receive all results.
> The problem seem related to WODisplayGroup and maybe memory
> fetch / filtering.  You can check the InQualifier code in
> my other message.
>
>
> Kind regards,
>
> ____________________________________________
> Francis Labrie    email@hidden
> Montreal, Quebec
> Canada
> _______________________________________________
> webobjects-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: [WO45] Problem with a new EOQualifier subclass in Java (From: "Labrie, Francis (Liste de distribution)" <email@hidden>)

  • Prev by Date: Re: simple database login
  • Next by Date: Re: simple database login
  • Previous by thread: RE: [WO45] Problem with a new EOQualifier subclass in Java
  • Next by thread: RE: [WO45] Problem with a new EOQualifier subclass in Java
  • Index(es):
    • Date
    • Thread