1 Reply Latest reply on Sep 5, 2002 9:01 AM by erikture

    M:M relation in latest JBoss

    erikture

      Hello!

      I have two entity beans, User and AccessGroup.
      An User can be member of many AccessGroups and an AccessGroup can have many Users. This worked fine for me with a JBoss build upon CVS in late May. However the same code does not work in the latest JBoss from CVS.
      When I try to assign an User to an Accessgroup nothing happens.

      The code that does that is below:

      /**
      * addUserToAccessGroup
      *
      * @ejb:interface-method view-type="remote"
      */
      public void addUserToAccessGroup(long accessGroup, long userId, long adminId)
      throws UserDoesntExistException, AccessGroupDoesntExistException, UserNotAuthorizedException{
      try{
      if(!isUserAuthroized(adminId)){
      ctx.setRollbackOnly();
      throw new UserNotAuthorizedException(adminId);
      }
      }catch(UserDoesntExistException e){
      ctx.setRollbackOnly();
      throw new UserNotAuthorizedException(adminId);
      }
      try{
      UserLocal user = getUserLocal(userId);
      AccessGroupLocal group = getAccessGroupLocal(accessGroup);
      Set users = group.getUsers();
      users.add(user);
      }
      catch(UserDoesntExistException e){
      ctx.setRollbackOnly();
      throw e;
      }
      catch(AccessGroupDoesntExistException e){
      ctx.setRollbackOnly();
      throw e;
      }
      }



      Below is examples om my ejb-jar.xml file and I since I dont manage to attach the Bean implementations I include them to. The ejb-jar.xml file is generated using XDoclet. I do not use the jbosscmp-jdbc.xml file generated since it contains errors in the relation mapping. Do I have to use that file in the latest JBoss?



      <![CDATA[No Description.]]>

      <ejb-name>AccessGroup</ejb-name>

      <local-home>com.proventek.scj.user.internalinterfaces.AccessGroupLocalHome</local-home>
      com.proventek.scj.user.internalinterfaces.AccessGroupLocal

      <ejb-class>com.proventek.scj.user.implementation.AccessGroupBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.proventek.scj.user.internalinterfaces.AccessGroupPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>AccessGroup</abstract-schema-name>
      <cmp-field >
      <![CDATA[Returns the id]]>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the name]]>
      <field-name>name</field-name>
      </cmp-field>


      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(a) FROM AccessGroup AS a WHERE a.name = ?1]]></ejb-ql>


      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(c) FROM AccessGroup c]]></ejb-ql>






      <![CDATA[No Description.]]>

      <ejb-name>User</ejb-name>

      <local-home>com.proventek.scj.user.internalinterfaces.UserLocalHome</local-home>
      com.proventek.scj.user.internalinterfaces.UserLocal

      <ejb-class>com.proventek.scj.user.implementation.UserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.proventek.scj.user.internalinterfaces.UserPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>User</abstract-schema-name>
      <cmp-field >
      <![CDATA[Returns the id]]>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the userid]]>
      <field-name>userId</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the password]]>
      <field-name>password</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the firstname]]>
      <field-name>firstName</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the lastname]]>
      <field-name>lastName</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the email]]>
      <field-name>email</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the personnumber]]>
      <field-name>personNumber</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the adress]]>
      <field-name>adress</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the zipcode]]>
      <field-name>zipCode</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the city]]>
      <field-name>city</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the country]]>
      <field-name>country</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the homephone]]>
      <field-name>homePhone</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the mobilephone]]>
      <field-name>mobilePhone</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the workphone]]>
      <field-name>workPhone</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the startdate]]>
      <field-name>startDate</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the stopdate]]>
      <field-name>stopDate</field-name>
      </cmp-field>


      <query-method>
      <method-name>findByUserId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(a) FROM User AS a WHERE a.userId = ?1]]></ejb-ql>


      <query-method>
      <method-name>findUsersInAccessGroup</method-name>
      <method-params>
      <method-param>java.lang.Long</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(a) FROM User AS a, IN(a.aG) AS ag WHERE ag.id = ?1]]></ejb-ql>


      <query-method>
      <method-name>findUsersNotInAccessGroup</method-name>
      <method-params>
      <method-param>java.lang.Long</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(a) FROM User a]]></ejb-ql>


      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(c) FROM User c]]></ejb-ql>







      <ejb-relation >
      <ejb-relation-name>accessgroup-user</ejb-relation-name>
      <!-- bidirectional -->
      <ejb-relationship-role >
      <ejb-relationship-role-name>one-accessgroup-has-many-users</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>AccessGroup</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>users</cmr-field-name>
      <cmr-field-type>java.util.Set</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role >
      <ejb-relationship-role-name>one-user-belongs-to-many-accessgroups</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>User</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>aG</cmr-field-name>
      <cmr-field-type>java.util.Set</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      package com.proventek.scj.user.implementation;
      import com.proventek.scj.sequencegenerator.internalinterfaces.*;

      /**
      * @author Middlegen
      *
      * @ejb:bean
      * type="CMP"
      * cmp-version="2.x"
      * name="AccessGroup"
      * local-jndi-name="com.proventek.scj.user.internalinterfaces.AccessGroup"
      * view-type="local"
      *
      * @ejb:pk class="com.proventek.scj.user.internalinterfaces.AccessGroupPK"
      *
      * @ejb:util generate="physical"
      *
      *
      * @ejb:finder
      * signature="com.proventek.scj.user.internalinterfaces.AccessGroupLocal findByName(java.lang.String name)"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(a) FROM AccessGroup AS a WHERE a.name = ?1"
      * result-type-mapping="Local"
      *
      * @ejb:finder
      * signature="java.util.Collection findAll()"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(c) FROM AccessGroup c"
      * result-type-mapping="Local"
      *
      * @weblogic:table-name ACCESSGROUP
      * @weblogic:data-source-name middlegen.database
      * @weblogic:persistence
      *
      * @jboss:table-name ACCESSGROUP
      */
      public abstract class AccessGroupBean implements javax.ejb.EntityBean {
      SequenceSessionLocal aSequence;
      /**
      * Context set by container
      */
      private javax.ejb.EntityContext _entityContext;

      /**
      * Returns the id
      *
      * @return the id
      *
      * @ejb:persistent-field
      * @ejb:pk-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column ID
      *
      * @jboss:column-name ID
      */
      public abstract java.lang.Long getId();

      /**
      * Sets the id
      *
      * @param id the new id
      */
      public abstract void setId(java.lang.Long id);

      /**
      * Returns the name
      *
      * @return the name
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column NAME
      *
      * @jboss:column-name NAME
      */
      public abstract java.lang.String getName();

      /**
      * Sets the name
      *
      * @param name the new name
      * @ejb:interface-method view-type="local"
      */
      public abstract void setName(java.lang.String name);

      /**
      * @return the users the users that belongs to this group
      *
      * @ejb:interface-method view-type="local"
      * @ejb:relation
      * name="accessgroup-user"
      * role-name="one-accessgroup-has-many-users"
      * target-role-name="one-user-belongs-to-many-accessgroups"
      * target-multiple="yes"
      *
      * @weblogic:column-map
      * foreign-key-column="user_id"
      * key-column="id"
      *
      * @jboss:target-relation related-pk-field="id"
      * fk-column="user_id"
      */
      public abstract java.util.Set getUsers();

      /**
      * Sets the users
      *
      * @param users the new users
      * @ejb:interface-method view-type="local"
      */
      public abstract void setUsers(java.util.Set users);


      /**
      * When the client invokes a create method, the EJB container invokes the ejbCreate method.
      * Typically, an ejbCreate method in an entity bean performs the following tasks:
      *
      * Inserts the entity state into the database.
      * Initializes the instance variables.
      * Returns the primary key.
      *
      *
      * @param data the data object used to initialise the new instance
      * @return the primary key of the new instance
      *
      * @ejb:create-method
      */
      public com.proventek.scj.user.internalinterfaces.AccessGroupPK ejbCreate(String name, com.proventek.scj.user.internalinterfaces.UserLocal[] users) throws javax.ejb.CreateException {
      return this.ejbCreate(name);
      }

      /**
      * When the client invokes a create method, the EJB container invokes the ejbCreate method.
      * Typically, an ejbCreate method in an entity bean performs the following tasks:
      *
      * Inserts the entity state into the database.
      * Initializes the instance variables.
      * Returns the primary key.
      *
      *
      * @param data the data object used to initialise the new instance
      * @return the primary key of the new instance
      *
      * @ejb:create-method
      */
      public com.proventek.scj.user.internalinterfaces.AccessGroupPK ejbCreate(String name) throws javax.ejb.CreateException {
      try{
      //get next key
      setId(new Long(aSequence.getNextKey(SequenceInternalDefinitions.DEFAULT_SEQUENCE_NAME)));
      setName(name);
      }
      catch(Exception e){
      System.out.println("AccessGroupBean:ejbCreate Exception " + e);
      throw new javax.ejb.EJBException(e);
      }
      return null;
      }

      /**
      * The container invokes thos method immediately after it calls ejbCreate.
      *
      * @param data the data object used to initialise the new instance
      */
      public void ejbPostCreate(String name, com.proventek.scj.user.internalinterfaces.UserLocal[] users) throws javax.ejb.CreateException {
      java.util.Set usersSet = getUsers();
      for(int i=0;i<users.length;i++){
      usersSet.add(users);
      }
      }

      /**
      * The container invokes thos method immediately after it calls ejbCreate.
      *
      * @param data the data object used to initialise the new instance
      */
      public void ejbPostCreate(String name) throws javax.ejb.CreateException {

      }


      // Implementation of the javax.ejb.EntityBean interface methods

      /**
      * The container invokes setEntityContext just once - when it creates the bean instance.
      */
      public void setEntityContext(javax.ejb.EntityContext entityContext) {
      _entityContext = entityContext;
      aSequence = SequenceStatic.getSequence();
      }

      /**
      * At the end of the life cycle, the container removes the instance from
      * the pool and invokes this method.
      */
      public void unsetEntityContext() {
      _entityContext = null;
      }

      /**
      * The container invokes this method to instruct the instance to synchronize its
      * state by loading it state from the underlying database.
      */
      public void ejbLoad() {
      }

      /**
      * The container invokes this method when the instance is taken out of the pool of
      * available instances to become associated with a specific EJB object.
      */
      public void ejbActivate() {
      }

      /**
      * The container invokes this method on an instance before the instance becomes
      * disassociated with a specific EJB object.
      */
      public void ejbPassivate() {
      }

      /**
      * The container invokes this method before it removes the EJB object that is
      * currently associated with the instance.
      */
      public void ejbRemove() throws javax.ejb.RemoveException {
      }

      /**
      * The container invokes this method to instruct the instance to synchronize its
      * state by storing it to the underlying database.
      */
      public void ejbStore() {
      }
      }


      package com.proventek.scj.user.implementation;
      import com.proventek.scj.sequencegenerator.internalinterfaces.*;

      /**
      * @author Middlegen
      *
      * @ejb:bean
      * type="CMP"
      * cmp-version="2.x"
      * name="User"
      * local-jndi-name="com.proventek.scj.user.internalinterfaces.UserLocal"
      * view-type="local"
      *
      * @ejb:pk class="com.proventek.scj.user.internalinterfaces.UserPK"
      *
      * @ejb:util generate="physical"
      *
      * @ejb:finder
      * signature="com.proventek.scj.user.internalinterfaces.UserLocal findByUserId (java.lang.String userId)"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(a) FROM User AS a WHERE a.userId = ?1"
      * result-type-mapping="Local"
      *
      * @ejb:finder
      * signature="java.util.Collection findUsersInAccessGroup(java.lang.Long group)"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(a) FROM User AS a, IN(a.aG) AS ag WHERE ag.id = ?1"
      * result-type-mapping="Local"
      *
      * @ejb:finder
      * signature="java.util.Collection findUsersNotInAccessGroup(java.lang.Long group)"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(a) FROM User a"
      * result-type-mapping="Local"
      *
      * @ejb:finder
      * signature="java.util.Collection findAll()"
      * unchecked="true"
      * query="SELECT DISTINCT OBJECT(c) FROM User c"
      * result-type-mapping="Local"
      *
      * @weblogic:table-name USER
      * @weblogic:data-source-name middlegen.database
      * @weblogic:persistence
      *
      * @jboss:table-name USER
      */
      public abstract class UserBean implements javax.ejb.EntityBean {
      SequenceSessionLocal aSequence;

      /**
      * Context set by container
      */
      private javax.ejb.EntityContext _entityContext;

      /**
      * Returns the id
      *
      * @return the id
      *
      * @ejb:persistent-field
      * @ejb:pk-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column ID
      *
      * @jboss:column-name ID
      */
      public abstract java.lang.Long getId();

      /**
      * Sets the id
      *
      * @param id the new id
      */
      public abstract void setId(java.lang.Long id);

      /**
      * Returns the userid
      *
      * @return the userid
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column USERID
      *
      * @jboss:column-name USERID
      */
      public abstract java.lang.String getUserId();

      /**
      * Sets the userid
      *
      * @param userid the new userid
      * @ejb:interface-method view-type="local"
      */
      public abstract void setUserId(java.lang.String userid);

      /**
      * Returns the password
      *
      * @return the password
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column PASSWORD
      *
      * @jboss:column-name PASSWORD
      */
      public abstract java.lang.String getPassword();

      /**
      * Sets the password
      *
      * @param password the new password
      * @ejb:interface-method view-type="local"
      */
      public abstract void setPassword(java.lang.String password);

      /**
      * Returns the firstname
      *
      * @return the firstname
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column FIRSTNAME
      *
      * @jboss:column-name FIRSTNAME
      */
      public abstract java.lang.String getFirstName();

      /**
      * Sets the firstname
      *
      * @param firstname the new firstname
      * @ejb:interface-method view-type="local"
      */
      public abstract void setFirstName(java.lang.String firstname);

      /**
      * Returns the lastname
      *
      * @return the lastname
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column LASTNAME
      *
      * @jboss:column-name LASTNAME
      */
      public abstract java.lang.String getLastName();

      /**
      * Sets the lastname
      *
      * @param lastname the new lastname
      * @ejb:interface-method view-type="local"
      */
      public abstract void setLastName(java.lang.String lastname);

      /**
      * Returns the email
      *
      * @return the email
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column EMAIL
      *
      * @jboss:column-name EMAIL
      */
      public abstract java.lang.String getEmail();

      /**
      * Sets the email
      *
      * @param email the new email
      * @ejb:interface-method view-type="local"
      */
      public abstract void setEmail(java.lang.String email);

      /**
      * Returns the personnumber
      *
      * @return the personnumber
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column PERSONNUMBER
      *
      * @jboss:column-name PERSONNUMBER
      */
      public abstract java.lang.String getPersonNumber();

      /**
      * Sets the personnumber
      *
      * @param personnumber the new personnumber
      * @ejb:interface-method view-type="local"
      */
      public abstract void setPersonNumber(java.lang.String personnumber);

      /**
      * Returns the adress
      *
      * @return the adress
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column ADRESS
      *
      * @jboss:column-name ADRESS
      */
      public abstract java.lang.String getAdress();

      /**
      * Sets the adress
      *
      * @param adress the new adress
      * @ejb:interface-method view-type="local"
      */
      public abstract void setAdress(java.lang.String adress);

      /**
      * Returns the zipcode
      *
      * @return the zipcode
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column ZIPCODE
      *
      * @jboss:column-name ZIPCODE
      */
      public abstract java.lang.String getZipCode();

      /**
      * Sets the zipcode
      *
      * @param zipcode the new zipcode
      * @ejb:interface-method view-type="local"
      */
      public abstract void setZipCode(java.lang.String zipcode);

      /**
      * Returns the city
      *
      * @return the city
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column CITY
      *
      * @jboss:column-name CITY
      */
      public abstract java.lang.String getCity();

      /**
      * Sets the city
      *
      * @param city the new city
      * @ejb:interface-method view-type="local"
      */
      public abstract void setCity(java.lang.String city);

      /**
      * Returns the country
      *
      * @return the country
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column COUNTRY
      *
      * @jboss:column-name COUNTRY
      */
      public abstract java.lang.String getCountry();

      /**
      * Sets the country
      *
      * @param country the new country
      * @ejb:interface-method view-type="local"
      */
      public abstract void setCountry(java.lang.String country);

      /**
      * Returns the homephone
      *
      * @return the homephone
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column HOMEPHONE
      *
      * @jboss:column-name HOMEPHONE
      */
      public abstract java.lang.String getHomePhone();

      /**
      * Sets the homephone
      *
      * @param homephone the new homephone
      * @ejb:interface-method view-type="local"
      */
      public abstract void setHomePhone(java.lang.String homephone);

      /**
      * Returns the mobilephone
      *
      * @return the mobilephone
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column MOBILEPHONE
      *
      * @jboss:column-name MOBILEPHONE
      */
      public abstract java.lang.String getMobilePhone();

      /**
      * Sets the mobilephone
      *
      * @param mobilephone the new mobilephone
      * @ejb:interface-method view-type="local"
      */
      public abstract void setMobilePhone(java.lang.String mobilephone);

      /**
      * Returns the workphone
      *
      * @return the workphone
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column WORKPHONE
      *
      * @jboss:column-name WORKPHONE
      */
      public abstract java.lang.String getWorkPhone();

      /**
      * Sets the workphone
      *
      * @param workphone the new workphone
      * @ejb:interface-method view-type="local"
      */
      public abstract void setWorkPhone(java.lang.String workphone);

      /**
      * Returns the startdate
      *
      * @return the startdate
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column STARTDATE
      *
      * @jboss:column-name STARTDATE
      */
      public abstract long getStartDate();

      /**
      * Sets the startdate
      *
      * @param startdate the new startdate
      * @ejb:interface-method view-type="local"
      */
      public abstract void setStartDate(long startdate);

      /**
      * Returns the stopdate
      *
      * @return the stopdate
      *
      * @ejb:persistent-field
      * @ejb:interface-method view-type="local"
      *
      * @weblogic:dbms-column STOPDATE
      *
      * @jboss:column-name STOPDATE
      */
      public abstract long getStopDate();

      /**
      * Sets the stopdate
      *
      * @param stopdate the new stopdate
      * @ejb:interface-method view-type="local"
      */
      public abstract void setStopDate(long stopdate);

      /**
      * @return the accessgroup the accessgroups that this user bellongs to
      *
      * @ejb:interface-method view-type="local"
      * @ejb:relation
      * name="accessgroup-user"
      * role-name="one-user-belongs-to-many-accessgroups"
      * target-role-name="one-accessgroup-has-many-users"
      * target-multiple="yes"
      *
      * @weblogic:column-map
      * foreign-key-column="accessgroup_id"
      * key-column="id"
      *
      * @jboss:target-relation related-pk-field="id"
      * fk-column="accessgroup_id"
      */
      public abstract java.util.Set getAG();

      /**
      * Sets the accessgroups
      *
      * @param accessgroups the new accessgroups
      * @ejb:interface-method view-type="local"
      */
      public abstract void setAG(java.util.Set accessGroups);

      /**
      * When the client invokes a create method, the EJB container invokes the ejbCreate method.
      * Typically, an ejbCreate method in an entity bean performs the following tasks:
      *
      * Inserts the entity state into the database.
      * Initializes the instance variables.
      * Returns the primary key.
      *
      *
      * @param data the data object used to initialise the new instance
      * @return the primary key of the new instance
      *
      * @ejb:create-method
      */
      public com.proventek.scj.user.internalinterfaces.UserPK ejbCreate(String userId, String password, String firstName, String lastName, String email,
      String personNumber, String adress, String zipCode, String city,
      String country, String homePhone, String mobilePhone, String workPhone, long startDate, long stopDate) throws javax.ejb.CreateException {
      try{
      //get next key
      setId(new Long(aSequence.getNextKey(SequenceInternalDefinitions.DEFAULT_SEQUENCE_NAME)));
      setUserId(userId);
      setPassword(password);
      setFirstName(firstName);
      setLastName(lastName);
      setEmail(email);
      setPersonNumber(personNumber);
      setAdress(adress);
      setZipCode(zipCode);
      setCity(city);
      setCountry(country);
      setHomePhone(homePhone);
      setWorkPhone(workPhone);
      setMobilePhone(mobilePhone);
      setStartDate(startDate);
      setStopDate(stopDate);
      return null;
      }
      catch(Exception e){
      System.out.println("UserBean:ejbCreate Exception " + e);
      throw new javax.ejb.EJBException(e);
      }
      }

      /**
      * The container invokes thos method immediately after it calls ejbCreate.
      *
      * @param data the data object used to initialise the new instance
      */
      public void ejbPostCreate(String userId, String password, String firstName, String lastName, String email,
      String personNumber, String adress, String zipCode, String city,
      String country, String homePhone, String mobilePhone, String workPhone, long startDate, long stopDate) throws javax.ejb.CreateException {
      }

      // Implementation of the javax.ejb.EntityBean interface methods

      /**
      * The container invokes setEntityContext just once - when it creates the bean instance.
      */
      public void setEntityContext(javax.ejb.EntityContext entityContext) {
      _entityContext = entityContext;
      aSequence = SequenceStatic.getSequence();

      }

      /**
      * At the end of the life cycle, the container removes the instance from
      * the pool and invokes this method.
      */
      public void unsetEntityContext() {
      _entityContext = null;
      }

      /**
      * The container invokes this method to instruct the instance to synchronize its
      * state by loading it state from the underlying database.
      */
      public void ejbLoad() {
      }

      /**
      * The container invokes this method when the instance is taken out of the pool of
      * available instances to become associated with a specific EJB object.
      */
      public void ejbActivate() {
      }

      /**
      * The container invokes this method on an instance before the instance becomes
      * disassociated with a specific EJB object.
      */
      public void ejbPassivate() {
      }

      /**
      * The container invokes this method before it removes the EJB object that is
      * currently associated with the instance.
      */
      public void ejbRemove() throws javax.ejb.RemoveException {
      }

      /**
      * The container invokes this method to instruct the instance to synchronize its
      * state by storing it to the underlying database.
      */
      public void ejbStore() {
      }
      }

      Why does this work perfect in previous JBoss but not in the latest?

      /Erik

        • 1. Re: M:M relation in latest JBoss
          erikture

          My application works not OK but almost OK in the 3.0.2 release from 27 of August.

          I get some errors not related to the relations. The method shown in my previous post does work in the 3.0.2 release.

          What is the difference between that one and the latest?

          /Erik