db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Harris (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OJB-62) addPathClass in QueryByCriteria does not consider inheritance
Date Wed, 05 Apr 2006 16:41:47 GMT
    [ http://issues.apache.org/jira/browse/OJB-62?page=comments#action_12373394 ] 

Ryan Harris commented on OJB-62:

I've had the same error described in the bug report above.  

Armin reproduced no error because his test case used slightly a different configuration:
Notice in the class descriptor attribute table="tablename" exists in the test case but not
the bug report.

I tried to fix the source code for my own use but didnt have enough time so I just learned
from Armin's successful test case and created an empty table.  It didnt immediately work.
 so I added the expected columns to the class descriptor and to the empty table. The sql generated
by ojb started to work again.

Here is the documentation on the website that doesnt work as written (for me at least):  http://db.apache.org/ojb/docu/guides/advanced-technique.html#Extents
(its line 3 in the example)

> addPathClass in QueryByCriteria does not consider inheritance
> -------------------------------------------------------------
>          Key: OJB-62
>          URL: http://issues.apache.org/jira/browse/OJB-62
>      Project: OJB
>         Type: Bug

>   Components: PB-API
>  Environment: postgresql, ojb 1.0.3
>     Reporter: Kirill Petrov
>      Fix For: 1.0.4

> I guess there is a bug in the addPathClass method. Orirginally I posted it on the mailing
list and then you requested me to submit a new bug on this website:
> here is the code that I have
> public static Collection findModelsByAuthorsName(String aName) {
>     PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>     try{
>       Criteria crit = new Criteria();
>       crit.addLike("sources.author", aName);
>       QueryByCriteria query = new QueryByCriteria(Model.class, crit, true);
>       query.addPathClass("sources", Citation.class);
>       return broker.getCollectionByQuery(query);
>     } finally {
>       broker.close();
>     }
>   }
> when I run it I get an error (below). The problem is that Citation is a superclass that
has a number of classes that implement it. If instead of Citation I use OJBCitation (which
is not extended by any class) then everything works fine.
> Here is the definition of Citation:
> here is what I have:
> <class-descriptor class="edu.uci.ics.sigmoid.Citation">
>   <extent-class class-ref="edu.uci.ics.sigmoid.OJBCitation" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Article" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Book" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Booklet" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Unpublished" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.TechReport" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Proceedings" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.PhDThesis" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.MiscCitation" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.MastersThesis" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Manual" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.InProceedings" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.InCollection" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.InBook" />
>   <extent-class class-ref="edu.uci.ics.sigmoid.Conference" />
> </class-descriptor> 
> Here is the exception I get.
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: createTableAlias2:
path: sources* tableAlias: model_sources_knowledge_source A1
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: Result of getTableAlias():
null A2
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT DISTINCT
A0._id,A0.name,A0.extended_description,A0.license_id,A0.unique_dbid,A0.comment FR\
> OM model A0 INNER JOIN (model_sources_knowledge_source A1 INNER JOIN null A2 ON A1.knowledge_source_id=A2._id)
ON A0._id=A1.model_id WHERE author LIKE ?
> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution
of the query (for edu.uci.ics.sigmoid.OJBModel): ERROR: syntax error at or near \
> "null"
> ERROR: syntax error at or near "null"
> java.sql.SQLException: ERROR: syntax error at or near "null"
>         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
>         at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
>         at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

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

View raw message