Re: Am I using EOUtilities.createAndInsertInstance() correctly?
Re: Am I using EOUtilities.createAndInsertInstance() correctly?
- Subject: Re: Am I using EOUtilities.createAndInsertInstance() correctly?
- From: MacFirst <email@hidden>
- Date: Mon, 21 Mar 2005 09:30:12 -0800
on 3/21/05 9:21 AM, Des Oates <email@hidden> went on and on saying, in
part:
> Apparently not. I'm getting a class cast exception when I call this
> method like this:
>
> MyObject mo = (MyObject) EOUtilities.createAndInsertInstance(myEC,
> "MyObject");
>
> Where:
>
> MyObject extends MyGenericObject extends EOGenericRecord
>
> (which extends EOCustomObject which implements EOEnterpriseObject --
> The return type of EOUtilities.createAndInsertInstance() )
>
> So, although the inheritance hierarchy is a bit unwieldy, it shouldn't
> behave like this should it? The code is returning a valid
> EOEnterpriseObject. I know this since, I modified the code to:
>
> EnterpriseObject eo = EOUtilitiesAndInsertInstance(myEC, "MyObject")
> MyObject mo = (MyObject) eo;
>
> Then I still get the ClassCastException, but its thrown on execution of
> the second line. If I stop the code before executing the cast then I
> have a valid, populated EOEnterpriseObject in my Eclipse watch window.
>
> So, either I'm missing something embarrassing, there's a bug in this
> WO code, or I'm not using this utility method as it was intended.
The fact that you can execute the CreateAndInsert and get a valid EO
demonstrates that you're using it properly.
The fact that you get a class-cast executing this line:
MyObject mo = (MyObject) eo;
Demonstrates that you're missing something embarrassing ;)
I'm going to go out on a limb and suggest that, despite what you may think,
MyObject does not extend EOEnterpriseObject, making the class-cast invalid.
_______________________________________________
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