1 Reply Latest reply on Nov 24, 2003 9:21 AM by fredatwork

    Help needed for N-N relationship setup

    fredatwork

      Hello everybody,

      I'm trying to setup my first N-N relationship and I have some unexpected failures at runtime (execption thrown by the mysql driver).

      I have a 'List' EJB with a N-N relationship with the 'Equity' EJB. Here is the relevant source code extract for EJB 'List' :

      public abstract class ListBean implements EntityBean {

      .../...

      /**
      * Returns the equities of this list
      * @return a Collection of equities
      *
      * @ejb.interface-method
      *
      * @ejb.relation
      * name="List-Equity"
      * role-name="List is made out of zero or several equities"
      * target-ejb="Equity"
      * target-role-name="Equity belong to zero or several lists"
      * target-multiple="yes"
      *
      * @jboss.relation
      * related-pk-field="ID"
      * fk-column="nsq_eqt"
      *
      * @jboss.target-relation
      * related-pk-field="ID"
      * fk-column="nsq_lst"
      *
      * @jboss.relation-mapping="relation-table"
      *
      * @jboss.relation-table
      * table-name="l02_eqt_lst"
      * create-table="true"
      *
      */
      public abstract Collection getEquities();

      /**
      * @ejb.interface-method
      * view-type="both"
      */
      public abstract void setEquities(Collection equities);

      /**
      * @ejb.interface-method
      * view-type="both"
      */
      public void addEquity(Integer equityID)
      throws EJBHomeFactoryException {
      try {
      EquityLocalHome equityHome = ...
      EquityLocal equity = (EquityLocal) equityHome.findByPrimaryKey(equityID);
      Collection equities = this.getEquities();
      equities.add(equity);
      } catch (FinderException e) {
      // Do nothing : equity not found
      }
      }


      EJB classes were generated using XDoclet.

      Both EJB's were deployed without error, and the relationship table (l02_lst_eqt) was created with both expected foreigh keys colmun at deployment time.


      But, at run-time, when the 'addEquity' method is called on a 'List' EJB instance, the following exception is thrown :
      14:51:44,354 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: null, causedBy:
      java.sql.SQLException: Column not found, message from server: "Unknown column 'create_date' in 'field list'"
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
      at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:289)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:165)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:83)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:634)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:616)
      at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:395)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:232)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:56)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:273)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeAddRelation(JDBCCMRFieldBridge.java:916)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.createRelationLinks(JDBCCMRFieldBridge.java:818)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.add(RelationSet.java:112)
      at com.rubis.app.basics.ejb.ListBean.addEquity(ListBean.java:274)
      .../...

      I have no clue where this 'create_date' field comes from !!!! I have to such field name in my entire database ...

      Thanks in advance for some tip.

      Fred


      PS: I'm using Jboss 3.2.2 and MySql as the database.