-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(Please note that we are new to developing with xdoclet...)

We are trying to connect two cmp entity beans with a 1:1 relationship. 
The two objects in question model a User and the user's Account 
(similar to every hello-world-like oop-example in the universe and 
exactly the same as the relationship between Customer and Account in 
the xPetstore-implementation). 

But somehow we can't seem to make this work. Even if we do it in the 
exact (to our understanding) same way as in xPetstore. 

When compiling (with ant and xdoclet) we get this error:

compile:
  [javac] Compiling 12 source files to /home/zeitgeist/www/build/classes
  [javac] 
/home/zeitgeist/www/build/generate/com/pu240/zeitgeist/user/UserEntityCMP.java:117: 
cannot resolve symbol
  [javac] symbol  : method setAccountEntity  
(com.pu240.zeitgeist.user.AccountEntityValue)
  [javac] location: interface com.pu240.zeitgeist.user.AccountEntityLocal
  [javac]              relation.setAccountEntity(valueHolder.getAccountEntity());
  [javac]                          ^
  [javac] 1 error



Here are the relevant xdoclet class level tags in our User object:


  /**
   * @ejb:bean     
   *     name="UserEntity"
   *     type="CMP"
   *     cmp-version="2.x"
   *     view-typ="local"
   *     jndi-name="ejb/com/pu240/zeitgeist/user/UserEntity"
   *     local-jndi-name="ejb/com/pu240/zeitgeist/user/UserEntityLocal"
   *     primkey-field="userUId"
   *
   *
   * @ejb.value-object
   *     name="UserEntity"
   *     match="*"
   */


A User has an Account and here are the xdoclet relationship information 
in the User's cmr methods:


  /**
   * @ejb.interface-method
   *
   * @ejb.relation
   *    name="user-account"
   *    role-name="user-has-account"
   *    target-ejb="AccountEntity" 
   *    target-role-name="account-belongs_to-user"
   *    target-cascade-delete="yes"
   *
   * @ejb.value-object
   *      compose="com.pu240.zeitgeist.user.AccountEntityValue"
   *      compose-name="AccountEntity"
   *      members="com.pu240.zeitgeist.user.AccountEntity"
   *      members-name="AccountEntity"
   *      relation="external" 
   *
   * @jboss.relation
   *    fk-column="userId_fk"
   *    related-pk-field="userId"
   *
   * @jboss.relation-read-ahead
   *    strategy="on-find"
   */
  public abstract com.pu240.zeitgeist.user.AccountEntityLocal getAccountEntity();
  public abstract void setAccountEntity(com.pu240.zeitgeist.user.AccountEntityLocal a);
    

Here's the User's ejbCreate() ans ejbPostCreate():


  /**
   * @ejb:create-method
   */
  public String ejbCreate(AccountEntityLocal av, UserEntityValue v) 
      throws EJBException, CreateException {

        String id = UserEntityUtil.generateGUID(this);
        setUserUId(new String(id));
        setUserEntityValue(v);
        return null;
    }

  public void ejbPostCreate(AccountEntityLocal av, UserEntityValue v) {
        setAccountEntity(av);
  }


As we are trying to create a unidirectional relationship, the Account 
object doesn't include any @ejb.relationship tags (again, exactly as in 
xPetstore). The relevant class level xdoclet tags in Account:


  /**
   * @ejb.bean
   *   name="AccountEntity"
   *   type="CMP"
   *   cmp-version="2.x"
   *   view-type="local"
   *   local-jndi-name="ejb/com/pu240/zeitgeist/user/AccountEntityLocal"
   *   jndi-name="ejb/com/pu240/zeitgeist/user/AccountEntity"
   *   primkey-field="userId"
   *
   * @ejb.value-object
   *   name="AccountEntity"
   *   match="*"
   */


And the create- post-create methods:


  /**
   * @ejb.create-method
   */
  public String ejbCreate(AccountEntityValue data)
        throws CreateException {
        setUserId(data.getUserId());
        setAccountEntityValue(data);
        return null;
  }

  public void ejbPostCreate(AccountEntityValue data)
      throws CreateException {
  }


Ok. So far so good. Then we have a session bean, UserAdminSession, that 
for example should be able to create a User:


  /**
   * @ejb:interface-method view-type="both"
   */
  public String createUser(UserEntityValue user) {

      String id;

      try {
           AccountEntityLocal act = null;
           AccountEntityValue account = user.getAccountEntity();
           act = accountHome.create(account);
           UserEntityLocal usr = userHome.create(act, user);
           id = usr.getUserUId();
      } catch (Exception ex) {
           throw new EJBException("Exception in createUser()");
      }

      return id;
    }


We can compile and run xPetstore just fine, but we can't get our own 
stuff to even compile. All suggestions and help is much appreciated!




Regards,
Erik Tjernlund

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+MVlAqHy5M3kRLQoRAgX4AJ9ScUCzdPpScg8khL6mPCOX8Nl4LwCfbbrd
mFphkUVuFD6nVwO4LFkd8SU=
=DKwL
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to