0 Replies Latest reply on Nov 10, 2003 1:16 PM by silviomatthes

    override toString() in entity-bean doesn't work

    silviomatthes

      Hi,

      Please help me, I'm highly frustrated...
      I'm trying to override the toString-Method in an local interface of an entity-bean. But that doesn't work, it seems that another method is called.
      Here's what I've done so far:
      The Entity I'm working on is called Document.
      I'm working with xdoclet so I wrote


      /**
      * @ejb.interface-method view-type="local"
      */
      public String toString()
      {
      return "content of entitybean";
      }


      in my DocumentEJB.
      Xdoclet is generating a DocumentLocal-class with the line


      public java.lang.String toString( ) ;


      in it. In my sessionbean I create my Documentbean and want to call the toString()-method:


      DocumentLocal doc = null;
      DocumentLocalHome home = (DocumentLocalHome)ctx.lookup("java:comp/env/ejb/local/docarchiv/Document");
      doc = home.create();
      System.out.println("Doc: ["+doc.toString()+"]");


      I wanted my jboss 3.2.1 to printout something like "content of entitybean", but it said:


      19:57:13,690 INFO [STDOUT] Doc: [ejb/local/docarchiv/Document:1000010000000000000000059]


      , which is the type and the primary key of my created bean. Seems that my toString()-call is calling another toString-method I did not override.
      But in which class is the called toString()-method located and how can I override it?

      Thanks in advance

      Silvio Matthes