I think you're asking the wrong question/query. In my opinion, I think the
right query is
"SELECT o FROM myapp.Product o WHERE o.group.id=3" (and not SELECT o FROM
myapp.Product o WHERE product.group.id=3)

Below you also can find a query of my own that works just fine. Just follow
the same logic:
"SELECT rule FROM
be.realsoftware.datastore.persistence.xml.fraudrule.FraudRule rule WHERE
rule.IdtFraudRule=$1"

Hopefully, it works...and once it works, you will find OQL as wonderful as I
do.
Ciao,
Nico

---

Here is also the code of the whole method where I use OQL:

    public void update(RuleVO ruleVO) throws Exception {
        Query oql;
        QueryResults results = null;
        Database db = null;
        FraudRule fraudRule = null;
        // Open a new database, begin a transaction
        try {
            db = CastorToolkit.getDatabase();
            db.begin();

            oql = db.getOQLQuery("SELECT rule FROM
be.realsoftware.datastore.persistence.xml.fraudrule.FraudRule rule "
                                 + "WHERE rule.IdtFraudRule=$1");
            oql.bind(ruleVO.getIdtFraudRule());
            results = oql.execute();

            while ( results.hasMore() ) {
                fraudRule = (FraudRule) results.next();
                fraudRule.setIdtFraudRule(ruleVO.getIdtFraudRule());
                fraudRule.setShortName(ruleVO.getShortName());
                fraudRule.setDescription(ruleVO.getDescription());
                fraudRule.setActive(ruleVO.getActive());
                fraudRule.setFraudRule(ruleVO.getFraudRule());
            }
            // Commit all changes, close the database
            db.commit();
            oql.close();
            CastorToolkit.close(db);
        }
        catch (QueryException e) {
            if (Logger.isDebugEnabled()) {
                Logger.debug("CallableToolkit", "RuleDAO.update
SQLException");
            }
            throw new DataStoreException(e,
ErrorsProperties._DATABASE_ACCESS,
                                         "Error while executing
RuleDAO.update");
        }
        catch (Exception e) {
            if (Logger.isDebugEnabled()) {
                Logger.debug("CallableToolkit", "RuleDAO.update
DataStoreException");
            }
            throw new DataStoreException(e,
ErrorsProperties._DATABASE_ACCESS,
                                         "Unable to connect to the
database.");
        }
        finally {
            InstanceFactory.getJDBCManagerInstance().closeConnection();
        }
    }


-----Original Message-----
From: Tetley, Paul [mailto:[EMAIL PROTECTED]
Sent: dinsdag 24 juni 2003 11:16
To: [EMAIL PROTECTED]
Subject: [castor-dev] JDO: OQL Question...


In the Castor 0.9.5 examples (the JDO Example) I've the OQL Query Analyzer
GUI tool and tried to run the query:

SELECT o FROM myapp.Product o WHERE product.group.id=3

I get an exception:

org.exolab.castor.jdo.QueryException: An unknown field was requested:
product.group.id (myapp.Product AS prod)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.checkProjection(ParseTreeWalker.ja
va:485)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.checkWhereClause(ParseTreeWalker.j
ava:566)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.checkWhereClause(ParseTreeWalker.j
ava:590)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.checkWhereClause(ParseTreeWalker.j
ava:590)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.checkErrors(ParseTreeWalker.java:2
36)
        at
org.exolab.castor.jdo.oql.ParseTreeWalker.<init>(ParseTreeWalker.java:137)
        at
org.exolab.castor.jdo.engine.OQLQueryImpl.create(OQLQueryImpl.java:275)
...

Am I asking the wrong question (in which case how should the query be
formulated)?

Or is there a problem with my database (HypersonicSQL)?

Or is it a bug?

:-)

TIA
Paul Tetley
AeM Group
Perth, Western Australia

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to