Re: Constants for Column names

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Nov 04 2003 - 11:31:15 EST

  • Next message: Andriy Shapochka: "Cayenne Data View Modeler merged with Cayenne 1.1-dev"

    Hi Tobias,

    +1 for the feature, and you are totally right about the way this could
    be done. IIRC one of Cayenne committers, Eric Schneider, has done this
    already for his own project, with pretty capitalization of the
    variables, etc.

    I guess I haven't bothered to add it in yet, cause I wanted to make it
    optional and add Modeler support when I have more time, but now that I
    am thinking about it again, there is no harm in adding this code to all
    generated classes unconditionally. I'll target this for 1.0.3.

    > 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?

    Hmm... need to look into the build script. If you have any more
    details, please open a bug report.

    For now you have an option of using an arbitrary custom template
    outside of Cayenne if you use cgen task for class generation:

    http://objectstyle.org/cayenne/userguide/javagen.html

    Use "supertemplate" binding to alter the template for the superclass.

    Andrus

    On Nov 4, 2003, at 10:58 AM, Tobias SCHOESSLER wrote:
    > 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 - 11:31:23 EST