Forgot one more thing...
Looking at SQL generated by OJB, things look perfect from there.

SELECT DISTINCT A0.description,A0.name,A0.id FROM category A0 WHERE id like
'%' order by name

So, it is looking in Category table, but it's returning Product object(s) as
result.
No idea... :)

--Alen


----- Original Message -----
From: "Alen Ribic" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Sunday, June 15, 2003 11:27 PM
Subject: Help, wrong table being looked up!


> Hi Everyone,
>
> I seem to be getting a strange problem in my persistence mechanism using
> OJB.
> I'm using OJB ver: 1.0 rc2.
>
> I have two value objects named Category and Product. Each have own DB
table
> there are mapped to. (same table names as class names)
> Both have common fields (Id, description) hence such classes in my system
> inherit common fields from superclass BaseBusinessBean.
>
>
> Message I get from the log is:
>
> 0     WARN  [Thread-4] singlevm.PersistenceBrokerImpl - Candidate object
> [[1] Product test 01                         price: 12.55
stock:
> 8] class
>  [com.baroko.ebiz.model.Product] is not a subtype of
> [com.baroko.ebiz.model.Cate
> gory] or any type of proxy. NOT INCLUDED in result collection
>
>
> As you can see above, OJB is pulling info from the wrong table. (In this
> case Product table instead of Category table)
> It did the right thing with regards to the identity field. There is only
one
> Id so far in Category table and that's Id: 1. But it looked up the Id: 1
in
> Product instead of Category table.
> So, I got results for row where Id = 1 from Product instead of Category
> table.
>
> Here is my code snippet...
> ...
> broker set here..
> ...
> public List apply(Object query)
>   throws PersistenceException {
>   ArrayList categoryList = null;
>   try {
>     if (!(query instanceof String))
>       throw new PersistenceException(
>         Constants.PERSISTENCE_LIST_FAILED_INVALID_QUERY);
>    Criteria crt = new Criteria();
>    crt.addSql((String)query);
>    QueryByCriteria queryByCriteria =
>      QueryFactory.newQuery(Category.class, crt, true);
>    Collection results = broker.getCollectionByQuery(queryByCriteria);
>    categoryList = new ArrayList(results);
>   } catch(Exception ex) {
>     throw new PersistenceException(
>      Constants.PERSISTENCE_LIST_FAILED);
>   }
>   return (List)categoryList;
> }
>
>
>
> Lastly the repository mappings...
>
> <!-- Definitions... -->
> <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"
> />
> </class-descriptor>
>
>
> <class-descriptor
>   class="com.baroko.ebiz.model.Category"
>   table="category"
> >
> <field-descriptor id="13"
>   name="id"
>   column="id"
>   jdbc-type="SMALLINT"
>   primarykey="true"
>   autoincrement="true"
> />
> <field-descriptor id="14"
>   name="name"
>   column="name"
>   jdbc-type="VARCHAR"
> />
> <field-descriptor id="15"
>   name="description"
>   column="description"
>   jdbc-type="VARCHAR"
> />
> </class-descriptor>
>
> <class-descriptor
>   class="com.baroko.ebiz.model.BaseBusinessBean"
> >
>   <extent-class class-ref="com.baroko.ebiz.model.Category" />
>   <extent-class class-ref="com.baroko.ebiz.model.Product" />
> </class-descriptor>
>
>
> Note that I can get the list of products with no problems with almost an
> identical method as one above for category list.
>
> Sorry for inconvenience to anyone, if this is maybe some stupid problem on
> my side.
> I just can't spot anything that would be causing this problem especially
> when it works fine with product list.
>
> Thanks
> --Alen
>
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to