Bug 105378 - Session#flushAll mistakenly things a 1..1 association isn't set
Session#flushAll mistakenly things a 1..1 association isn't set
Status: CLOSED WONTFIX
Product: Red Hat Web Application Framework
Classification: Retired
Component: persistence (Show other bugs)
nightly
All Linux
medium Severity medium
: ---
: ---
Assigned To: Archit Shah
Jon Orris
:
Depends On:
Blocks: 108447
  Show dependency treegraph
 
Reported: 2003-09-25 11:54 EDT by Daniel Berrange
Modified: 2007-04-18 12:57 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-11-10 16:03:46 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2003-09-25 11:54:00 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.9 (X11; Linux i686; U;) Gecko/20030314

Description of problem:
Consider the following association (i've removed the table mappings for
simplification).

association {
    composite AtoZ[1..1] atoz;
    component AtoZProvider[0..n] atozProviders;
    Integer[0..1] sortKey = atoz_provider_map.sort_key INTEGER;
}


Now, in the code I'm creating an AtoZProvider thus:

  AtoZ atoz = (AtoZ)Kernel.getContext().getResource();
  Assert.exists(atoz, AtoZ.class);
  provider = (AtoZProvider)Classes.newInstance(m_providerType);
  atoz.addProvider(provider);

The addProvider method does this:

    public void addProvider(AtoZProvider provider) {
        add(PROVIDERS, provider);
    }

However, when the transaction commits, the Session#flushAll method throws an
exception:

com.redhat.persistence.FlushException: Unable to send all events to database
because these required properties are null:
 [com.arsdigita.london.atoz.AtoZCategoryProvider:{id=9478}].atoz
        at com.redhat.persistence.Session.flushAll(Session.java:533)
        at com.redhat.persistence.Session.commit(Session.java:619)
        at
com.arsdigita.persistence.TransactionContext.commitTxn(TransactionContext.java:91)
        at
com.arsdigita.kernel.DatabaseTransaction.commit(DatabaseTransaction.java:74)
        at com.arsdigita.kernel.DatabaseTransaction.end(DatabaseTransaction.java:62)

This is bogus, because the code above clearly shows I am setting the association
in question. I have also tried setting the association from the other end, ie
setting 'atoz' explicitly on the AtoZProvider object. This also fails. I have
also tried explicitly setting a value for the link attribute (although since
sortKey is 0..1 its not required). This also has no effect.

 * If I remove the 'sortKey' link attribute this error goes away.
 * Or, ff I change the 'atoz' property to be '0..1' instead of '1..1' the
problem also goes away.

In either case, the 'atoz' property is definitely set to a non-null value since
looking in SQL shows that the mapping table is populated.
So there must be a bug somewhere in the code that checks for nulls that is being
triggered by the link attribute.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Define an association similar to the above example
2. Run code similar to the above example

    

Additional info:
Comment 1 Archit Shah 2003-10-21 13:58:48 EDT
The bug reported is actually a bug masking a known lacking feature. The reported
bug that is causing the error reported is fixed in 37186. That changes the code
that checks flushability to use the correct metadata. With that fix, the error
you will get is a foreign key violation. The engine is confused by the loop of
1..1 relationships. According to the metadata, the link must exist for the
"provider" object to exist. And the "provider" object, as part of the key of the
link must exist for the link to exist. Only by looking at the physical metadata
and determining that the "provider" object can be created in the database
without the link can this use case work.

Note You need to log in before you can comment on or make changes to this bug.