Hi,

Affected Method: 
 org.mmbase.module.database.support.MMSQL92Node (1.66)
 public int insert_real(bul,owner,node,tableName)

Problem:
 OO-database complaints on an insert: 'unique constraint violated'

Description:

After some debugging we found a nasty 'feature' in MMSQL92Node regarding
inserts of new nodes in OO-databases *(ours is informix). It seems that some
Relational Database functions made it into the generic layer which is handling
both kinds of databases.

The problem manifests itself when you insert a new node in the database. Our
database starts to complain that a 'unique constraint is violated'. After some 
extensive search, we found the problem to be the double insert of a node,
once into its own table after which the code tries to insert a second instance into
the 'object' table. All nice and such, but when you have a OO-database, the 
last step is not necessary, because the first insert also implicitly means an
insert into the object table.

This code will now throw a huge exeption on every insert of a new node in the 
logfile, but since the child table is updated before the parent, no information is 
lost, eg, the node is correctly inserted. But this can hardly be called 'correct 
behavior'. And since it throws an exception there can be no guaranty about 
code correctly working after that. 

I suspect that the (inherited) relations are also affected in the same way.

This piece of code needs to be removed and put into the database support 
classes of MySql and all other not-OO databases. I know that's a hassle,
but this modification as it is now in cvs, 'breaks' all OO-databases.

Maybe its a idea to make 2 new database classes, RelationalDatabase and
OODatabase which both extends MMSQL92Node. The RelationalDatabase
has a insert_real as it is now implemented in cvs, the OODatabase has a 
insert as it was previously. All other drivers can now safely be of type 
RelationalDatabase or OODatabase.

Reply via email to