[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - deployment problem with CMP (1:n relation)

y0ur1 do-not-reply at jboss.com
Mon Mar 10 08:54:50 EDT 2008


Hi, im using:
- EJB21
- JBoss 4.2.2.GA
- Java 1.5.0.14

I have a one-to-many relationship: Customer - Books, very straightforward. I keep getting the following error when i deploy my application:

  | org.jboss.deployment.DeploymentException: Configuration found in jbosscmp-jdbc.xml for relation Customer-Book but relation is not a jbosscmp-jdbc-managed relation in ejb-jar.xml
  | 

When i don't use jbosscmp-jdbc.xml it deploys but the table books doesnt contain a foreign key with the customerid. Is there anyone who can help me with this problem?

Here is my ejb-jar.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <ejb-jar 
  | 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"
  | version="2.1">
  | 
  | 	<enterprise-beans>
  | 		<entity>
  | 			<ejb-name>Book</ejb-name>
  | 			<home>BookHome</home>
  | 			<remote>Book</remote>
  | 			<ejb-class>BookEntity</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>Book</abstract-schema-name>
  | 			<cmp-field>
  | 				<field-name>bookid</field-name>
  | 			</cmp-field>
  | 			<cmp-field>
  | 				<field-name>title</field-name>
  | 			</cmp-field>
  | 			
  | 			<primkey-field>bookid</primkey-field>
  | 		</entity>
  | 		
  | 		<entity>
  | 			<ejb-name>Customer</ejb-name>
  | 			<home>CustomerHome</home>
  | 			<remote>Customer</remote>
  | 			<ejb-class>CustomerEntity</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>Customer</abstract-schema-name>
  | 			<cmp-field>
  | 				<field-name>customerid</field-name>
  | 			</cmp-field>
  | 			<cmp-field>
  | 				<field-name>name</field-name>
  | 			</cmp-field>
  | 
  | 			<primkey-field>customerid</primkey-field>
  | 		</entity>
  | 		
  | 		
  | 		<relationships>	
  | 			<ejb-relation>	
  | 				<ejb-relation-name>Customer-Book</ejb-relation-name>
  | 		
  | 				<ejb-relationship-role>
  | 					<ejb-relationship-role-name>Book-has-customer</ejb-relationship-role-name>
  | 					<multiplicity>Many</multiplicity>
  | 					<relationship-role-source>
  | 						<ejb-name>BookEntity</ejb-name>
  | 					</relationship-role-source>
  | 					<cmr-field>
  | 						<cmr-field-name>customerid</cmr-field-name>
  | 					</cmr-field>
  | 				</ejb-relationship-role>	
  | 				
  | 				<ejb-relationship-role>
  | 					<ejb-relationship-role-name>Customer-has-books</ejb-relationship-role-name>
  | 					<multiplicity>One</multiplicity>
  | 					<relationship-role-source>
  | 						<ejb-name>CustomerEntity</ejb-name>
  | 					</relationship-role-source>
  | 					<cmr-field>
  | 						<cmr-field-name>books</cmr-field-name>
  | 						<cmr-field-type>java.util.Collection</cmr-field-type>
  | 					</cmr-field>
  | 				</ejb-relationship-role>
  | 			</ejb-relation>
  | 		</relationships>
  | 	</enterprise-beans>
  | </ejb-jar>
  | 

jbosscmp-jdbc.xml:

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <jbosscmp-jdbc>
  |   <relationships>
  |     <ejb-relation>
  |       <ejb-relation-name>Customer-Book</ejb-relation-name>
  |       <foreign-key-mapping/>
  |     </ejb-relation>   
  |   </relationships>
  | 
  | </jbosscmp-jdbc>
  | 

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

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



More information about the jboss-user mailing list