0 Replies Latest reply on Mar 31, 2005 4:58 AM by Yevgen Bushuyev

    Sorting by attributes of the related objects

    Yevgen Bushuyev Newbie

      I run into the problem while sorting by attributes of related objects...

      In the ejb spec it is said that "each orderby_item must be an orderable cmp-field of the entity bean abstract schema type value returned by the SELECT clause."

      Thus, when an "identification variable variable x, denoted as OBJECT(x)" is being selected it should not be possible to sort by attribute y of a related entity z, like SELECT OBJEXT(x) FROM Xxxx AS x ORDER BY x.z.y. Despite this JBoss allows to run such queries, at least dynamic ones.

      The only problem with this it is that JBoss does not reutrn objects when reference to the related entity is null. This happens because it generates queries without JOINS but with WHERE clause to tie tables.

      Thus, i have two questions:
      1. Is it legal to use sorting by attributes of related objects?
      2. How do you solve the problem when reference to the related object is null? Users expect all objects to be returned whether or not they have reference to the related object they sort by.


      thanx