Home
LimitationsLimitations
JoSQL is limited to work on the methods/fields defined in the class specified in the FROM clause. Whilst in theory it is possible to allow access to "sub-class" methods and fields at run-time, there are issues with how such access should be handled for objects that DO NOT have the method/field. For example:
public abstract class MyObject
{

   private String myValue = null;

   public String getMyValue ()
   {

       return this.myValue;

   }

}

public class AObject extends MyObject
{

   private String aValue = null;

   public String getAValue ()
   {

       return this.aValue;

   }

}

public class BObject extends MyObject
{

   private String bValue = null;

   public String getBValue ()
   {

       return this.bValue;

   }

}
SELECT *
FROM   MyObject
WHERE  bValue = 'b'
OR     aValue = 'a'
Whilst technically this is possible, it causes problems at run-time since JoSQL then has to make a decision about how to handle the fact that one of the objects passed in does NOT have the relevant accessor. Because of this issue JoSQL ONLY allows accessors for the class specified in the FROM clause.

It should be noted that this particular issue can be "circumvented" by the developer by the use of a function that will allow access to the relevant accessor. For example:
SELECT *
FROM   MyObject
WHERE  get ('bValue') = 'b'
OR     get ('aValue') = 'a'
The get function would be user-defined and allow access to the relevant method/field. A potential implementation would be thus:
public Object get (Object o,
                   String accessor)
                   throws QueryExecutionException
{

    Getter g = null;

    try
    {

       g = new Getter (accessor,
                       o.getClass ());

    } catch (Exception e) {

       // Class does not have the relevant accessor, just return 
       // null or whatever value is required.
       return null;

    }

    try
    {

       // Get the value from the object.
       return g.getValue (o);

    } catch (Exception e) {

       throw new QueryExecutionException ("Unable to get value for accessor: " +
                                          accessor + 
                                          " from class: " +
                                          o.getClass ().getName (),
                                          e);

    }

}
See Also