4 Replies Latest reply on Aug 15, 2005 11:46 AM by Adrian Brock

    Setter methods in ejbCreate useless?

    Mike Sowka Newbie

      I've got a simple entity bean (CMP). I'm messing around with it, and have noted something "funny":

      public Integer ejbCreate (String foo) throws CreateException {
      Integer id = // some generated id
      foo = foo + "Bar";
      setFoo(foo);
      return id;
      }

      IS NOT THE SAME AS:

      public Integer ejbCreate (String foo) throws CreateException {
      Integer id = // some generated id
      setFoo(foo + "Bar");
      return id;
      }

      In fact, when running the latter code the 'foo' bean attribute does not include "Bar" after it's created!

      I'm a bit of a "newb", but do understand that in CMP the container actually extends the entity class and _it_ is responsible for storing data... but according to [Mastering Enterprise JavaBeans, E. Roman et al.] a typical ejbCreate implementation includes use of setters.

      What's going on? Any hints much appreciated,
      Mike

        • 1. Re: Setter methods in ejbCreate useless?
          Mike Sowka Newbie

          ... I'm still scratching my head here, and it's getting even more confusing:

          I've got a InitialContext.lookup call in a JNDIUtil class... and now it turns out that for some String name = "Hello"

          name = name.concat(" World!");
          context.lookup(name);

          IS NOT THE SAME AS

          context.lookup(name.concat(" World!"));

          In the latter instance the look-up is done on "Hello"! :|

          Am I coding Java?! Waaa... what's going on?!

          • 2. Re: Setter methods in ejbCreate useless?
            Adrian Brock Master

            Look, obviously got one of the following broken:

            * compiler/jvm
            * brain :-)

            In either case, this is not a JBoss or EJB issue.

            Depending upon the problem, the solution will come from:

            * the JDK vendor
            * medical help :-)

            What makes you think anybody in an EJB forum would be interested in this problem?
            Much less, when you post zero information beyond
            your own assertion that something strange is happening.
            http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHelp

            e.g. You don't even provide the JDK version.
            Don't post it, there's is nothing we can do to fix your JDK.

            • 3. Re: Setter methods in ejbCreate useless?
              Mike Sowka Newbie

              Adrian,

              I do admit (and, in written, did in my first post) that I'm relatively fresh to J2EE, and as such :) take the faulty brain joke with a pinch of salt... especially since the second post was hasty, as it did turn out to be "user error" :| (read: disregard second post, and pardon for littering).

              It did not occure to me that I may be posting about a JBoss error. I knew it was most likely something I was doing, and thought that real J2EE developer glancing at my very brief pseudo-example would be able to quickly point out what I was doing wrong.

              On that note, didn't realize that these forums were limited to posts on JBoss technical problems... will figure out my original problem outside, and will keep any further J2EE beginner question to myself ;). Mea culpa.

              Have a good weekend Adrian,
              Mike

              P.S. My JDK/OS is pretty standard (Sun 1.5.0_04 + Linux). If I had any doubts about those, You're right Adrian, I wouldn't post here.

              • 4. Re: Setter methods in ejbCreate useless?
                Adrian Brock Master

                There is a perfectly good "beginners corner" where you can dump "dumb" questions
                to your heart's content ;-)