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 Alen Ribic <al...@mweb.co.za> on 2003/08/21 23:38:02 UTC
Need JOIN
Hi All
I have a single Category object.
This Category object contains a collection of Products of type Vector.
Product objects contain a boolean field named 'activate'.
I have a method that returns a single category with all products in it's
category by category PK.
Everything is fine as is but as soon as I try to specify a product specific
criteria, I get an exception that such column does not exist. Column I wish
to use as my criteria (WHERE clause) is 'activate'.
I was thinking that the category would be joining onto all applicable
products but that doesn't seem to be the case. It must be executing separate
sql statements.
I which to use criteria:
query = "<cat-specific-field>.id = 3 AND <prod-specific-field>.activate = 1"
as follows:
...
crt.addSql(query);
QueryByCriteria queryByCriteria =
QueryFactory.newQuery(Category.class, crt, true);
Collection results = broker.getCollectionByQuery(queryByCriteria);
my repository <class-descriptor/>'s:
<class-descriptor
class="com.baroko.ebiz.model.Product"
table="product"
>
<field-descriptor id="8"
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="9"
name="name"
column="name"
jdbc-type="VARCHAR"
/>
<field-descriptor id="10"
name="price"
column="price"
jdbc-type="FLOAT"
/>
<field-descriptor id="11"
name="stock"
column="stock"
jdbc-type="SMALLINT"
/>
<field-descriptor id="12"
name="description"
column="description"
jdbc-type="VARCHAR"
/>
<field-descriptor id="13"
name="productImage"
column="productImage"
jdbc-type="VARCHAR"
/>
<field-descriptor id="14"
name="activate"
column="activate"
jdbc-type="BIT"
/>
<field-descriptor id="15"
name="categoryId"
column="categoryId"
jdbc-type="SMALLINT"
/>
</class-descriptor>
<class-descriptor
class="com.baroko.ebiz.model.Category"
table="category"
>
<field-descriptor id="16"
name="id"
column="id"
jdbc-type="SMALLINT"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="17"
name="name"
column="name"
jdbc-type="VARCHAR"
/>
<field-descriptor id="18"
name="description"
column="description"
jdbc-type="VARCHAR"
/>
<collection-descriptor
name="allProductsForCategory"
element-class-ref="com.baroko.ebiz.model.Product"
orderby="name"
>
<inverse-foreignkey field-ref="categoryId"/>
</collection-descriptor>
</class-descriptor>
Any help, thx
--Alen
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Prefetched relationships /performance
Posted by Joerg Lensing <in...@softcon-lensing.de>.
hi all,
when querying object "partnerPO"[100 tablerows] with a collection of
"addresses" [each partner has ONE address now, later more]
the query needs 8 to 10 seconds, depending on the query I use. With
dynamic proxy, the query needs 8 seconds, with using
prefetched relationships (without the proxy), the query needs 12 seconds.
For pref.rel. I use
QueryByCriteria query = new QueryByCriteria(PartnerPO.class, null);
query.addPrefetchedRelationship("allAddresses");
Collection allPartner = broker.getCollectionByQuery(query);
Is this the expected time for this configuration?
joerg
OJB rc4
MySQL,
sdk 1.4.0
768 RAM
2,5 Ghz P4
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org