Re: # char in DB field name

From: Mike Kienenberger (mkienen..laska.net)
Date: Tue Jul 12 2005 - 16:56:55 EDT

  • Next message: Emre Yilmaz: "Max. Length Validation"

    Albert Jagnow <albert-jagno..iowa.edu> wrote:
    > I have run across a database table that has a # in the field name and
    > that field happens to be the primary key field. The problem I encounter
    > is that when I generate the class file for this table I get the
    > following line:
    >
    > public static final String ACTSQ#_PK_COLUMN = "ACTSQ#";
    >
    > Java doesn't like the # in that var name. I don't know enough about how
    > cayenne works to know if I can rename this var or if that will that
    > cause problems. This is a legacy table so I can't do anything about
    > renaming the field. I will need to insert data into this table, but I
    > will be manually updating the new pk numbers. Any suggestions?

    The constant is only there for your convenience.

    Feel free to rename it to ACTSQNO_PK_COLUMN or ACTSQ_NUMBER_PK_COLUMN or
    delete it.

    You'll just have to remember to make that change each time you regenerate
    your class.

    If you open a Cayenne JIRA issue, we'll eventually fix the template
    generator so that # isn't included as part of the variable name.

    A fix will happen sooner if you provide a patch to fix it :) -- I seem to
    recall that there's a function that filters out illegal characters, so it
    should be pretty simple to fix.

    -Mike



    This archive was generated by hypermail 2.0.0 : Tue Jul 12 2005 - 16:53:52 EDT