Teaching vertical inheritance to me ?
Teaching vertical inheritance to me ?
- Subject: Teaching vertical inheritance to me ?
- From: Wolfram Stebel <email@hidden>
- Date: Mon, 15 Nov 2004 11:39:21 +0100
Hello all,
i have a complex application with a complex data modell.
I choose vertical inheritance for a classical businespartner<-->person and
businespartner<-->mandant object structure (and more derived objects).
In my code i do the following:
CMandant newMandant = CMandant.newMandant ( ec );
CPerson newPerson = CPerson.newPersonForMandantAndPerson ( ec,
newMandant, null ); // relation to mandant and "self" is set!
where ec is the EOEditingContext, in which the Objects insert themself after
creation.
Later on I do:
ec.saveChanges ();
PROBLEM 1:
- All initialization via " awakeFromInsertion" for the vertical derived
classes have to be handled in the derived class.
- When i have a "awakeFromInsertion" in the base class, the construction
cycle fails.
Probably because WO does "awakeFromInsertion" for "Mandant" and i call
"super" in there, which is "Businespartner", aaaannnndddd WO calls
"awakeFromInsertion" for the same "Businespartner" too.
QUESTION: Are all accessors of the base class unused? May i remove the
"member" carret in EOModeller?
PROBLEM 2:
- The above mentioned objects (2 businespartners and 1 person and 1 mandant)
are inserted into the database with the ec.saveChanges ().
- The reduced but still lengty sql trace shows 5 inserts where the last
fails:
A:
[2004-11-15 10:42:54 CET] <WorkerThread4> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO
MANDANT(MASCOT_PICT, ...., SHOP_MAP) VALUES (NULL, ....., NULL)"
withBindings: 1:0(test_duration), 2:1(pk_bupa), 3:1(fk_clubtype_key),
4:"gast"(mandant_alias), 5:2(allow_non_public), 6:1(fk_legalform_key),
7:2004-11-15 10:42:38(valid_since), 8:0(show_billing)>
B:
[2004-11-15 10:42:54 CET] <WorkerThread4> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO
BUSINESPARTNER(DIRECT_DEBIT, ....., NAMEADD_2) VALUES (?, ....., NULL)"
withBindings: 1:0(businespartner_direct_debit), 2:0(businespartner_type),
3:1(NeededByEOF0), 4:2004-11-15 10:42:38(businespartner_bupa_upd_date),
5:"Vereinsname"(businespartner_name), 6:1(businespartner_bupa_active),
7:2004-11-15 10:42:38(businespartner_bupa_create_date)>
C:
[2004-11-15 10:42:54 CET] <WorkerThread4> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO
PERSON(IS_USER, ....., LAST_LOGIN) VALUES (?, ....., ?)" withBindings:
1:0(is_user), 2:""(user_pw_answer), 3:2(pk_bupa), 4:0(children_count),
5:2004-11-15 10:42:42(date_from), 6:1(fk_personstatus_key), 7:"Someones
Name"(user_pw_question), 8:0(should_pick), 9:"gast"(user_pw), 10:2004-11-15
10:42:42(last_login)>
D:
[2004-11-15 10:42:54 CET] <WorkerThread4> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO
BUSINESPARTNER(DIRECT_DEBIT, ....., NAMEADD_2) VALUES (?, ......., NULL)"
withBindings: 1:0(businespartner_direct_debit), 2:0(businespartner_type),
3:"Vorname"(businespartner_firstname), 4:2(NeededByEOF0),
5:"MitgliedsNummer"(businespartner_key_1), 6:2004-11-15
10:42:42(businespartner_bupa_upd_date), 7:"gast"(businespartner_name),
8:2(businespartner_bupa_active), 9:2004-11-15
10:42:42(businespartner_bupa_create_date)>
E:
[2004-11-15 10:42:54 CET] <WorkerThread4> evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO
BUSINESPARTNER(NAMEADD_1, ......, PUBLISH_PRIV) VALUES (NULL, .......,
NULL)" withBindings: 1:1(pk_bupa)>
SQLException: SQLState(23000) vendor code(1062) msg: Duplicate key or
integrity constraint violation message from server: "Duplicate entry '1' for
key 1"
The objects are connected via "pk_bupa". As you can see, Mandant has a
binding to it ("1") and Person too ("2"). In my understanding, the first two
busonespartner should have a binding too, but they dont have.
Instead a third businespartner is inserted with an only binding for pk_bupa
("1") followed by an error.
The 4 data sets have been written to the database with correct pk_bupa's.
QUESTION: What the h... happens?
Is the binding "NeededByEOF0" the internaly used "pk_bupa"?
Why is there a third businespartner inserted (and probably a fourth...)?
Does anybody know a bit about this?
Do the two problems interfer, so that initialisation and persistence
influence each other?
Does the vertical inheritance technic work in real life?
In short: is it my fault??? :-)
AND NOTE:
WebObjects can not handle attributes called "alias" (i dont know why i used
this possibly reserved word :-) as a field name ), it will replace bindings
not correctly.
Thanks for your Help.
Dipl. Inform. Wolfram Stebel, bugs&errors
Flutgrabenstr. 19, 35576 Wetzlar
Tel. 06441/47633
Mailto:email@hidden
Web: www.bugs-and-errors.de
_______________________________________________
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