[EMAIL PROTECTED] penned > Here is our CreditApplicationBean relationships pasted below. > I have this relationship for products to a credit application:
The problem is that the CMR definition and the database schema are not aligned. AFAIK, entity bean CMR do not allow for a discriminator (your product type), which is precisely what you need in this case. Without it, the CMR layer cannot tell which product row belongs to which of the four relationships. So it simply picks the first one it finds and assigns it to each one. I see two solutions to your problem, neither of them trivial. 1. Change the database to store the Product's PK as an FK in the CreditApplication table -- once for each type of Product. This is not so cool because it limits the types of products physically, requiring a data model change to add a new product type. It also seems backwards. The upshot is that it's relatively easy. 2. Change the relationship from four 1:1 CMRs into a single 1:N CMR. You can still have an accessor for each type of product, but it won't be the abstract CMR accessor. Here's one example /** @ejb.relation ... */ public abstract Collection getProducts ( ) ; public BusinessCardLocal getBusinessCard ( ) { Collection allProducts = getProducts(); for ( Iterator i = allProducts.iterator() ; i.hastNext() ; ) { ProductLocal product = (ProductLocal) i.next(); if ( product.getType().equals(BUSINESS_CARD_TYPE) ) { return (BusinessCardLocal) product; } } } Clearly, this method is far more involved. For one thing, you need to implement inheritence of entity beans, and I have no idea what affect that will have on the use of Value Objects. Given your time constraint (and control of the database schema), I would go with the first solution. Off the top of my head, I believe it would only require the schema change and altering your XDoclet CMR tags to move the foreign key. Good luck! -- David Harkness Sony Pictures Digital Sr. Software Engineer 310.482.4756 [EMAIL PROTECTED] Those who judge the value of advice by its source will at once dismiss the best and follow the worst. ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user