2 Replies Latest reply: Jun 21, 2004 1:17 AM by raj_kumar RSS

unexpected problem with one to one relationship

raj_kumar Newbie

hello ....
i'm using one to one unidirectional relationship between two entity
beans but i'm not able to ... here primary key of the one table is the
foreign key and primary key of second table .

the stack trace is (Trace is enables )


2004-06-16 16:19:48,435 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.RSCTP] Executing SQL: SELECT COUNT(*) FROM rsctp WHERE RSCTPID=?
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#rsCTPID] Set parameter: index=1, jdbcType=INTEGER, value=401100000
2004-06-16 16:19:48,435 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.RSCTP] Executing SQL: INSERT INTO rsctp (RSCTPID, SlotPort, SwitchName, RS, OperationalStatus, SinkOperationalStatus, SourceOperationalStatus, STMLevel, RSCTPMode, XConnectObjectPointer, ConnectionStatus, OpticalPortID, rsttp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#rsCTPID] Set parameter: index=1, jdbcType=INTEGER, value=401100000
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#slotPort] Set parameter: index=2, jdbcType=INTEGER, value=401
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#switchName] Set parameter: index=3, jdbcType=VARCHAR, value=Lecsar
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#rs] Set parameter: index=4, jdbcType=INTEGER, value=1
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#operationalStatus] Set parameter: index=5, jdbcType=INTEGER, value=0
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#sinkOperationalStatus] Set parameter: index=6, jdbcType=INTEGER, value=0
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#sourceOperationalStatus] Set parameter: index=7, jdbcType=INTEGER, value=0
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#stmLevel] Set parameter: index=8, jdbcType=INTEGER, value=2
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#rsCTPMode] Set parameter: index=9, jdbcType=INTEGER, value=2
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#xConnectObjectPointer] Set parameter: index=10, jdbcType=INTEGER, value=1
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#connectionStatus] Set parameter: index=11, jdbcType=INTEGER, value=1
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#opticalPortID] Set parameter: index=12, jdbcType=INTEGER, value=401000000
2004-06-16 16:19:48,435 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.RSCTP#rsCTPID] Set parameter: index=13, jdbcType=INTEGER, value=NULL
2004-06-16 16:19:48,450 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.RSCTP] Could not create entity
java.sql.SQLException: Column not found, message from server: "Unknown column 'rsttp' 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(Unknown Source)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
 at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(Unknown Source)
 at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.executeInsert(JDBCAbstractCreateCommand.java:326)
 at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:287)
 at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:138)
 at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:554)
 at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:208)
 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:269)
 at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:324)
 at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1043)
 at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
 at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197)
 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214)
 at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
 at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89)
 at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
 at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
 at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98)
 at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
 at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
 at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
 at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:483)
 at org.jboss.ejb.Container.invoke(Container.java:720)
 at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:293)
 at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
 at $Proxy292.create(Unknown Source)
 at com.le.nms.persistence.configupdate.OpticalPortBean.setRSCTP(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:324)
 at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1096)
 at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
 at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:282)
 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
 at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:114)
 at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
 at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
 at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
 at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
 at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
 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:489)
 at org.jboss.ejb.Container.invoke(Container.java:700)
 at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
 at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
 at $Proxy322.setRSCTP(Unknown Source)
 at com.le.nms.domain.configupdate.ConfigMesgBean.storeIntoRSCTPTable(Unknown Source)
 at com.le.nms.domain.configupdate.ConfigMesgBean.storeIntoDB(Unknown Source)
 at com.le.nms.domain.configupdate.ConfigMesgBean.handleGetResponse(Unknown Source)
 at com.le.nms.domain.configupdate.ConfigMesgBean.handleResponse(Unknown Source)
 at com.le.nms.domain.configupdate.ConfigMesgBean.onMessage(Unknown Source)
 at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:324)
 at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:460)
 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
 at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:240)
 at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
 at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
 at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
 at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
 at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374)
 at org.jboss.ejb.Container.invoke(Container.java:700)
 at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:824)
 at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1114)
 at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
 at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:633)
 at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:433)
 at org.jboss.mq.SpySession.run(SpySession.java:298)
 at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:732)
 at java.lang.Thread.run(Thread.java:534)


there is a CMR feild name "rsttp" .... i'm not able to understand that why
it takes as an CMP feild as u see in the trace...."INSERT INTO rsctp".

and the second thing is while setting the parameters of rsctp table
there are 12 feilds, but it sets in the 1st and 13th parameters ..... and rsCTPID is an
primary key but in trace i can see that it sets the value of rsCTPID
two times (at the 13th parameter) and at the second time it sets as null.

these are my deployment descriptors:-




EJB-JAR:----------

 CMP FIELDS:------------

<abstract-schema-name>rsctp</abstract-schema-name>
 <cmp-field>
 <field-name>rsCTPID</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>slotPort</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>switchName</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>rs</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>operationalStatus</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>sinkOperationalStatus</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>sourceOperationalStatus</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>stmLevel</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>rsCTPMode</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>xConnectObjectPointer</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>connectionStatus</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>opticalPortID</field-name>
 </cmp-field>
 <primkey-field>rsCTPID</primkey-field>
 </entity>
 <entity>
 <ejb-name>ElectricalPort</ejb-name>
 <local-home>com.le.nms.persistence.configupdate.ElectricalPortLocalHome</local-home>
 <local>com.le.nms.persistence.configupdate.ElectricalPortLocal</local>
 <ejb-class>com.le.nms.persistence.configupdate.ElectricalPortBean</ejb-class>
 <persistence-type>Container</persistence-type>
 <prim-key-class>java.lang.Integer</prim-key-class>
 <reentrant>False</reentrant>
 <cmp-version>2.x</cmp-version>
 <abstract-schema-name>electricalPort</abstract-schema-name>
 <cmp-field>
 <field-name>electricalPortID</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>slotPort</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>switchName</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>stmLevel</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>electricalMode</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>miPortMode</field-name>
 </cmp-field>
 <cmp-field>
 <field-name>connectionStatus</field-name>
 </cmp-field>
 <primkey-field>electricalPortID</primkey-field>

