Re: Entity Modeler SQL generation trouble

From: Chuck Hill (chil..lobal-village.net)
Date: Tue Nov 13 2007 - 16:33:09 EST

  • Next message: Anjo Krank: "Re: Entity Modeler SQL generation trouble"

    On Nov 13, 2007, at 12:40 PM, Zak Burke wrote:

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

    Perhaps you could have a little chat with my wife.

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

    Because that fetch will happen as soon as the JVM loads that class.
    Whenever that might be. At which time EOF may not be fully really to
    go.

    Chuck

    -- 
    

    Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects



    This archive was generated by hypermail 2.0.0 : Tue Nov 13 2007 - 16:34:37 EST