db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: please enlighten me... attributes "abstract" and "alias" on tables
Date Mon, 27 Sep 2010 19:43:09 GMT
> > As far as I know, static methods are bound at compile time and cannot
> > overridden (i.e the BasePeer code will always access this
> > and thus always fail).
> AFAICT, no runtime code ever calls getOMClass(). The generated peer
> classes call TablePeer.getOMClass() and thus overriding this method
> *will* work. It looks like you can define another class that is used in
> row2Object(). Don't know if that could be useful.

Sorry I do not understand:

In the Torque 3 test project:

    /** A class that can be returned by this peer. */
    protected static final String CLASSNAME_DEFAULT =

    /** A class that can be returned by this peer. */
    protected static final Class CLASS_DEFAULT = initClass(

     * Class object initialization method.
     * @param className name of the class to initialize
     * @return the initialized class
    private static Class initClass(String className)
        Class c = null;
            c = Class.forName(className);
        catch (Throwable t)
        return c;
    public static Class getOMClass()
        throws TorqueException
        return CLASS_DEFAULT;

so getOmClass() will always return Author.class

getOmClass() is called in Runtime code:

    public static List populateObjects(List records)
        throws TorqueException
        List results = new ArrayList(records.size());

        // populate the object(s)
        for (int i = 0; i < records.size(); i++)
            Record row = (Record) records.get(i);
            results.add(AuthorPeer.row2Object(row, 1,
        return results;

You cannot override a static method. Ecample:

// Base.java
public class Base
  public static String getOmClass()
      return "BASE";

  public static void printOmClass()

// Inherited.java
public class Inherited extends Base
    public static String getOmClass()
        return "INHERITED";

    public static void main(String[] argv)

Running Inheried will output:

because the call getOmClass() in printOmClass() is bound at compile time.

Because of this, populateObjects(...) will always fail classes marked as

Or did I musunderstand what you were saying ?


> As we are at it, sometimes in a schema the equivalent to "skipSql" for
> the OM classes "skipJava" could be useful.

Go ahead, should not be difficult to implement. I can help, if you have any


To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message