-
1. Re: Persistent arrays of entity beans in an entity bean
frank Sep 3, 2001 4:14 PM (in response to lk)You can refer in the detail beans to the master bean using a foreign key, that is add a field to the one bean (the foreign key) which refers to the many bean.
-
2. Re: Persistent arrays of entity beans in an entity bean
lk Sep 6, 2001 9:31 AM (in response to lk)What exactly is "many bean"? So far I have to implement a BPM-type bean and create additional table in the database holding information about one-to-many references among my beans (the many-sided bean may be CMP-type).
-
3. Re: Persistent arrays of entity beans in an entity bean
andreas Sep 6, 2001 10:15 AM (in response to lk)Check out EJB 2.0 persistance.
(For jBoss, at the moment, only available with a add on from mvcsoft.com) -
4. Re: Persistent arrays of entity beans in an entity bean
ghilling Sep 10, 2001 8:10 AM (in response to lk)You cannot save an array of beans because this is neither a simple Java type nor a serializable
Object.
Get yourself Handles to the Objects and put them into a Container. This is a serializable Object so this Method works (at least for me). You will just have to re-get the Objects from the Handles ...
(If this works for me only by chance please mail me a note...)
-Gunnar -
5. Re: Persistent arrays of entity beans in an entity bean
haytona Sep 10, 2001 11:30 PM (in response to lk)Storing an array of primary key objects for the related beans rather than handles should give better flexibility and performance at the expense of "good" OO principals (IMHO).
I made a simple example using an Order EJB which has many OrderLine EJBs. Each OrderLine has only one Order. Classic 1-N relationship. I stored the Order PrimaryKey (in my case a string) in the OrderLine and when i wanted to get the order lines for an order I called order.getOrderLines() which returned a collection of OrderLine references. This method called findByOrderId(order.getId()) from the OrderLineHome interface. Seemed to work ok for me. It is possible to do n-n relationships like this too.
For more info see www.geocities.com/haytona/reltut/ for more info and code examples.
hope this helps
hamish