Hi,
ABOU LINA wrote:
thank first,
PersistenceBroker *delete elements* from the database that have been removed
from the collection only if i do this :
for example : A 1:n B
1. i get A from database using OJB Broker.
2. i delete one element B from A : A.getBCollection().remove(o);
in this case yes the PB delete the element from database . but in generale
we don't
invoke remove but we construct a new collection and we set it :
1. get A from database.
2. Collection bCol = new ArrayList();
A.setBCollection(bCol);
in this case the element that not figure in bCol are not deleted because i
use ArrayList. (in my Application i can't put RemovalAwareList directly
There is no need to handle with RemovalAwareList instances in your
POJO's. Using type 'List' is sufficient and on insert of new objects you
can use ArrayList, so
> 2. Collection bCol = new ArrayList();
> A.setBCollection(bCol);
is valid when insert new objects.
But you are right, when updating objects you have to use
Collection.remove(...) method.
> 2. i delete one element B from A : A.getBCollection().remove(o);
it's not allowed to replace the old List with a sub-List instance.
inorder to keep the application independent of OJB classes ...)
so what is the solution please ... without using ODMG ?????
There is none.
That's the main difference between the PB-api and ODMG. The ODMG
implementation use a "Unit of work" pattern (object state detection,
detection of new/deleted objects) the PB-api does immediately write
objects to DB and does not keep the objects state "in mind".
For the next major release of OJB we plan to extend the PB-api to
support a "unit of work" pattern with locking.
regards,
Armin
Thanks
On 3/7/06, Armin Waibel <[EMAIL PROTECTED]> wrote:
Hi,
ABOU LINA wrote:
Hi,
in ojb document :
---------------------------------------
Say you use the PB to query an object O that has a collection attribute
col
with five
elements a,b,c,d,e. Next you delete Objects d and e from col and store O
again with
PersistenceBroker.store(O);
PB will store the remaining objects a,b,c. But it will not delete d and
e !
If you then
requery object O it will again contain a,b,c,d,e !!!
--------------------
i ask if the new version of PB (1.0.4) still behave like this ???
Oops! Seems you found some outdated documentation - I will fix this till
next release.
With corresponding settings OJB 1.0.4 is able to detect the deleted
objects of the 1:n reference. More info see
http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting
http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type
regards,
Armin
---------------------------------------------------------------------
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]