Hi,
I want to create a N:M CMR between records in the nuke_file table. Therefore I created 
an Entity Bean which contains the primary key of the nuke_file record an a Set which 
shall contain the primary keys of other records of the nuke_file table. 
But when I try to add a relationship between two records I get this error message:

anonymous wrote : 14:55:19,126 ERROR [Page] Cannot create link entries
  | javax.ejb.DuplicateKeyException: Entity with primary key 35 already exists
  |         at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCInsertPKCreateCommand.beforeInsert(JDBCInsertPKCreateCommand.java:90)
  |         at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:137)
  |         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 $Proxy187.create(Unknown Source)
  | ...
  | 

There is no record inserted into the relation table. For me it looks like it is tried 
to insert an additional record to the nuke_file table instead of the relation.

Here is my realtionship configuration in jbosscmp-jdbc.xml
anonymous wrote : 
  |     <ejb-relation>
  |       <ejb-relation-name>ParentLink</ejb-relation-name>
  |       <relation-table-mapping>
  |         <table-name>nuke_file_link</table-name>
  |           <create-table>false</create-table>
  |           <remove-table>false</remove-table>
  |       </relation-table-mapping>
  | 
  |       <ejb-relationship-role>
  |           <ejb-relationship-role-name>Parent-has-Links</ejb-relationship-role-name>
  |           <key-fields>
  |              <key-field>
  |                <field-name>fileId</field-name>
  |                <column-name>pn_id</column-name>
  |              </key-field>
  |           </key-fields>
  | 
  |           <read-ahead>
  |             on-find
  |           </read-ahead>
  |       </ejb-relationship-role>
  |       <ejb-relationship-role>
  |           <ejb-relationship-role-name>Link-has-Parents</ejb-relationship-role-name>
  |           <key-fields>
  |              <key-field>
  |                <field-name>fileId</field-name>
  |                <column-name>pn_id</column-name>
  |              </key-field>
  |           </key-fields>
  | 
  |       </ejb-relationship-role>
  |     </ejb-relation>
  |     
  |     
  |     
  | 

And the ejb-jar.xml
anonymous wrote : 
  |       <ejb-relation >
  |          <ejb-relation-name>ParentLink</ejb-relation-name>
  | 
  |          <ejb-relationship-role >
  |             
<ejb-relationship-role-name>Parent-has-Links</ejb-relationship-role-name>
  |             Many
  |             <relationship-role-source >
  |                <ejb-name>ServiceFileEJB</ejb-name>
  |             </relationship-role-source>
  |             <cmr-field >
  |                <cmr-field-name>links</cmr-field-name>
  |                <cmr-field-type>java.util.Collection</cmr-field-type>
  |             </cmr-field>
  |          </ejb-relationship-role>
  | 
  |          <ejb-relationship-role >
  |             
<ejb-relationship-role-name>Link-has-Parents</ejb-relationship-role-name>
  |             Many
  |             <relationship-role-source >
  |                <ejb-name>ServiceFileEJB</ejb-name>
  |             </relationship-role-source>
  |          </ejb-relationship-role>
  | 
  |             
  |       </ejb-relation>
  |       
  |               
  |     

Who may tell me what is wrong?

Thanks
tj99de

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3844403#3844403

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3844403


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to