Re: Setting up horizontal inheritance
Re: Setting up horizontal inheritance
- Subject: Re: Setting up horizontal inheritance
- From: Chuck Hill <email@hidden>
- Date: Tue, 4 Nov 2008 13:51:59 -0800
On Nov 4, 2008, at 1:42 PM, Paul Hoadley wrote:
On 05/11/2008, at 5:25 AM, Chuck Hill wrote:
On Nov 4, 2008, at 1:50 AM, Paul Hoadley wrote:
1. I have a framework that contains a model Auth that contains an
entity Person. It also contains the UserPreference entity that
has a to-one relationship to Person. Person is abstract.
2. I have an app that contains a model AMAuth that contains an
entity AMPerson. I created AMPerson by subclassing Person in the
Auth model (nominating HI), and then cut + pasting over the
entries for AMPerson in index.eomodeld, and AMPerson.plist to the
AMAuth model. I changed the package on the class appropriately.
(Is there an easier way to generate a cross-model sub-entity?)
3. I have set up the tables using the SQL generated by Entity
Modeler. This creates both 'person' and 'amperson', as well as
'person_seq' and 'amperson_seq'. The sequences get linked to
their corresponding id columns to generate PKs. For the
'userpreference' table, I dropped the FK constraint to person.id.
4. I loaded the 'amperson' table with my set of test users.
How are you doing that, exactly?
With raw SQL and psql. Outside of EOF. So after inserting 6 test
users, amperson_seq is sitting at last_value = 6, and person_seq is
sitting at last_value = 1. Is this the problem? If the PKs need to
be unique across all sub-entities, should the tables be using a
common sequence?
EOF will only use person_seq. That is going to be a problem if you
create any new objects. When you insert into amperson, you MUST use
the person_seq sequence. That said, it does not sound like the cause
of your current WOe. It will be the cause of your next one... :-)
No, its happening on an update to a timestamp column on the
child. Worse, it's only happening the second time the app tries
an update on that column. It's the lastLogin attribute. I can
log in, and the column gets updated:
[2008-11-3 20:52:46 CST] <WorkerThread0> === Begin Internal
Transaction
[2008-11-3 20:52:46 CST] <WorkerThread0> evaluateExpression:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "UPDATE
amperson SET last_login = ?::timestamp WHERE id = ?::int4"
withBindings: 1:2008-11-03 20:52:46.912(lastLogin), 2:3(id)>
[2008-11-3 20:52:46 CST] <WorkerThread0> === Commit Internal
Transaction
Then if I log out, and back in:
[2008-11-3 20:53:3 CST] <WorkerThread1> === Begin Internal
Transaction
[2008-11-3 20:53:3 CST] <WorkerThread1> evaluateExpression:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "UPDATE
amperson SET last_login = ?::timestamp WHERE id = ?::int4"
withBindings: 1:2008-11-03 20:53:03.434(lastLogin), 2:3(id)>
[2008-11-3 20:53:3 CST] <WorkerThread1> === Rollback Internal
Transaction
[2008-11-3 20:53:3 CST] <WorkerThread1>
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
java.lang.IllegalStateException: rowDiffsForAttributes: snapshot
in com.webobjects.eoaccess.EODatabaseOperation {_dbSnapshot = {};
_entity = "AMPerson"; _newRow = {lastName = "Turner"; lastLogin =
2008-11-03 10:23:03 Etc/GMT; id = 3; username = "admin"; dob =
1973-06-07 14:30:00 Etc/GMT; password =
"0DPiKuNIrrVmD8IUCuw1hQxNqZc="; firstName = "Turnkey";
lastPWChange = 2007-11-12 13:30:00 Etc/GMT; }; _object = "PERSON:
Turnkey Turner"; _globalID = _EOIntegralKeyGlobalID[AMPerson
(java.lang.Integer)3]; _databaseOperator =
"EODatabaseUpdateOperator"; } does not contain value for
attribute named contactDetailsID with snapshot key:
contactDetailsID
Application.handleException: Handling an Exception:
java.lang.IllegalStateException: rowDiffsForAttributes: snapshot
in com.webobjects.eoaccess.EODatabaseOperation {_dbSnapshot = {};
_entity = "AMPerson"; _newRow = {lastName = "Turner"; lastLogin =
2008-11-03 10:23:03 Etc/GMT; id = 3; username = "admin"; dob =
1973-06-07 14:30:00 Etc/GMT; password =
"0DPiKuNIrrVmD8IUCuw1hQxNqZc="; firstName = "Turnkey";
lastPWChange = 2007-11-12 13:30:00 Etc/GMT; }; _object = "PERSON:
Turnkey Turner"; _globalID = _EOIntegralKeyGlobalID[AMPerson
(java.lang.Integer)3]; _databaseOperator =
"EODatabaseUpdateOperator"; } does not contain value for
attribute named contactDetailsID with snapshot key:
contactDetailsID
Moving around the app a little, I can generate a different
exception:
java.lang.IllegalStateException: initializeObject: No snapshot for
gid _EOIntegralKeyGlobalID[AMPerson (java.lang.Integer)4]
at
com
.webobjects
.eoaccess
.EODatabaseContext.initializeObject(EODatabaseContext.java:3578)
at
com
.webobjects
.eocontrol
.EOObjectStoreCoordinator
.initializeObject(EOObjectStoreCoordinator.java:597)
at
com
.webobjects
.eocontrol.EOEditingContext.initializeObject(EOEditingContext.java:
3752)
at com.webobjects.eoaccess.EODatabaseChannel
$
_EODatabaseChannelFetchResult
.initializeObjects(EODatabaseChannel.java:497)
at
com
.webobjects
.eoaccess
.EODatabaseContext
._objectsWithFetchSpecificationEditingContext
(EODatabaseContext.java:3090)
at
com
.webobjects
.eoaccess
.EODatabaseContext
.objectsWithFetchSpecification(EODatabaseContext.java:3195)
at
com
.webobjects
.eocontrol
.EOObjectStoreCoordinator
.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
at
com
.webobjects
.eocontrol
.EOEditingContext
.objectsWithFetchSpecification(EOEditingContext.java:4053)
at
com
.webobjects
.eocontrol
.EOEditingContext
.objectsWithFetchSpecification(EOEditingContext.java:4428)
at
net
.logicsquad
.webobjects.auth.model.auth._Person.fetchPersons(_Person.java:351)
at
net
.logicsquad
.webobjects
.auth
.model
.auth.Person.fetchAllPersonsForOrganisationSorted(Person.java:213)
(Truncated.)
Person.fetchAllPersonsForOrganisationSorted() above is looking for
the other Persons in the logged-in user's organisation. The
AMPerson with PK=4 is the first such user in 'amperson', so
presumably one of the sub-entities
Which sub-entities?
I meant one of the two AMPersons which should come up with that
query. The only sub-entity of the abstract Person is AMPerson.
required is being found. What is causing this error?
First guess is two objects in an inheritance hierarchy with the
same PK.
I don't have that, since the 'person' table is empty, and the only
other sub-entity is 'amperson'. But I am inserting the initial data
outside EOF, and I do have the issue with the sequences out of sync.
I am still very unsure as to what is happening. Have you checked to
ensure that you are locking the ECs correctly if you are not using the
session's defaultEditingContext, ERXEC etc.?
Chuck
--
Chuck Hill Senior Consultant / VP Development
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