Re: Entity Modeler SQL generation trouble

From: Zak Burke (zdbw..artmouth.EDU)
Date: Tue Nov 13 2007 - 18:02:03 EST

  • Next message: Chuck Hill: "Re: Entity Modeler SQL generation trouble"

    Mike Schrag wrote on 11/13/07 4:30 PM:
    >> I can only assume his java files are doing something funky in a static
    >> block or something?
    > Oh right .. looking at that stack trace for 5 seconds:
    >
    > at edu.dartmouth.dltg.pns.eos.SourceDnd.sourceDndById(SourceDnd.java:45)
    > at edu.dartmouth.dltg.pns.eos.SourceDnd.<clinit>(SourceDnd.java:20)
    >
    > You're doing EOF stuff in a static initializer. This is just a bad
    > idea. You should really do this kind of initialization after your app
    > loads

    Ah; that's good to know. ... How should I have known? This is the part
    of WO programming that sometimes drives me nuts: there's some Java
    pattern that is normal (this is all derived from a standard way of
    managing typesafe enums prior to JDK 1.5) but that causes WO to explode
    and Chuck, Anjo and Mike say, "Oh, yeah, that. Don't do that." How do
    you know? How did you learn? Or is it just obvious if you truly
    understand EOF what kinds of behaviour will lead to trouble?

    Before I get carried away on my rant, is the basic answer that I have to
    replace this:

    A.
         public class SourceDnd extends _SourceDnd {

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

    with this:

    B.
         public class OtherClassNotRelatedToAnEo {

             private static final SourceDnd DARTMOUTH_DND = null;
             private static final SourceDnd ALUMNI_DND = null;

             public static final DARTMOUTH_DND() {
                 if (OtherClass.DARTMOUTH_DND == null)
                     OtherClass.DARTMOUTH_DND = SourceDnd.sourceDndById(
                     Integer.valueOf(1));

                 return OtherClass.DARTMOUTH_DND;
             }
             ...
         }

    or do I have to give up on the efficiency of static variables all
    together and implement these as methods only:

    C.
         public class OtherClassNotRelatedToAnEo {

             public static final DARTMOUTH_DND() {
                 return SourceDnd.sourceDndById(Integer.valueOf(1));
             }
             ...
         }

    zak.



    This archive was generated by hypermail 2.0.0 : Tue Nov 13 2007 - 18:04:09 EST