6 Replies Latest reply on Jul 9, 2002 2:15 PM by Dain Sundstrom

    Container insert extra data

    roysun Newbie

      I have two beans AccountBean and UserLoginBean with relationship 1 to N. It is unidirectional. In AccountBean, I have code like
      public abstract Collection getUserLogins();
      public abstract void setUserLogins(Collection userLogins);
      UserLoginBean matches table user_login.
      The relationship in descriptor
      ====


      <ejb-relation>
      <ejb-relation-name>AccountUser</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>AccountHasUsers</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Account</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>loginUsers</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>UserInAccount</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>UserLogin</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      The ejbCreate in UserLoginBean like
      ==
      public java.lang.Integer ejbCreate(java.lang.Integer userId, int accountId, String username, String password, String hostname) throws CreateException
      {
      this.setUserId(userId);
      this.setAccountId(accountId);
      this.setUsername(username);
      this.setPassword(password);
      this.setHostname(hostname);

      return null;
      }

      When I called userLoginHome.create(), I got following error message.

      ==

      2002-07-08 15:41:28,883 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserLogin] Executing SQL: INSERT INTO user_login (user_id, account_id, password, username, hostname, Account_loginUsers) VALUES (?, ?, ?, ?, ?, ?)
      2002-07-08 15:41:28,897 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserLogin] Could not create entity
      java.sql.SQLException: ERROR: Relation 'user_login' does not have attribute 'account_loginusers'

      ==
      Container is trying to insert a extra data "Account_loginUsers" to user_login table. How to explain this? Did I do something wrong?

      Roy