You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Mauricio Montblanch <mm...@uragua.com.uy> on 2004/03/12 20:29:47 UTC

two tables Report Query

Hi,
 
    I am new with ojb and I am having problems with a Report Query that 
involves two tables:
CONVENIO (logica.negocio.Convenio) and GIRO (logica.negocio.Giro).

I am trying  to get  the value of the filed giro but I get a invalid 
column error (I have read the FAQ and the mailing list but I can not 
find a solution)


This is my Repository

    <class-descriptor class="logica.negocio.Convenio" table="CONVENIO">
        <field-descriptor
            name="id"
            column="IDCONVENIO"
            jdbc-type="BIGINT"
            primarykey="true"
            autoincrement="true"
            sequence-name="CONVENIO_ID"
            />

        <field-descriptor
            name="idEmpresa"
            column="IDEMPRESA"
            jdbc-type="BIGINT"
            />

        <field-descriptor
            name="idGiro"
            column="IDGIRO"
            jdbc-type="BIGINT"
            />

        <reference-descriptor name="giro" class-ref="logica.negocio.Giro">
            <foreignkey field-ref="idGiro"/>
        </reference-descriptor>


    ...............................
    ...............................
    ...............................
    ...............................


    <class-descriptor class="logica.negocio.Giro" table="GIRO">
        <field-descriptor
            name="id"
            column="IDGIRO"
            jdbc-type="BIGINT"
            primarykey="true"
            autoincrement="true"
            sequence-name="GIRO_ID"
            />

        <field-descriptor
            name="giro"
            column="GIRO"
            jdbc-type="VARCHAR"
            size="50"
            />

    </class-descriptor>

and this is the Report Query

PersistenceBroker broker = 
PersistenceBrokerFactory.defaultPersistenceBroker();
ReportQueryByCriteria query = 
QueryFactory.newReportQuery(Convenio.getClass(), new Criteria());
query.setColumns(new String[]{"IDCONVENIO","IDEMPRESA","Giro.giro"});
Iterator i=broker.getReportQueryIteratorByQuery(query);




[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException 
during the execution of the query (for a logica.negocio.Convenio): 
ORA-00904: Ivalid column name

ORA-00904: Ivalid column name

java.sql.SQLException: ORA-00904: Ivalid column name

    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:241)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1477)
    at 
oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:677)
    at 
oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2285)
    at ora................


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: two tables Report Query

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi mauricio,

i know the name is misleading but setColumns expects an array of attribute names 
not column names :

 > QueryFactory.newReportQuery(Convenio.getClass(), new Criteria());
 > query.setColumns(new String[]{"IDCONVENIO","IDEMPRESA","Giro.giro"});

and the name of the relationship is 'giro' not 'Giro'. so this one should work:

query.setColumns(new String[]{"id","idEmpresa","giro.giro"});

hth
jakob

Mauricio Montblanch wrote:

> Hi,
> 
>    I am new with ojb and I am having problems with a Report Query that 
> involves two tables:
> CONVENIO (logica.negocio.Convenio) and GIRO (logica.negocio.Giro).
> 
> I am trying  to get  the value of the filed giro but I get a invalid 
> column error (I have read the FAQ and the mailing list but I can not 
> find a solution)
> 
> 
> This is my Repository
> 
>    <class-descriptor class="logica.negocio.Convenio" table="CONVENIO">
>        <field-descriptor
>            name="id"
>            column="IDCONVENIO"
>            jdbc-type="BIGINT"
>            primarykey="true"
>            autoincrement="true"
>            sequence-name="CONVENIO_ID"
>            />
> 
>        <field-descriptor
>            name="idEmpresa"
>            column="IDEMPRESA"
>            jdbc-type="BIGINT"
>            />
> 
>        <field-descriptor
>            name="idGiro"
>            column="IDGIRO"
>            jdbc-type="BIGINT"
>            />
> 
>        <reference-descriptor name="giro" class-ref="logica.negocio.Giro">
>            <foreignkey field-ref="idGiro"/>
>        </reference-descriptor>
> 
> 
>    ...............................
>    ...............................
>    ...............................
>    ...............................
> 
> 
>    <class-descriptor class="logica.negocio.Giro" table="GIRO">
>        <field-descriptor
>            name="id"
>            column="IDGIRO"
>            jdbc-type="BIGINT"
>            primarykey="true"
>            autoincrement="true"
>            sequence-name="GIRO_ID"
>            />
> 
>        <field-descriptor
>            name="giro"
>            column="GIRO"
>            jdbc-type="VARCHAR"
>            size="50"
>            />
> 
>    </class-descriptor>
> 
> and this is the Report Query
> 
> PersistenceBroker broker = 
> PersistenceBrokerFactory.defaultPersistenceBroker();
> ReportQueryByCriteria query = 
> QueryFactory.newReportQuery(Convenio.getClass(), new Criteria());
> query.setColumns(new String[]{"IDCONVENIO","IDEMPRESA","Giro.giro"});
> Iterator i=broker.getReportQueryIteratorByQuery(query);
> 
> 
> 
> 
> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException 
> during the execution of the query (for a logica.negocio.Convenio): 
> ORA-00904: Ivalid column name
> 
> ORA-00904: Ivalid column name
> 
> java.sql.SQLException: ORA-00904: Ivalid column name
> 
>    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
>    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:241)
>    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
>    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1477)
>    at 
> oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:677)
>    at 
> oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2285) 
> 
>    at ora................
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org