5 Replies Latest reply on Oct 9, 2002 4:47 AM by paul73

    One-To-One Relationship problems

    paul73

      I'm trying to generate some basic examples (it's very short) with relationships but I've some problems:
      TransactionRolledbackException, causedBy:
      java.lang.ClassCastException: $Proxy373

      Maybe the problem is not in the relationship specification... but I'm going out of my head....

      Thanx in advance,
      Paul

        • 1. Re: One-To-One Relationship problems
          aloubyansky

          You trying to implement relationships using remote interfaces. Use local instead.

          • 2. Re: One-To-One Relationship problems
            paul73

            Thank you for the suggestion but the problem still remains... I think that the problem is related to the way I use to set the "ChildEntity" in the "MainEntity" Bean.

            Now I'm using "local" but, when in the ejbCreate I try to set the ChildEntity field:

            TransactionRolledbackException, causedBy:
            java.lang.ClassCastException: $Proxy796

            Sorry, but I'm new to the J2EE :(

            Thanks again
            Paul

            • 3. Re: One-To-One Relationship problems
              paul73

              Sorry... the code:

              /**
              * @ejb:interface-method
              * tview-type="local"
              *
              *
              * @ejb:relation
              * name="Main-child"
              * role-name="Main"
              * target-ejb="ChildEntity"
              * target-role-name="Child"
              *
              * @jboss:relation
              * related-pk-field="ida"
              * fk-column="ida"
              **/
              abstract public ChildEntity getChildEntity();

              /**
              * @ejb:interface-method
              * tview-type="local"
              **/
              abstract public void setChildEntity(ChildEntity child);

              /**
              * @ejb:create-method
              * tview-type="remote"
              **/
              public MainEntityPK ejbCreate()
              throws CreateException
              {
              return null;
              }

              public void ejbPostCreate()
              throws CreateException
              {
              }

              /**
              * @ejb:create-method
              * tview-type="remote"
              **/
              public MainEntityPK ejbCreate(int id,ChildEntity child)
              throws CreateException
              {
              setId(id);
              setName("Pippo");
              return null;
              }

              public void ejbPostCreate(int id,ChildEntity child)
              throws CreateException
              {
              setChildEntity(child);
              }


              Paul

              • 4. Re: One-To-One Relationship problems
                aloubyansky

                The code looks ok... except ejbCreate() :)
                Note: not only the cmr accessors must be in local interfaces but ChildEntity and MainEntityBean must be local interfaces too.
                Confirm this, please.

                • 5. Re: One-To-One Relationship problems
                  paul73

                  Thankx Alex...

                  now it works!

                  I've changed everything to "local" as you said :)

                  Thanx again!