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]

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
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