Hello everyone,

I came accross a strange OQL to SQL translation.

I'm trying to do this :
oql = db.getOQLQuery( "SELECT a FROM net.talath.server.data.Action a WHERE
a.player.money = $1 " );
oql.bind(0);

And I get the following exception :
java.sql.SQLException: Column not found: ID in statement [SELECT
action_queue.id,action_queue.player_id,action_queue.data FROM
player,action_queue WHERE action_queue.player_id=player_0.id AND
player_0.money = 0]
        at org.hsqldb.Trace.getError(Trace.java:180)
        at org.hsqldb.jdbcResultSet.<init>(jdbcResultSet.java:2645)
        at
org.hsqldb.jdbcConnection.executeStandalone(jdbcConnection.java:994)
        at org.hsqldb.jdbcConnection.execute(jdbcConnection.java:721)
        at org.hsqldb.jdbcStatement.fetchResult(jdbcStatement.java:686)
        at org.hsqldb.jdbcStatement.executeQuery(jdbcStatement.java:68)
        at
org.hsqldb.jdbcPreparedStatement.executeQuery(jdbcPreparedStatement.java:133
)
        at
org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.execute(SQLEngine.java:1584)
        at
org.exolab.castor.persist.TransactionContext.query(TransactionContext.java:6
44)
        at
org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:458)
        at
org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:405)
        at net.talath.server.data.test.JDOTest.main(JDOTest.java:82)

Here is important parts of my mapping.xml :
  <class name="net.talath.server.data.Player" identity="id"
key-generator="high-low">
    <map-to table="player" xml="player"/>
    <field name="id">
      <sql name="id"/>
    </field>
    <field name="nickname" type="string">
      <sql name="nickname" type="char" dirty="check"/>
    </field>
    <field name="money" type="integer">
      <sql name="money" type="integer"/>
    </field>
    <field name="actions" type="net.talath.server.data.Action"
required="false" collection="collection">
      <sql many-key="player_id"/>
    </field>
  </class>
  <class name="net.talath.server.data.Action" identity="id"
key-generator="high-low">
    <map-to table="action_queue" xml="action"/>
    <field name="id">
      <sql name="id"/>
    </field>
    <field name="player" type="net.talath.server.data.Player">
      <sql name="player_id"/>
    </field>
    <field name="data" type="string">
      <sql name="data" type="char" dirty="ignore"/>
    </field>
  </class>

And my tables schema (in SQL) :
create table player (
    id              int not null,
    nickname        varchar(32) not null,
    password        varchar(32) not null,
    email           varchar(64) not null,
    kingdom_name    varchar(32) not null,
    money           int not null
);
create unique index player_pk on player ( id );
create table action_queue (
    id              int not null,
    data            varchar(4096) not null,
    player_id       int not null
);
create unique index action_pk on action_queue ( id );

Why did "player" table become "player_0" in OQL to SQL translation ?!

Lunar.

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

Reply via email to