Re: Entity Modeler SQL generation trouble

From: Zak Burke (zdbw..artmouth.EDU)
Date: Tue Nov 13 2007 - 15:40:27 EST

  • Next message: Guido Neitzer: "Re: Entity Modeler SQL generation trouble"

    Chuck Hill wrote on 11/13/07 12:51 PM:
    >
    > On Nov 13, 2007, at 8:39 AM, Zak Burke wrote:
    >
    >> I cannot generate SQL for an EO Model in a framework project. It seems
    >> like the problem may be (?) that the EO's .java file is being
    >> parsed/loaded before the EO model file. The full stacktrace is below,
    >> but the root of the problem is the initialization of the following
    >> static variable on the EO SourceDnd:
    >>
    >> public static final SourceDnd DARTMOUTH_DND =
    >> SourceDnd.sourceDndById(Integer.valueOf(1));
    >>
    >> The method SourceDnd.sourceDndById is nothing fancy; it does a simple
    >> fetch via EOUtilities:
    >>
    >> return (SourceDnd) EOUtilities.objectMatchingKeyAndValue(ec,
    >> SourceDnd.ENTITY_NAME, SourceDnd.ID_KEY, id);
    >
    >
    > Never mind the SQL generation. That seems like a breathtakingly
    > dangerous thing to do with EOF.
    >
    > Chuck

    And Chuck said the words, and so they were true. But ... why is it true,
    and what part is so dangerous? If this is what's killing you:

            public static final SourceDnd DARTMOUTH_DND =
            SourceDnd.sourceDndById(Integer.valueOf(1));

    imagine that "SourceDnd" is "Planet" and we have something like this:

            public static final Planet MERCURY =
            Planet.fetchById(Integer.valueOf(1));

            public static final Planet VENUS =
            Planet.fetchById(Integer.valueOf(2));

            ...

    SourceDnd is only a lookup table so that we can constrain against it in
    the DB; the rows in that table are static. Also, the PK values are read
    from a properties file but I just wanted to keep my example simple.

    If the trouble is elsewhere, where?

    zak.



    This archive was generated by hypermail 2.0.0 : Tue Nov 13 2007 - 15:42:36 EST