Constants for Column names

From: Tobias SCHOESSLER (Tobias.Schoessle..nvienna.org)
Date: Tue Nov 04 2003 - 10:58:15 EST

  • Next message: Andrus Adamchik: "Re: Constants for Column names"

    Hello,

    I have the following simple thing on my wishlist:
    some constants to be generated in the ObjEntity Classes that represent the
    Column names of the underlying table.

    Something like this would be nice:

    public static String COL_FULL_NAME="fullName";

    I think it is nice to use these constants instead of the explicite String
    when creating expressions. The compiler is then able to check
    the correctness and I could use code insight features of IDEs to input the
    column names.
    In addition, if the column names change during developement the problems
    will come up at compile time instead of runtime.

    I think changes to the cayenne-1.0.2
    p1\src\cayenne\dotemplates\singleclass.vm like this

    #foreach( $attr in ${classGen.Entity.Attributes} )
    public static final String ${attr.Name}_COLUMN = "${attr.Name}";
    #end

    should do the trick. Though capitalizing the $attr.Name and some additional
    tweaking to meet the Java Code standard for constants
    would be nice.

    Unfortunatelly the shipped build script is ignoring changes to the
    templates and does not pack the resources like images etc. correctly.
    So changes are hard to be done manually. Perhaps there is a way to get that
    wish fullfilled?

    best regards

    Tobias

    (Embedded image moved to file: pic09338.gif)


    pic09338.gif



    This archive was generated by hypermail 2.0.0 : Tue Nov 04 2003 - 10:58:20 EST