db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oliver.m...@ppi.de
Subject delete on m:n-link-table during INSERT
Date Fri, 01 Oct 2004 11:07:18 GMT
Hello,

recently, Mariusz W├│jcik [mailto:wojcikm@okno.pw.edu.pl] pointed out in
the Users' list that whenever an Object that has an empty 
m:n-mapped collection is inserted, the corresponding entries in the 
link-table are deleted.
The code is in PersistenceBrokerImpl.storeAndLinkMtoN(), see below.

I find this very annoying.  Typically, there won't be any objects 
to delete during insert, unless the new primary key had previously 
been used as a foreign key in the link-table.  I bet this chiefly happens
druing testing, but not in real-life applications.

I propose to change this in 1.1.  There could be a configuration switch 
(say, in the collection-descriptor) to get the old behaviour, but the
default
should be NOT to delete during insert.

What do you think?

Olli

if (insert || ...)
{
  // if referenced objects are null, assign empty list
  if(referencedObjects == null)
    {
      referencedObjects = Collections.EMPTY_LIST;
    }
  // ...
  Iterator referencedObjectsIterator =
BrokerHelper.getCollectionIterator(referencedObjects);
  
  if(!referencedObjectsIterator.hasNext())
    {
      mtoNBroker.deleteMtoNImplementor(cod, obj);
    }
}

-- 
  Oliver Matz
  ppi Media GmbH
  Deliusstra├če 10
  D-24114 Kiel
  phone   +49 (0) 43 1-53 53-422
  fax     +49 (0) 43 1-53 53-2 22
  email	mailto:oliver.matz@ppi.de
  web	www.ppi.de

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message