can't seem to get it to work. I don't get it. There's still an error. 
  return anOpportunity.companies().containsObject( currentCompany );
this statement doesn't invoke. it returns a nullpointer exception. Why?

Warmest Regards,
Jim Wong



On 27 Feb 2006, at 1:37 AM, Michael Warner wrote:

An obvious situation in which flattened relationships are not appropriate is the one in which you have attributes that belong directly in the linking table (in this case, the OPPORTUNITY_COMPANY table).
Sometimes you don't anticipate these attributes right away.   With experience you will learn to recognize situations in which it is obvious to you that the only attributes in the  join table will be the two 
primary keys from the other tables, in which case, flattening can be very convenient. 

Mike Warner

On Feb 26, 2006, at 12:08 PM, Mark Morris wrote:

Hello Jim,

You'll be safest if you stick to using flattened relationships for many-to-many's, and for nothing else.

I haven't used Art's method, but he says it'll create the flattened relationship for you, so just leave it at that.  Make sure the non-flattened relationships (the ones directly to and from OPPORTUNITY_CUSTOMER) are not exposed to the class (uncheck the diamond column in EOModeler, and make sure any java classes don't have methods calling those relationships directly).

Finally, you can modify the code I sent earlier like this (and again, I haven't run or debugged this):

public boolean opportunityHasCompany() {
  return anOpportunity.companies().containsObject( currentCompany );
}

public void setOpportunityHasCompany( boolean value ) {
  if( value && !opportunityHasCompany() ) {
      anOpportunity.addObjectToBothSidesOfRelationshipWithKey( currentCompany, "companies" );
  }
  if( !value && opportunityHasCompany() ) {
      companyArray.removeObjectFromBothSidesOfRelationshipWithKey( currentCompany, "companies" );
  }
}

Where "companies" is the flattened many-to-many from Opportunity to Company, anOpportunity is the Opportunity being modified, and currentCompany is the "item" in the WORepetition.

Regards,
Mark

On Feb 26, 2006, at 2:21 AM, Jim Wong wrote:

thanks art. 

what's flattened relationships? i can't catch wat the WO tutorial is talking abt. when do i use flattened and when do i not use? any pros and cons?

Warmest Regards,
Jim Wong



On 26 Feb 2006, at 4:10 PM, Art Isbell wrote:

On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:

I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. 

COMPANY
- companyID (attribute)


OPPORTUNITY
- oppID (attribute)
- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))

OPPORTUNITY_CUSTOMER
- oppID (attribute)
- customerID (attribute)
- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))
- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))

The requirements of a form are:
- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. 
- Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. 

how can i get the above done? how's the coding requirement be like? 

EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.

Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:

opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");

Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord.

Aloha,
Art

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to