How to represent Master and Detail Tables in Entity Bean?

Hi All,

I have 2 tables now. One is master table and the other one is table showing details of master table. So, primary key fields in detail table are foreign keys of master table.

If it is so, how can I represent these 2 tables using Entity Bean? Should I use one entity bean for each table? Or there should be better solution for this situation?

Thanks a lot!!!

[403 byte] By [hoson] at [2007-9-26 2:44:52]
# 1

well the easy solution is that u use one Bean per table

and in the Maste Table define some some business method

i presume ur navigating from master to detail just find the value of the field which is the foreign key in the details table from the Master Bean and get the details by using a findbyPrimarykey method of the detail bean

simple

but if ur using one bean only then there is a problem and even i want its solution . i dont know what entries i have to make in the deployment descriptors

hope that u will share any results with me

atifumar at 2007-6-29 10:25:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
hihave one ejb for both tables. first write master logic then write details logic in case of insertion in ejbCreate, etc.
m_s_mansoor at 2007-6-29 10:25:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

If you are using CMP you might as well use Container Managed Relations. Make one MasterEJB and one DetailEJB, and let the MasterEJB have a 1:1 or 1:* relation to DetailEJB. Use the cascade delete CMR feature to make sure details are deleted along with their master (if that's what you want).

--

Jon Martin Solaas

jonmartin.solaas@mail.link.no

http://solaas.minidns.net

jonmartin at 2007-6-29 10:25:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Hello,Weblogic 8.1 can span across multiple tables? How to implement this if primary key is different in 2 tables?Rgds,Seetesh
seeteshh at 2007-6-29 10:25:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...