Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Beans > Re: EJB 2.0: Co...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1294 of 1403
Post > Topic >>

Re: EJB 2.0: Compount Primary Keys and CMR

by Sascha Effert <fermat@[EMAIL PROTECTED] > Mar 1, 2007 at 03:39 PM

Sascha Effert wrote:

> Hello,
> 
> ist it possible with EJB 2.0 and 2 EJBs (CMP) with Compound Primary
Keays
> to use a CMR? I tried it with Netbeans 5.5 and JBoss 4.0.4. There I got
> following error:
> 
> 14:52:27,539 INFO  [BaseLocalProxyFactory] Bound EJB
>   LocalHome 'StoragePoolBean' to jndi 'local/StoragePoolBean@[EMAIL PROTECTED]
'
> 14:52:27,544 INFO  [ProxyFactory] Bound EJB Home 'StoragePoolBean' to
>   jndi 'StoragePoolBean'
> 14:52:27,551 INFO  [BaseLocalProxyFactory] Bound EJB
>   LocalHome 'VirtualVolumeBean' to jndi
'local/VirtualVolumeBean@[EMAIL PROTECTED]
'
> 14:52:27,556 INFO  [ProxyFactory] Bound EJB Home 'VirtualVolumeBean' to
>   jndi 'VirtualVolumeBean'
> org.jboss.deployment.DeploymentException: Atleast one role of a
> foreign-key
>   mapped relation****p must have key fields (or <primkey-field> is
missing
>   from ejb-jar.xml): ejb-relation-name=SP-contains-VVs
> 
> 
> 
> The Beans seem to be o.k., the CMR not. My config:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
>     <display-name>mda2-EJBModule</display-name>
>     <enterprise-beans>
>         <entity>
>             <display-name>StoragePoolEB</display-name>
>             <ejb-name>StoragePoolBean</ejb-name>
>             <home>de.virticalsolutions.vdrive.mda.StoragePoolRemoteHome
>             </home>
>             <remote>de.virticalsolutions.vdrive.mda.StoragePoolRemote
>             </remote>
>            
<local-home>de.virticalsolutions.vdrive.mda.StoragePoolLocalHome
>             </local-home>
>             <local>de.virticalsolutions.vdrive.mda.StoragePoolLocal
>             </local>
>             <ejb-class>de.virticalsolutions.vdrive.mda.StoragePoolBean
>             </ejb-class>
>             <persistence-type>Container
>             </persistence-type>
>            
<prim-key-class>de.virticalsolutions.vdrive.mda.StoragePoolPK
>             </prim-key-class>
>             <reentrant>false</reentrant>
>             <abstract-schema-name>StoragePool</abstract-schema-name>
> [...]
>         </entity>
>         <entity>
>             <display-name>VirtualVolumeEB</display-name>
>             <ejb-name>VirtualVolumeBean</ejb-name>
>            
<home>de.virticalsolutions.vdrive.mda.VirtualVolumeRemoteHome
>             </home>
>             <remote>de.virticalsolutions.vdrive.mda.VirtualVolumeRemote
>             </remote>
>             <local-home>
>                 de.virticalsolutions.vdrive.mda.VirtualVolumeLocalHome
>             </local-home>
>             <local>de.virticalsolutions.vdrive.mda.VirtualVolumeLocal
>             </local>
>             <ejb-class>de.virticalsolutions.vdrive.mda.VirtualVolumeBean
>             </ejb-class>
>             <persistence-type>Container</persistence-type>
>            
<prim-key-class>de.virticalsolutions.vdrive.mda.VirtualVolumePK
>             </prim-key-class>
>             <reentrant>false</reentrant>
>             <abstract-schema-name>VirtualVolume</abstract-schema-name>
> [...]
>         </entity>
>     </enterprise-beans>
>     <relation****ps>
>         <ejb-relation>
>             <description/>
>             <ejb-relation-name>SP-contains-VVs</ejb-relation-name>
>             <ejb-relation****p-role>
>                 <ejb-relation****p-role-name>SPhasVV
>                 </ejb-relation****p-role-name>
>                 <multiplicity>One</multiplicity>
>                 <relation****p-role-source>
>                     <ejb-name>StoragePoolBean</ejb-name>
>                     </relation****p-role-source>
>                 <cmr-field>
>                     <cmr-field-name>virtualVolumes</cmr-field-name>
>                    
<cmr-field-type>java.util.Collection</cmr-field-type>
>                     </cmr-field>
>                 </ejb-relation****p-role>
>             <ejb-relation****p-role>
>                 <ejb-relation****p-role-name>VVinSP
>                 </ejb-relation****p-role-name>
>                 <multiplicity>Many</multiplicity>
>                 <relation****p-role-source>
>                     <ejb-name>VirtualVolumeBean</ejb-name>
>                     </relation****p-role-source>
>                 <cmr-field>
>                     <cmr-field-name>storagePool</cmr-field-name>
>                     </cmr-field>
>                 </ejb-relation****p-role>
>         </ejb-relation>
>     </relation****ps>
>     <assembly-descriptor>
> [...]
>     </assembly-descriptor>
> </ejb-jar>
> 
> 
>
===========================================================================
> The Primary Keys have no fields of the same name. I also tried to write
> the mapping in the jbosscmp-jdbc. As you will see I used e
relation-table,
> no forign key. But with a forign-key I got the same result. Here is my
> jbosscmp-jdbc.xml:
> 
> <jbosscmp-jdbc>
>     <relation****ps>
>         <ejb-relation>
>             <ejb-relation-name>SP-contains-VVs</ejb-relation-name>
>             <relation-table-mapping>
>                 <table-name>storagepool_has_virtualvolumes</table-name>
>             </relation-table-mapping>
>             <ejb-relation****p-role>
>                 <ejb-relation****p-role-name>SPhasVV
>                 </ejb-relation****p-role-name>
>                 <key-fields>
>                     <key-field>
>                         <field-name>spID</field-name>
>                         <column-name>storagepool</column-name>
>                     </key-field>
>                     <key-field>
>                         <field-name>spSessionID</field-name>
>                         <column-name>storagepool_session</column-name>
>                     </key-field>
>                 </key-fields>
>             </ejb-relation****p-role>
>             <ejb-relation****p-role>
>                 <ejb-relation****p-role-name>VVinSP
>                 </ejb-relation****p-role-name>
>                 <key-fields>
>                     <key-field>
>                         <field-name>vvID</field-name>
>                         <column-name>virtualvolume</column-name>
>                     </key-field>
>                     <key-field>
>                         <field-name>vvSessionID</field-name>
>                         <column-name>virtualvolume_session</column-name>
>                     </key-field>
>                 </key-fields>
>             </ejb-relation****p-role>
>         </ejb-relation>
>     </relation****ps>
> </jbosscmp-jdbc>
> 
>
===========================================================================
> 
> It would be great if someone could explain me what is going wrong here.
At
> the moment I am thinking about not using CMR and make all the
> relation****ps on my own. But I don't think that it's a good solution
> because it would be much more code for me...
> 
> bests
> 
> Sascha Effert

Hello,

sorry: a short enhancement: With the relation table below I get the error:

org.jboss.deployment.DeploymentException: Both roles of a relation-table 
  mapped relation****p must have key fields: 
  ejb-relation-name=SP-contains-VVs

The fieldnames in the jbosscmp-jdbc are the fields in the Primary Key
Cl*****.

bests

Sascha Effert
 




 2 Posts in Topic:
EJB 2.0: Compount Primary Keys and CMR
Sascha Effert <fermat@  2007-03-01 15:16:32 
Re: EJB 2.0: Compount Primary Keys and CMR
Sascha Effert <fermat@  2007-03-01 15:39:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 0:30:26 CST 2008.