(solved) Re: Fetch objects: Error in MYSQL or WO
(solved) Re: Fetch objects: Error in MYSQL or WO
- Subject: (solved) Re: Fetch objects: Error in MYSQL or WO
- From: "Cheong Hee (Datasonic)" <email@hidden>
- Date: Fri, 20 Apr 2007 12:24:30 +0800
How could Class Cast Exception happen in the first place? (though both
subclass from Template..)
Indeed, yes. Both are inherited from a common superclass.
I am migrating the data from FrontBase into MySQL. All the data and primary
key are created through EOF *perfectly* , then I attempted to port over them
to MySQL. I did some changes in the model as the following:
Previously..
ProjectExecutionTemplate <- inherited from - Template
ProjectActorRoleTemplate <-inherited from - ActorRoleTemplate
to...
ProjectExecutionTemplate <- inherited from - Template
ProjectActorRoleTemplate <-inherited from - ActorRoleTemplate <- now
inherited from - Template
This is the root cause of the problem, *EO inheritance hierarchy needs a
unique PK*! Thanks for pointing out, Chuck.
Cheers
Cheong Hee
----- Original Message -----
From: "Chuck Hill" <email@hidden>
To: "Cheong Hee (Datasonic)" <email@hidden>
Cc: "WO-Apple-Dev" <email@hidden>
Sent: Friday, April 20, 2007 1:00 AM
Subject: Re: Fetch objects: Error in MYSQL or WO
It sounds to me like ProjectExecutionTemplate and
ProjectActorRoleTemplate both share a common EO superclass. __ALL__
objects in an EO inheritance hierarchy need a unique PK. Not just unique
in their table, unique across ALL tables in the hierarchy. EOF should do
this by default, if you have edited the data manually or are importing it
or some such, that is exactly what causes this problem.
Chuck
On Apr 19, 2007, at 1:27 AM, Cheong Hee (Datasonic) wrote:
I have an application that is using this fetch defined in
"getAllObjects":
....
EOFetchSpecification fs = new EOFetchSpecification
("ProjectExecutionTemplate", nameQualifier, null, true, true,
sortOrdering);
NSArray foundList = context.objectsWithFetchSpecification(fs);
.....etc
Everything "seems" working, however when fetch this particular table,
this message has thrown out :: It was complaining the class cast
exception that instead of ProjectExecutionTemplate, WO looks that the
objects fetched are of ProjectActorRoleTemplate class!! The SQL trace
shows correctly that all 12 rows are fetched.
=== trace 1 === error
[2007-04-19 16:00:17 SGT] <WorkerThread0> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
DISTINCT t0.ABBREVIATION_NAME, t0.CODE, t0.IS_ACTIVE, t0.IS_DEFAULT,
t0.SEQUENCE_NUMBER, t0.TEMPLATE_KEY, t0.VDESCRIPTION, t0.VNAME FROM
PROJECT_EXECUTION_TEMPLATE t0 WHERE UPPER(t0.VNAME) LIKE UPPER(?) ESCAPE
'|'" withBindings: 1:"%"(vName)>
[2007-04-19 16:00:17 SGT] <WorkerThread0> 12 row(s) processed
[2007-04-19 16:00:17 SGT] <WorkerThread0> === Commit Internal
Transaction
java.lang.ClassCastException: com.rhino.model.ProjectActorRoleTemplate
at com.rhino.model.ProjectExecutionTemplate.getAllObjects
(ProjectExecutionTemplate.java:206)
at ProjectExecutionPage.initializeDisplayGroup
(ProjectExecutionPage.java:110)
So, spent some time on error searching... and finally reach a point that
if I changed the primary key in ProjectExecutionTemplate database, e.g.:
(NULL,NULL,1,NULL,NULL,1000007,NULL,'Design/Development'), ==> changed
to
(NULL,NULL,1,NULL,NULL,10007,NULL,'Design/Development'), ==> Note that
"1000007" to "10007"
When run the app again, everything worked! See below:
==== trace 2 ==== good one
[2007-04-19 16:03:45 SGT] <WorkerThread1> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
DISTINCT t0.ABBREVIATION_NAME, t0.CODE, t0.IS_ACTIVE, t0.IS_DEFAULT,
t0.SEQUENCE_NUMBER, t0.TEMPLATE_KEY, t0.VDESCRIPTION, t0.VNAME FROM
PROJECT_EXECUTION_TEMPLATE t0 WHERE UPPER(t0.VNAME) LIKE UPPER(?) ESCAPE
'|'" withBindings: 1:"%"(vName)>
[2007-04-19 16:03:45 SGT] <WorkerThread1> 12 row(s) processed
[2007-04-19 16:03:45 SGT] <WorkerThread1> === Commit Internal
Transaction
So what my question is: what has gone wrong actually?
Primary key overflow?
Faults in MYSQL or WO or "programmer"? (primary key is defined as
int(11) in MYSQL)
How could Class Cast Exception happen in the first place? (though both
subclass from Template..)
Puzzled....Appreciate comments. [WO5.2.4/MYSQL v 5.0.22]
Cheers
Cheong Hee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
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