0 Replies Latest reply on Jan 16, 2003 12:19 PM by Jürgen Krannich

    Generated code to remove n:m-relationships is very inefficie

    Jürgen Krannich Newbie

      Hi there,
      I have got a little performance problem caused by the way the persistence engine generates its jdbc-statements. The following is the situation:

      I have two beans Key and KeyGroup standing in a many-to-many relationship. The tables are "key" and "keygroup" and the mapping-table is key_keygroup(key, keyGroup). A KeyGroup might consist of thousands of Keys. If I try to remove a KeyGroup I can go for a coffee because the generated remove-statement is something like:

      2003-01-16 17:49:04,113 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDeleteRelationsCommand.Key] Executing SQL: DELETE FROM key_keygroup WHERE (key=? AND keyGroup=?) OR (key=? AND keyGroup=?) OR (key=? AND keyGroup=?) OR (key
      =? AND keyGroup=?) OR (key=? AND keyGroup=?) OR (key=? AND keyGroup=?) OR (key=? AND keyGroup=?) OR (key=? AND
      keyGroup=?) OR (key=? AND keyGroup=?) OR (key=? AND keyGroup=?) OR .......................

      Is there any way to tell the persistence engine to generate a statement like "DELETE FROM key_keygroup where (keyGroup=?)" because this would have the same effect but be much more performant.

      Thanks in advance,
      Jürgen