Hi Kirill,
Kirill Petrov wrote:
Armin Waibel wrote:
how did you map the sub-classes of Citation.class, do you use
'extent-class' elements in mapping for Citation.class or do you use
'super-references' in the sub-classes?
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>
should I change it somehow?
No, seems ok. So it seems you found a bug.
Do you use OJB1.0.3 or the latest from CVS OJB_1_0_RELEASE branch? If
possible please try with it with the latest from CVS. If you can't or
you have the same problem with latest from CVS, please summarize and
describe the problem in pseudo code, then I will write a test case to
reproduce your problem.
regards,
Armin
Kirill
Kirill Petrov wrote:
Hello guys,
is it indeed a bug or am I doing something wrong?? Please, help.
thanks,
Kirill
you should try using the path class hint:
Criteria crit = new Criteria();
crit.addLike("reactions.name", rName);
QueryByCriteria query = new QueryByCriteria(Model.class, crit1);
query.addPathClass("reactions", BidirectionalReaction.class);
in this case ojb will only use BidirectionalReaction when
processing the relationship "reactions".
there's a test case called PathTest for this feature.
I guess there is a bug in this feature:
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 another 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.
Do you have a fix for this or am I doing something wrong?
[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)
jakob
Kirill Petrov schrieb:
Hello everybody,
Recently, I asked a question how can a query an object having a
property which is a collection of objects. I received an answer,
so, now my query looks like this:
public static Collection findModelsByReactionsName(String rName) {
PersistenceBroker broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
try{
Criteria crit = new Criteria();
crit.addLike("reactions.name", rName);
QueryByCriteria query = new QueryByCriteria(Model.class, crit);
return broker.getCollectionByQuery(query);
} finally {
broker.close();
}
}
Now, I have another problem. There are several subclasses of
Reaction. Those subclasses of course have their own properties.
For example, "BidirectionalReaction" has a property "reverseRate".
I want to query the models by this property which implies that I
am looking only for the models that have BidirectionalReactions in
them. But I don't know how to do that. If I just specify
"reactions.reverseRate" in the query, OJB generates SQL that would
try to query using all the possibe subclasses. The SQL of course
fails since only one table would have a column corresponding to
reverseRate.
How do I write such a query?
thanks a lot,
Kirill
PS
Here is explanation of my object model:
I have an object model in which there are two objects: Model and
Reactiont. This is basically n to m relationship. Model can have a
number of Reactions. Reactions can be in a number of Models.
In Java this is implemented by a Collection property in Model class.
I want to construct a query that allows me to find all the models
that
have a particular reaction in them.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]