On 2-Oct-08, at 10:04 AM, Awbrey Hughlett wrote:
I am getting a classCastException from this when I invoke
saveChanges(). What am I doing wrong again?
First providing pretty unreadable stacktraces, second not looking at
the exact line where that is given to you in the stacktrace, third
mixing getter/setter usage with direct ivar usage, forth some basic
things:
private ERXEC ec = new ERXEC();
This should be
private EOEditingContext ec = ERXEC.newEditingContext();
or
private ERXEC ec = (ERXEC) ERXEC.newEditingContext();
public Basic aBasic = new Basic();
public Specific aSpecific = new Specific();
Ouch. If you want to do that right, make e.g. in the constructor
something like this:
aBasic = EOUtilities.createAndInsertInstance(editingContext(),
Basic.ENTITY_NAME);
and so on for the others.
But I don't understand what you are using these for. Is that for the a
selection binding of a popup button or so? Than this is one of the
problems. What are you trying to achieve on that page?
public Listing listing() {
if (listing == null) {
ec.revert();
listing = (Listing)EOUtilities.createAndInsertInstance(ec,
"Listing");
}
return listing;
}
Okay.
public NSArray allSpecificTypes() {
return EOUtilities.objectsForEntityNamed(ec, "Specific");
}
That seems for me, you are using an array for some kind of repetition
where you select one element from and want to set that to a
relationship on the listing.
What you need is the array of objects, an "item" object for e.g. the
popup button and the "selection" binding set to the target property.
listing().setLastModified(new NSTimestamp());
listing().setUserId(1);
Argl? Are you exposing primary keys here? Are your primary keys class
properties? Don't do that!
listing().addObjectToPropertyWithKey(aSpecific, "specific");
listing().addObjectToPropertyWithKey(aBasic, "basics");
Don't do that either. Use addObjectToBothSidesOfRelationshipWithKey or
one of the relationship setters on your listing classes (addTo...
methods).
setBasic(null);
setSpecific(null);
setListing(null);
What is that for?
With what I understand from your code, you'll have two unrelated
objects dangling around:
private Basic basic = new Basic();
private Specific specific = new Specific();
These are there in the ec, you'll save them (or get a validation
exception if they have any required attribute).
It would help if you give more information of what you want to do and
how your datastructure looks like.
cug
--
Real World WebObjects Bootcamp at the Big Nerd Ranch:
http://www.bignerdranch.com/classes/real-world_webobjects.shtml
_______________________________________________
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]