This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Help! Problem using 1:1 CMP Relationship example using JBoss 3.0.0

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to deply Order-Shipment 1:1 CMP example from EdRomans book using JBoss 3.0
as in the book in my ejb-jar.xml I have,
......OrderBean

I have declared two methods in Order entity bean class as

The tables created by JBoss are as follows
Table: Order
------------
Field 1: ORDERID(PK)
Field 2: NAME
Field 3: SHIPMENT
Table: Shipment
Field 1: SHIPMENT(PK)
Field 2: CITY
Field 3: ZIPCODE
Field 4: ORDERS_SHIPMENT
There is no FK constraint created.
Obviously the foriegn key relationship os missing. Where should i specify this. Please help!
[ June 28, 2002: Message edited by: seshu kumar ]
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well how u can see jboss table.form where.can u please tell.Well remember that cmr field should be local.Well i have made example og customer to address of manson hefil which i tested on jboss3.0 works perfactly.I hope it will be use ful for u
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>CustomerEJB</ejb-name>
<remote>com.ssuet.customer.Customer</remote>
<home>com.ssuet.customer.CustomerHome</home>
<ejb-class>com.ssuet.customer.CustomerBean</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>id</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/AddressHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.ssuet.address.AddressHome</local-home>
<local>com.ssuet.address.Address</local>
<ejb-link>AddressEJB</ejb-link>
</ejb-local-ref>
</entity>
<entity>
<ejb-name>AddressEJB</ejb-name>
<local>com.ssuet.address.Address</local>
<local-home>com.ssuet.address.AddressHome</local-home>
<ejb-class>com.ssuet.address.AddressBean</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>Address</abstract-schema-name>
<cmp-field>
<field-name>id</field-name>
</cmp-field>

<cmp-field>
<field-name>street</field-name>
</cmp-field>
<cmp-field>
<field-name>city</field-name>
</cmp-field>

<primkey-field>id</primkey-field>
</entity>
</enterprise-beans>

<relationships>
<!--One-to-one Customer-Address-->
<ejb-relation>
<ejb-relation-name>Customer-Address</ejb-relation-name>
<!--defining relation shipof cstomer-->
<ejb-relationship-role>
<ejb-relationship-role-name>Customer-has-Address</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>CustomerEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>homeAddress</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<!--defining relation shipof address-->
<ejb-relationship-role>
<ejb-relationship-role-name>Address-belongs-to-Customer</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>AddressEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>

</ejb-relation>
</relationships>
</ejb-jar>
 
seshu kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jawwad,
I deployed this app using Oracle as the database. jboss created these tables for me during deployment.
I had earlier defined both local and remote interfaces for my ShipmentEJB. Now i have defined only Local interfaces as suggested in the book (and also in your code).
Still the result is the same.
I still dont know how to specify the foriegn key relationship between ORDER.SHIPMENT and SHIPMENT.SHIPMENT . The cmr field refers only to the Local reference of the SHIPMENT Bean with the Order Bean. How do i specify the foriegn key??
Refering to your code,
You have CUSTOMEREJB(ID(PK),NAME)
and ADDRESSEJB(ID(PK),STREET,CITY)
and a cmr field homeAddress.
How do you get a forign key column in your CUSTOMEREJB table pointing to ADDRESSEJB.ID??
Can you describe the table schema you are using?
 
seshu kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By The way,
The Application is working fine. I'm able to read from the tables properly.
Only the tables created are
Table: Order
------------
Field 1: ORDERID(PK)
Field 2: NAME
Field 3: SHIPMENT
Table: Shipment
Field 1: SHIPMENT(PK)
Field 2: CITY
Field 3: ZIPCODE
Field 4: ORDERS_SHIPMENT
However if I set the following in jboss

and create my own tables as
Table: Order
------------
Field 1: ORDERID(PK)
Field 2: NAME
Field 3: SHIPMENT(FK)
Table: Shipment
Field 1: SHIPMENT(PK)
Field 2: CITY
Field 3: ZIPCODE
When I deploy the app and run my jsp which calls findAllOrders on the OrderEJB I get the following error.

[ June 29, 2002: Message edited by: seshu kumar ]
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well When creating table of customer in oracle specify foregin key of address in customer table.The container will manage automatically to manage relation ship.
Jawwad Ahmed
 
seshu kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I do this. In Which xml should i write the forign key relationhip?
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i just know this the table mapping is done in standardjaws.xml.The relation ship is defined in ejb-jar.xml and the foriegn key is automatically managed ny container.
Jawwad Ahmed
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In jboss2.4.4 ihave define table mapping like this
in statdardjaws.xml
<?xml version="1.0" encoding="UTF-8"?>
<jaws>
<datasource>java:/OracleDB</datasource>
<type-mapping>Oracle8</type-mapping>
<debug>false</debug>
<enterprise-beans>
<entity>
<ejb-name>CustomerEJB</ejb-name>
<table-name>cust</table-name>
<create-table>false</create-table>
<cmp-field>
<field-name>id</field-name>
<column-name>ID</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>NAME</column-name>
</cmp-field>
</entity>
</enterprise-beans>

Jawwad Ahmed
 
The moustache of a titan! The ad of a flea:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic