Bug 105378 - Session#flushAll mistakenly things a 1..1 association isn't set
Summary: Session#flushAll mistakenly things a 1..1 association isn't set
Alias: None
Product: Red Hat Web Application Framework
Classification: Retired
Component: persistence (Show other bugs)
(Show other bugs)
Version: nightly
Hardware: All Linux
Target Milestone: ---
Assignee: Archit Shah
QA Contact: Jon Orris
Depends On:
Blocks: 108447
TreeView+ depends on / blocked
Reported: 2003-09-25 15:54 UTC by Daniel Berrange
Modified: 2007-04-18 16:57 UTC (History)
0 users

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

Attachments (Terms of Use)

Description Daniel Berrange 2003-09-25 15:54:00 UTC
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

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);

The addProvider method does this:

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

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

com.redhat.persistence.FlushException: Unable to send all events to database
because these required properties are null:
        at com.redhat.persistence.Session.flushAll(Session.java:533)
        at com.redhat.persistence.Session.commit(Session.java:619)
        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:

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 17:58:48 UTC
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.