RELATIONSHIPS (EJB_JAR)--------------

<ejb-relation>
 <ejb-relation-name>RSCTP and RSTTP</ejb-relation-name>
 <ejb-relationship-role>
 <ejb-relationship-role-name>Each RSCTP has one RSTTP</ejb-relationship-role-name>
 <multiplicity>One</multiplicity>
 <relationship-role-source>
 <ejb-name>RSCTP</ejb-name>
 </relationship-role-source>
 <cmr-field>
 <cmr-field-name>rsttp</cmr-field-name>
 </cmr-field>
 </ejb-relationship-role>
 <ejb-relationship-role>
 <ejb-relationship-role-name>RSTTP to RSCTP</ejb-relationship-role-name>
 <multiplicity>One</multiplicity>
 <cascade-delete/>
 <relationship-role-source>
 <ejb-name>RSTTP</ejb-name>
 </relationship-role-source>
 </ejb-relationship-role>
 </ejb-relation>


JBOSS-CMP JDBC .---------

ENTITY TAG:------------

<entity>
 <ejb-name>RSCTP</ejb-name>
 <table-name>rsctp</table-name>
 <cmp-field>
 <field-name>rsCTPID</field-name>
 <column-name>RSCTPID</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>slotPort</field-name>
 <column-name>SlotPort</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>switchName</field-name>
 <column-name>SwitchName</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>rs</field-name>
 <column-name>RS</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>operationalStatus</field-name>
 <column-name>OperationalStatus</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>sinkOperationalStatus</field-name>
 <column-name>SinkOperationalStatus</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>sourceOperationalStatus</field-name>
 <column-name>SourceOperationalStatus</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>stmLevel</field-name>
 <column-name>STMLevel</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>rsCTPMode</field-name>
 <column-name>RSCTPMode</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>xConnectObjectPointer</field-name>
 <column-name>XConnectObjectPointer</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>connectionStatus</field-name>
 <column-name>ConnectionStatus</column-name>
 </cmp-field>
 <cmp-field>
 <field-name>opticalPortID</field-name>
 <column-name>OpticalPortID</column-name>
 </cmp-field>
</entity>


RELATIONSHIP tag--------
<ejb-relation>
 <ejb-relation-name>RSCTP and RSTTP</ejb-relation-name>
 <foreign-key-mapping/>
 <ejb-relationship-role>
 <ejb-relationship-role-name>Each RSCTP has one RSTTP
</ejb-relationship-role-name>
 <key-fields>
 <key-field>
 <field-name>rsCTPID</field-name>
 <column-name>RSCTPID</column-name>
 </key-field>
 </key-fields>
 </ejb-relationship-role>
 <ejb-relationship-role>
 <ejb-relationship-role-name>RSTTP to RSCTP</ejb-relationship-role-name>
 </ejb-relationship-role>
 </ejb-relation>







i dont understand why this problem is comming ....

can u tell me where i'm going wrong ?.... how can we set the one to one relationship .....why such an error is comming .


-- if i set it into one to many relationship then everything works fine
but in one to one it is not working .............


Thanks
Raj...........

  • 1. Re: unexpected problem with one to one relationship
    Alexey Loubyansky Master

    The DDs seem to be correct. What JBoss version?

  • 2. Re: unexpected problem with one to one relationship
    raj_kumar Newbie

    hi alex .....

    i really apologize for replying u late ....but i got the solution
    but i really dont know the actual cause behing it ...while doing hit and trials i just thought the key exist in the both the table (EJB)...and i did little change in the deployment descriptor ...in the jbosscmp-jdbc.xml i changes the follwing in relationship:----



    EARLIER IT WAS--------------
    
    <ejb-relation>
     <ejb-relation-name>RSCTP and RSTTP</ejb-relation-name>
     <foreign-key-mapping/>
     <ejb-relationship-role>
     <ejb-relationship-role-name>Each RSCTP has one RSTTP
    </ejb-relationship-role-name>
     <key-fields>
     <key-field>
     <field-name>rsCTPID</field-name>
     <column-name>RSCTPID</column-name>
     </key-field>
     </key-fields>
     </ejb-relationship-role>
     <ejb-relationship-role>
     <ejb-relationship-role-name>RSTTP to RSCTP</ejb-relationship-role-name>
     </ejb-relationship-role>
     </ejb-relation>
    


    now i change it to :-

    <ejb-relation>
     <ejb-relation-name>RSCTP and RSTTP</ejb-relation-name>
     <foreign-key-mapping/>
     <ejb-relationship-role>
     <ejb-relationship-role-name>Each RSCTP has one RSTTP
    </ejb-relationship-role-name>
     </ejb-relationship-role>
     <ejb-relationship-role>
     <ejb-relationship-role-name>RSTTP to RSCTP</ejb-relationship-role-name>
    <key-fields>
     <key-field>
     <field-name>rsCTPID</field-name>
     <column-name>RSCTPID</column-name>
     </key-field>
     </key-fields>
    
     </ejb-relationship-role>
     </ejb-relation>
    


    but here RSCTP is an parent EJB and RSTTP is an child ....i thought that the key exist in both the table soo i did this change ....can u pls tell me what is real cause behing this ?.
    i'm using jboss version 3.2.3


    thanks
    Raj........