7 Replies Latest reply on Mar 7, 2004 1:09 PM by mike andrews

    ejbql finder bug?

    mike andrews Newbie

      hi folks,

      i'm running a finder method twice in succession, i.e., one *immediately after* the other, and the results are different each time --- clearly seems like a bug.

      i'm doing something special which may be causing the trouble, despite its being suggested in this forum: i'm sharing a database column between one field of a complex CMP primary key, and a CMR field. obviously, once set, my application never changes that CMR field in order to keep primary key integrity and conform to the j2ee spec.

      this finder method involves traversal of that CMR field, which is one-to-one with another entity bean. the foreign key is on the 'other' side of the CMR.

      the correct answer for this finder method involves a Collection of one remote entity bean, which is what i get for the first invocation. the second time i invoke it, however, i get a Collection of zero items. this is clearly incorrect, since nothing happened in between the two finder invocation --- they literally executed one after the other in the bytecode.

      the database was not altered in between either, and indeed, if i iterate over *all* the local entities of that type, i can clearly see that the CMR field is still set properly. i can also see the same looking at the database manually.

      any ideas? i'm running a jboss-3.2.4RC1 snapshot from several days ago.

      mike.

        • 1. Re: ejbql finder bug?
          mike andrews Newbie

          sorry, i described it slightly incorrectly:

          although this entity bean has a CMP primary-key field and CMR field that share a database column, the CMR that the finder method is navigating is *another* CMR field, which has its own database column on the 'other' side of the relationship. thus, it seems less relevant to the bug i described than i initially thought.

          but i'm still stumped at this behaviour and think its incorrect (i.e., may be a bug)

          mike

          • 2. Re: ejbql finder bug?
            Alexey Loubyansky Master

            Please, post DDs and relevant code snippets. Thanks.

            • 3. Re: ejbql finder bug?
              mike andrews Newbie

              thanks so much --- will plan to abstract out a super-simple application with 2 or 3 entity beans that demonstrates the effect (if i can reproduce it!), with a client. mike

              • 4. Re: ejbql finder bug?
                mike andrews Newbie

                hi there,

                i prepared a zip file which is a complete jboss ejb project with a client, intended to [eventually] exhibit the bug i described in previous posts. the zip file is available at http://xoba.com/debug-2.zip and basically just contains three entity beans and a single client class. a 'properties.txt' file contains pointers to needed resources, like xdoclet, the jboss-server, etc, and needs to be customized before building. the 'deploy' ant target builds and deploys the ejbs to the jboss server. the 'client' ant target builds and runs a client that exhibits a [jboss] CMP/CMR bug; i see the bug in a standard jboss-3.2.3/all server and the project as configured uses mySQL in a database named 'debug' (see properties.txt for that).

                the bug which is exhibited by debug-2.zip is not precisely the bug i described in previous posts, having to do with the shared CMP/CMR field. indeed, changing a couple xdoclet tags in the bean named 'First' of debug-2.zip is all it takes to move onto that particular bug, which i think should be postponed until the present one (in debug-2.zip) is solved. perhaps even solving this bug will also solve the other one since they may be related.

                specifically, this bug is: when executing a finder method to find all beans of 'First' type that are related to beans of 'Third' type (i.e., "SELECT OBJECT(c) FROM First AS c WHERE c.third is NOT NULL"), it seems jboss is not doing the necessary table join in SQL. and that's the bug you will see exibited when you execute the 'client' ant target in debug-2.zip, and the SQL error message is due to the fact that jboss is trying to access the table of the 'Third' bean without doing the necessary table join.

                as a side note, in the bean named 'First', the primary key is logically the combination of a String and a CMR field. since there is no way of doing that directly in EJB (since the relationships must be set in ejbPostCreate, whereas the primary key is returned in ejbCreate), the idea is to have a CMP and CMR field share a database column. when implementing this, i ran into the bug i described in previous posts. on fiddling some more, i ran into the present bug, the one i exhibit in debug-2.zip. this present bug *does not* share the database column, and yet there still seems to be a bug. thus, i thought it better to solve this bug first, and then move onto the version where the database columns are shared, if indeed solving the present bug doesn't also fix the latter one.

                thanks so much,
                mike

                • 5. Re: ejbql finder bug?
                  mike andrews Newbie

                  i updated http://xoba.com/debug-2.zip to reflect the state of that project after its built, so that deployment descriptors created by xdoclet etc etc are all present now. this may be more convenient than depending on folks to build it for themselves. thanks in advance --- mike

                  • 6. Re: ejbql finder bug?
                    Alexey Loubyansky Master

                    Could you please submit a bug report on sf.net/projects/jboss? Thanks.

                    • 7. Re: ejbql finder bug?
                      mike andrews Newbie

                      glad to do so --- i may delay a bit while i investigate some more, however --- hope that's alright. thanks - mike