[solved, sort of] Re: Can't generate new primary keys *sigh*
[solved, sort of] Re: Can't generate new primary keys *sigh*
- Subject: [solved, sort of] Re: Can't generate new primary keys *sigh*
- From: Clark Mueller <email@hidden>
- Date: Sun, 18 Feb 2007 14:04:12 -0700
OK, so a conflict with Wonder's DB delegate is indeed what's going on
here. I implemented the custom PK for one of my entities using
wonder's mechanism, and the problem has gone away. My question then
becomes, is there an easy way that I can have the two db delegates
coexist?
Thanks,
Clark
On 18 Feb 07, at 1:25 PM, Clark Mueller wrote:
Hi all,
I'm getting the evil "failed to generate new primary keys" error
all of a sudden. I use MySQL 5 with the latest JDBC adaptor. I
recently changed the PK type of one of my entities to be textual,
and it caused several other entities to break. None of the
traditional problems seem to be at fault here... I've run into this
before when foreign keys that are mandatory are set as a class
property. That is not the case with any of the affected EOs. I've
heard it can happen when the PK is set as a class property, and I
have turned that on and off, but it didn't make a difference.
Interestingly, the pattern I have noticed is that the only affected
EOs seem to be ones that I generate custom keys for, and they all
have a textual PK value, but it extends beyond the one that I had
just changed, and none of them were having issues previously. My
custom PK generation is very similar to that described in the WO
documentation. In a nutshell, i have
EODatabaseContext.setDefaultDelegate(new mix.app.PrimaryKeyGenerator
()), and within that class, it looks like:
public NSDictionary databaseContextNewPrimaryKey
(EODatabaseContext context, Object o, EOEntity entity){
log.debug("A request came through to generate a new PK for
context: " + context + "; object: " + o + "; entity: " +
entity.name());
if( entity.name().equals("FMCustomer") ){
return getPrimaryKeyForCustomer(context, o, entity);
} else if( entity.name().equals("Repair") ){
return getPrimaryKeyForRepair(context, o, entity);
// etc.
} else{
return null;
}
}
My own logic is not ever getting called. I stuck a debug message in
ERXDatabaseContext.databaseContextNewPrimaryKey(), and it IS
getting called, so I'm suddenly suspicious that that's the problem,
but I never see the app making an effort to generate a numerical
key (e.g. a fetch to EO_PK_TABLE), which should be what's happening
then.
Questions:
- Would Wonder's ERXDatabaseContext be interfering with my own? It
hasn't before... I recently reordered my classpath a bit, but I
don't think it coincided with this. And ERExtensions didn't move in
relation to my PK generator. How can I direct Wonder (or EOF) to
use my own code? I am aware that Wonder has its own interface for
custom PKs, but I'd prefer not to use it if I don't have to.
- What else might cause this error? I've Googled this to death,
almost, and I can't find a solution that works.
Thanks,
Clark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
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