Bug 431410 - Channel.findByIdAndUserId, findByLabelAndUserId, and findBaseChannel use c.id = c_1_.original_id
Channel.findByIdAndUserId, findByLabelAndUserId, and findBaseChannel use c.id...
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Jesus M. Rodriguez
John Matthews
: Triaged
Depends On:
Blocks: 456985
  Show dependency treegraph
Reported: 2008-02-04 05:17 EST by Jan Pazdziora
Modified: 2009-09-10 16:23 EDT (History)
2 users (show)

See Also:
Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-09-10 16:23:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2008-02-04 05:17:01 EST
Description of problem:

When investigating duplicate output in bug 252165, we came to conclusion that:

- we need to (outer) join rhnChannel with rhnChannelCloned to make hibernate happy;
- but the join should be via c.id = c_1_.id, not c.id = c_1_.original_id.

I grepped eng/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml and
found three more occurencies of outer join with .original_id:

    <sql-query name="Channel.findByIdAndUserId">
        <![CDATA[SELECT {c.*} 
              FROM rhnChannel {c},
              rhnChannelCloned c_1_
             WHERE c.id = :cid
               AND c.id = c_1_.original_id (+)
               AND rhn_channel.user_role_check(c.id, :userId, 'subscribe') = 1]]>
        <return alias="c" class="com.redhat.rhn.domain.channel.Channel" />
   <sql-query name="Channel.findByLabelAndUserId">
        <![CDATA[SELECT {c.*} 
              FROM rhnChannel {c},
              rhnChannelCloned c_1_
             WHERE c.label = :label
               AND c.id = c_1_.original_id (+)
               AND rhn_channel.user_role_check(c.id, :userId, 'subscribe') = 1]]>
        <return alias="c" class="com.redhat.rhn.domain.channel.Channel" />
    <sql-query name="Channel.findBaseChannel">
        <![CDATA[SELECT {c.*} 
              FROM rhnChannel {c}, rhnChannelCloned c_1_, rhnServerChannel sc
             WHERE sc.server_id = :sid
               AND sc.channel_id = c.id
               AND c.id = c_1_.original_id (+)
               AND c.parent_channel IS NULL]]>
        <return alias="c" class="com.redhat.rhn.domain.channel.Channel" />

That might not be correct.

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


How reproducible:

I just looked at the code.

Steps to Reproduce:
1. I don't really have steps here. I assume that somewhere, these queries might
cause problems and duplicate output.
2. Find those places.
Actual results:

Duplicate output.

Expected results:

No duplicate output and profit.

Additional info:

This is mainly a placeholder for investigating whether those joins with
.original_id are legit or not.
Comment 1 Jan Pazdziora 2008-02-04 10:12:04 EST
These SQL queries are used only in
eng/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java, via
singleton.lookupObjectByNamedQuery calls, which leads to HibernateFactory's
lookupObjectByNamedQuery, which does

            Query query = session.getNamedQuery(qryName)
            bindParameters(query, qryParams);
            retval = query.uniqueResult();

I assume that uniqueResult protects us from the duplicates, so fixing that SQL
(for the sake) of fixing it should not have any ill effects.

And could probably be punted off to 5.2.0.
Comment 3 Jesus M. Rodriguez 2009-02-22 23:01:40 EST
This was fixed prior to opening up Spacewalk.
Here is the initial Spacewalk commit:
Comment 5 Jesus M. Rodriguez 2009-03-26 00:11:46 EDT
This is a code inspection bug, not a qa-able bug. Please download the
spacewalk-java*.src.rpm untar the code and find Channel.hbm.xml. Verify that
the above matches.
Comment 7 Tomas Lestach 2009-08-26 08:50:28 EDT
No more occurrences of c.id = c_1_.original_id found in java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml

Stage validated -> RELEASE_PENDING
Comment 8 Brandon Perkins 2009-09-10 16:23:38 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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