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/06/18 01:19:05 UTC
Collection of objects cached or something
Hi all
I seem to have a bit of an issue with my objects getting cached that are
retrieved from persistence storage using OJB.
I have a Category & Product tables.
Category bean contains getter method that retrieves a Vector of products
that belong to that Category. Product class contains categoryId field as FK
indicator.
My repository_user.xml contains "collection-descriptor" in Category
class/table mapping to Product table FK.
<collection-descriptor
name="allProductsForCategory"
element-class-ref="com.baroko.ebiz.model.Product"
>
<inverse-foreignkey field-ref="categoryId"/>
</collection-descriptor>
Now all this works in my application, but when it comes to adding a new
value object or deleting an existing one, the action gets performed in the
DB but doesn't reflect in my system (Only when I restart my application will
change show). It appears that the method I call returns relevant Category
but when I call getAllProductsForCategory() on it, it returns the same
Vector as before. It should return Vector of Products with changes reflected
in DB.
Note as I said this issue only is applicable to insert and delete statements
not update!
When I do an update on my value object, it reflects the change in my system.
Strange...:)
What could the problem be?
Any help will be much appreciated.
--Alen
Re: Collection of objects cached or something
Posted by Alen Ribic <al...@mweb.co.za>.
Forgot the code...sent this post late last night :)
<snippet>
public ActionForward execute(...) throws Exception {
Command cm = new CMListCatItems(broker);
String sqlCriteria = getCriteria(request.getParameter("id"));
Category cat = (Category)cm.execute(sqlCriteria);
/*
* getAllProductForCategory() returns Vector
* this Vector still will contain my old data after change */
request.setAttribute("productList",
cat.getAllProductForCategory());
// return to some froward page
}
public class CMListCatItems extends AbstractCommand {
public CMListItems(PersistenceBroker broker) {
super(broker);
}
public Object execute(Object criteria)
throws BusinessExceptionOfSomeSort {
Category cat = null;
try {
Criteria crt = new Criteria();
crt.addSql(/*chk if String...*/(String)criteria);
Query q = new QueryByCriteria(Category.class, crt, true);
cat = (Category)broker.getObjectByQuery(q));
} catch(...) {
//...
}
return cat;
}
//...other commands
}
</snippet>
snippet of descriptors...
<class-descriptor
class="com.baroko.ebiz.model.Category"
table="category">
<!-- field descriptors -->
<collection-descriptor
name="allProductsForCategory"
element-class-ref="com.baroko.ebiz.model.Product"
<inverse-foreignkey field-ref="categoryId"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="com.baroko.ebiz.model.Product"
table="product">
<!-- field descriptors including one for FK categoryId -->
</class-descriptor>
Any typos, let me know. :)
Hope this is sufficient enough to have a clearer view as what is going on in
my code.
Thanks
--Alen
----- Original Message -----
From: "Thomas Mahler" <th...@web.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Wednesday, June 18, 2003 7:39 AM
Subject: Re: Collection of objects cached or something
> please post the code snippet that provokes this problem.
> I have no idea what could be wrong here.
>
> All things you describe are covered by testcases...
>
>
> cheers,
> Thomas
>
> Alen Ribic wrote:
> > Hi all
> >
> > I seem to have a bit of an issue with my objects getting cached that are
> > retrieved from persistence storage using OJB.
> >
> > I have a Category & Product tables.
> > Category bean contains getter method that retrieves a Vector of products
> > that belong to that Category. Product class contains categoryId field as
FK
> > indicator.
> > My repository_user.xml contains "collection-descriptor" in Category
> > class/table mapping to Product table FK.
> >
> > <collection-descriptor
> > name="allProductsForCategory"
> > element-class-ref="com.baroko.ebiz.model.Product"
> >
> > <inverse-foreignkey field-ref="categoryId"/>
> > </collection-descriptor>
> >
> > Now all this works in my application, but when it comes to adding a new
> > value object or deleting an existing one, the action gets performed in
the
> > DB but doesn't reflect in my system (Only when I restart my application
will
> > change show). It appears that the method I call returns relevant
Category
> > but when I call getAllProductsForCategory() on it, it returns the same
> > Vector as before. It should return Vector of Products with changes
reflected
> > in DB.
> >
> > Note as I said this issue only is applicable to insert and delete
statements
> > not update!
> > When I do an update on my value object, it reflects the change in my
system.
> > Strange...:)
> >
> > What could the problem be?
> > Any help will be much appreciated.
> >
> > --Alen
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
Re: Collection of objects cached or something
Posted by Thomas Mahler <th...@web.de>.
please post the code snippet that provokes this problem.
I have no idea what could be wrong here.
All things you describe are covered by testcases...
cheers,
Thomas
Alen Ribic wrote:
> Hi all
>
> I seem to have a bit of an issue with my objects getting cached that are
> retrieved from persistence storage using OJB.
>
> I have a Category & Product tables.
> Category bean contains getter method that retrieves a Vector of products
> that belong to that Category. Product class contains categoryId field as FK
> indicator.
> My repository_user.xml contains "collection-descriptor" in Category
> class/table mapping to Product table FK.
>
> <collection-descriptor
> name="allProductsForCategory"
> element-class-ref="com.baroko.ebiz.model.Product"
>
> <inverse-foreignkey field-ref="categoryId"/>
> </collection-descriptor>
>
> Now all this works in my application, but when it comes to adding a new
> value object or deleting an existing one, the action gets performed in the
> DB but doesn't reflect in my system (Only when I restart my application will
> change show). It appears that the method I call returns relevant Category
> but when I call getAllProductsForCategory() on it, it returns the same
> Vector as before. It should return Vector of Products with changes reflected
> in DB.
>
> Note as I said this issue only is applicable to insert and delete statements
> not update!
> When I do an update on my value object, it reflects the change in my system.
> Strange...:)
>
> What could the problem be?
> Any help will be much appreciated.
>
> --Alen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>