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