Re: Propagate primary key questions
Re: Propagate primary key questions
- Subject: Re: Propagate primary key questions
- From: Chuck Hill <email@hidden>
- Date: Mon, 23 Jul 2007 10:51:20 -0700
On Jul 23, 2007, at 5:33 AM, James Cicenia wrote:
Well I was tired....
Anyway,,, I think EO was messing with my head. I thought for some
reason I read that EO would create an eo automatically if it was
mandatory and with propagate key.
It will. BUT. This happens when the owning EO is _created_ and
inserted into an editing context. If you change the model after you
create it you are on your own.
Well this was the first time I was trying to use that portion of
EOModeler. It failed me miserably.
It works just fine for what it is intended to do.
Couple with the fact that I was doing a one table vertical
inheritance. Unfortunately it wouldn't work with my multiple to-one
relationships as they can't use the qualifier in the key which
makes EO balk.
I have no idea what all that means. :-)
Chuck
So I went back to my old way and explicitly did everything and
everything works.
And yes I know about:
NSArray fetchPortfolio = EOUtilities.objectsForEntityNamed(session
().defaultEditingContext(), "Portfolio");
It was a bit of old code that should have been refactored.
- James
On Jul 22, 2007, at 7:14 PM, Chuck Hill wrote:
On Jul 21, 2007, at 4:45 PM, James Cicenia wrote:
Hello -
I am adding a new table to the database and a new EO object that
I want to be created automatically via owns destination and
propagate key.
However, this is after the fact. Now, I guess I just don't
understand but the following code to add the related record is
giving me the following errors.
I must be tired, or blind, but I don't understand the problem.
EOEditingContext ec = session().defaultEditingContext();
EOFetchSpecification fetchPortfolio = new EOFetchSpecification();
fetchPortfolio.setEntityName("Portfolio");
NSArray fetchPortfolios = (ec.objectsWithFetchSpecification
(fetchPortfolio)).immutableClone();
Cough.
NSArray fetchPortfolio = EOUtilities.objectsForEntityNamed(session
().defaultEditingContext(), "Portfolio");
Cough.
for(int i=0;i<fetchPortfolios.count();i++){
Portfolio portfolio = (Portfolio) fetchPortfolios.objectAtIndex
(i);
PortfolioNotifications pn = (PortfolioNotifications)
EOUtilities.createAndInsertInstance(ec, "PortfolioNotifications");
pn.setPortfolio(portfolio);
System.out.println("pn.portfolio.name is "+pn.portfolio().title
());
portfolio.setNotifications(pn);
ec.saveChanges();
}
However, when it gets to saveChanges it tells me...
errorcom.webobjects.eoaccess.EOObjectNotAvailableException: No
com.tos.eo.PortfolioNotifications found with globalID:
_EOIntegralKeyGlobalID[PortfolioNotifications (java.lang.Integer)16]
That happens to be the row-id of the first portfolio...
What am I missing that is so obvious.
I don't think you are missing anything, I think you are messing
with EOF's head. I really doubt that EOF is going to step in
handle this neatly after the fact. I'd try
- remove owns destination and propagate key
- manually create the global ID using EOKeyGlobalID's
globalIDWithEntityName(String, Object[]) and then inserting it
using insertObjectWithGlobalID(EOEnterpriseObject, EOGlobalID)
- restore owns destination and propagate key
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden