6 Replies Latest reply on Jan 11, 2002 12:18 PM by Adrian Brock

    IN Operator Giving Me Fits

    Tom Mahaffey Newbie

      Using jboss-3 alpha, I can't seem to get the IN operator to give me what I want.

      I have a one to many bidirectional relationship where a country can have many cities. I'm trying to use EJB-QL in an ejbSelect method:



      Find a city by name.

      <query-method>
      <method-name>
      ejbSelectCityByName
      </method-name>
      <method-params>
      <method-param>
      myapp.location.CountryLocal
      </method-param>
      <method-param>
      java.lang.String
      </method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      SELECT OBJECT(cty)
      FROM country AS cnt, IN(cnt.cities) AS cty
      WHERE cnt = ?1 AND
      cty.name = ?2
      </ejb-ql>



      Where country is my abstract-schema-name for a CountryEJB and cities is the cmr-field-name in the ejb-relation.

      Whenever I try to deploy my jar, I get:

      [20:26:18,042,ContainerFactory] Could not deploy file:/opt/nautilus/jboss/deploy/Default/nautilus.jar
      java.lang.IllegalArgumentException: Path element with identifier is not an instance of AbstractSchema: identifier=cty, pathElement=[CMRField: name=cities]
      at org.jboss.ejb.plugins.cmp.jdbc.ejbql.IdentifierManager.getExistingAbstractSchema(IdentifierManager.java:51)
      at org.jboss.ejb.plugins.cmp.jdbc.ejbql.SQLTarget.setSelectPath(SQLTarget.java:130)
      at org.jboss.ejb.plugins.cmp.jdbc.ejbql.EJBQLParser$1.workOn(EJBQLParser.java:59)
      at org.jboss.ejb.plugins.cmp.ejbql.Parser.matchAndAssemble(Parser.java:22)
      at org.jboss.ejb.plugins.cmp.ejbql.Sequence.match(Sequence.java:25)
      at org.jboss.ejb.plugins.cmp.ejbql.Parser.matchAndAssemble(Parser.java:14)
      at org.jboss.ejb.plugins.cmp.ejbql.Parser.soleMatch(Parser.java:48)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLFinderCommand.(JDBCEJBQLFinderCommand.java:56)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLFinderCommand(JDBCCommandFactory.java:99)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.start(JDBCFindEntitiesCommand.java:123)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:139)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:186)
      at org.jboss.ejb.EntityContainer.start(EntityContainer.java:354)
      at org.jboss.ejb.Application.start(Application.java:206)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:382)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:308)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
      at java.lang.reflect.Method.invoke(Method.java:327)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:467)
      at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:444)
      at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:215)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
      at java.lang.reflect.Method.invoke(Method.java:327)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:654)
      at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:327)
      at java.lang.Thread.run(Thread.java:539)





      My biggest problem right now is that I don't understand what "Path element with identifier is not an instance of AbstractSchema" means. I'm trying to select a CityLocal object from the CountryLocal it belongs to and its name. On the other hand, I can deploy a finder method from the CityEJB side:



      Find a city by name.
      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>
      myapp.location.CountryLocal
      </method-param>
      <method-param>
      java.lang.String
      </method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      SELECT OBJECT(c)
      FROM city c
      WHERE c.countryLocal = ?1 AND
      c.name = ?2
      </ejb-ql>



      This works just fine and accomplishes what I want, but my first attempt was using the IN operator...it fails and it seems like I should be able to do this based on EJB-QL examples I've seen.

      Any help or insight much appreciated.