• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: To Many to EOs w/ Compound Primary Keys that Include Reverse Foreign Key (+INHERITANCE!!!) -- FIX / WORK-AROUND
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To Many to EOs w/ Compound Primary Keys that Include Reverse Foreign Key (+INHERITANCE!!!) -- FIX / WORK-AROUND


  • Subject: Re: To Many to EOs w/ Compound Primary Keys that Include Reverse Foreign Key (+INHERITANCE!!!) -- FIX / WORK-AROUND
  • From: Lachlan Deck <email@hidden>
  • Date: Mon, 16 Jun 2008 06:57:22 +1000

Hi there,

On 15/06/2008, at 6:00 PM, Robert B.Hanviriyapunt wrote:

Ok. I completely verified that it is a problem (at least for me, who likes to implement inheritance in my entities, big time!)

If you're talking about Vertical Inheritance (i.e., where the parent entity is mapped to a different table) and you have, for example, a toOne mandatory relationship from the parent entity to some other entity, then the foreign key (which is not a class property in the parent entity) must be exposed as a class property in the sub-entity (and allow null in the sub-entity) for the INSERT to work.


-----------------------------
Radar:5219252
EOF fails to generate foreign key in sql (vertical inheritance)
-----------------------------
21-May-2007 08:05 PM Lachlan Deck:
Summary:
EOF is failing to generate the sql binding for foreign keys (i.e., non- class attributes) defined in the parent and flattened to sub-entities (Vertical inheritance) unless you expose the flattened foreign key for the relationship in the sub-entity.


Steps to Reproduce:
1) grab attached model
2) create a new D2W app with the model
3) open the model and generate sql
4) run the app
5) create a company
6) now create an Employee related to above company
7) Message on screen: "Could not save your changes: Object value '2' for column 3 is not an instanceof String"
8) quit
9) Open model again and set flattened foreign key (companyId in Employee) as class attribute.
10) run again. This time it works.


Expected Results:
I expect EOF to generate the foreign keys as it does for any other relationship.


Actual Results:
It's not even producing the foreign key in the sql and is thus attempting to assign a value intended for another column to it - with a JDBC exception being thrown because it naturally was expecting to receive data of a different type.


Regression:
I have tested this extensively over the last 4-5 days on both WO 5.2.4 and WO 5.3.x with the same results. I've tested (as you could see from the mailing list archives under the subject: vertical inheritance) various munging of the model's plist files to no avail. The only work- a-round is expose the flattened foreign key in the sub-entity.


Notes:
The generated sql without exposing the foreign key:
[2007-05-22 11:26:02 EST] <WorkerThread12> === Begin Internal Transaction
[2007-05-22 11:26:02 EST] <WorkerThread12> finding primary key value for Person
[2007-05-22 11:26:02 EST] <WorkerThread12> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT PK FROM EO_PK_TABLE WHERE NAME = 'Person' FOR UPDATE">
[2007-05-22 11:26:02 EST] <WorkerThread12> fetch canceled
[2007-05-22 11:26:02 EST] <WorkerThread12> 1 row(s) processed
[2007-05-22 11:26:02 EST] <WorkerThread12> updating primary key value for Person
[2007-05-22 11:26:02 EST] <WorkerThread12> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE EO_PK_TABLE SET PK = 14 WHERE NAME = 'Person' AND PK = 13">
[2007-05-22 11:26:02 EST] <WorkerThread12> === Commit Internal Transaction
[2007-05-22 11:26:02 EST] <WorkerThread12> === Begin Internal Transaction
[2007-05-22 11:26:02 EST] <WorkerThread12> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO Person(id, lastName, code, created, modified, firstName, entityType) VALUES (?, ?, ?, ?, ?, ?, ?)" withBindings: 1:14(NeededByEOF0), 2:"SaveMe"(lastName), 3:2(code), 4:2007-05-22 00:00:00(created), 5:2007-05-22 00:00:00(modified), 6:"Please"(firstName), 7:"Employee"(entityType)>
[2007-05-22 11:26:02 EST] <WorkerThread12> === Rollback Internal Transaction


The generated sql when the foreign key is exposed:
[2007-05-22 13:17:20 EST] <WorkerThread4> === Begin Internal Transaction
[2007-05-22 13:17:20 EST] <WorkerThread4> finding primary key value for Person
[2007-05-22 13:17:20 EST] <WorkerThread4> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT PK FROM EO_PK_TABLE WHERE NAME = 'Person' FOR UPDATE">
[2007-05-22 13:17:20 EST] <WorkerThread4> fetch canceled
[2007-05-22 13:17:20 EST] <WorkerThread4> 1 row(s) processed
[2007-05-22 13:17:20 EST] <WorkerThread4> updating primary key value for Person
[2007-05-22 13:17:20 EST] <WorkerThread4> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE EO_PK_TABLE SET PK = 27 WHERE NAME = 'Person' AND PK = 26">
[2007-05-22 13:17:20 EST] <WorkerThread4> === Commit Internal Transaction
[2007-05-22 13:17:20 EST] <WorkerThread4> === Begin Internal Transaction
[2007-05-22 13:17:20 EST] <WorkerThread4> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO Person(id, lastName, code, firstName, companyId, modified, created, entityType) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" withBindings: 1:27(NeededByEOF0), 2:"Bob"(lastName), 3:"777777"(code), 4:"Bill"(firstName), 5:2(companyId), 6:2007-05-22 00:00:00(modified), 7:2007-05-22 00:00:00(created), 8:"Employee"(entityType)>
[2007-05-22 13:17:20 EST] <WorkerThread4> evaluateExpression: <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT INTO Employee(id) VALUES (?)" withBindings: 1:27(id)>
[2007-05-22 13:17:20 EST] <WorkerThread4> === Commit Internal Transaction


Please fix/release an update for this soon.

'Inherit3.eomodeld.zip' was successfully uploaded

22-May-2007 07:40 PM Lachlan Deck:
Further to the above, where the work-a-round currently requires exposing the flattened foreign key(s) as class attributes, I've found that the sub-entity must allow-null, regardless of the parent's setting for these attributes, in order for validation (esp in a D2W app) to succeed.


05-Jun-2007 01:50 PM Lachlan Deck:
A further complication comes into play as follows: if you have a parent entity Taggable and one of the sub-entities BinaryInfo that has a Many-to-Many relationship to Taggable via a Join - NeededByEOF0 is not satisfied.
-----------------------------


with regards,
--

Lachlan Deck



_______________________________________________
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


References: 
 >Re: DatabaseContextDelegate + Compound Primary Keys that Include Foreign Keys (+INHERITANCE!!!) (From: Robert B.Hanviriyapunt <email@hidden>)
 >To Many to EOs w/ Compound Primary Keys that Include Reverse Foreign Key (+INHERITANCE!!!) -- FIX / WORK-AROUND (From: Robert B.Hanviriyapunt <email@hidden>)

  • Prev by Date: Re: Using ERMemoryAdaptor
  • Next by Date: Re: ReportMill can't find Framework?
  • Previous by thread: To Many to EOs w/ Compound Primary Keys that Include Reverse Foreign Key (+INHERITANCE!!!) -- FIX / WORK-AROUND
  • Next by thread: Re: DatabaseContextDelegate + Compound Primary Keys that Include Foreign Keys
  • Index(es):
    • Date
    • Thread