Hi,
You dont even have to call account.setCustomer(customer)
since this kind of referential integrity at the object level should be
taken care by the container based on the ejb-jar.xml where you specify if
the relationship is gonna be uni-directional or bi-directional.
This should work.
And yes ! either Customer-table should have the account_id or the other
way round both dont have to refer eachother in the DB-schema to implement a
1-many relationship.
Since Customer has many accounts, accounts-table has to refer customer,
means Account table has a foreignKey reference to Customer PK. As I told you
the other way round also works. But work fine as long as you map the
object-fields to DB-fields appropriately.
Hope this helps.
Regards,
kris
-----Original Message-----
From: Senthilkumar ,T.P (CTC) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 8:09 AM
To: [EMAIL PROTECTED]
Subject: Re: 1 - many relation ship
Hi,
You don't need act_id in Customer table because customer table is your
master table.
TPS
-----Original Message-----
From: Ashwani Kalra [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 5:02 PM
To: [EMAIL PROTECTED]
Subject: 1 - many relation ship
Hi,
First let give table structure to explain my problem
Customer Account
------------ ------------
cust_id(Primary Key) act_ id
name balance
act_id cust_id
I am trying the 1-many relation ship example(customer has many accounts) on
weblogic 6.1. When I try to establish an account(act_id=1,bal=100) with the
customer(cust_id=1,name=ashwani) I do the following
1. In CustomerBean class add this acct to the collection of accounts already
existing . 2. call setAccounts(Collection) 3. call
account.setCustomer(Customer)
What I see in the database is
Customer
-----------
Cust_id name act_id
1 ashwani <<empty>>
Account
-----------
Acct_id bal cust_id
1 100 1
My Question is why the field act_id in customer table is empty??Do I really
need the act_id field in the Customer table. I think Customer is master
table while account is transation table which keeps mapping between account
and customer.
Regds
Ashwani
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".