Re: many-to-many insert/edit relationship [w PWO identification scheme]
Re: many-to-many insert/edit relationship [w PWO identification scheme]
- Subject: Re: many-to-many insert/edit relationship [w PWO identification scheme]
- From: Chuck Hill <email@hidden>
- Date: Tue, 24 May 2005 10:41:18 -0700
On May 21, 2005, at 12:58 AM, kadoudal wrote:
I use the identification scheme described in PWO
AbstractUser entity (abstract class)
-> SIteUser entity extends AbstractUser (implements the password
control) // I use SiteUser as MySQL doesn't like User !)
-> Administrator entity extends SiteUser (type=9)
I also have a Language entity in my DB (one language , english,
already written)
I defined a many-to-many relationship 'languages' (JOIN table)
between SiteUser and Language entities
First off, don't do this! See page 36. Having a relation from each
language to each user is eventually going to kill performance. I
really doubt that you need the relationship in that direction very
often. It will be far, far better to just do a fetch if you (ever)
need it.
When trying to insert my first Administrator, I got an error...
An exception occurred while trying to save administrator language
com.webobjects.eoaccess.EOObjectNotAvailableException:
objectMatchingValueForKeyEntityNamed: No AbstractUser found with key
login matching anon
("Entity Administrator has a reference to class EOGenericRecord which
can not be loaded.")
remarks :
"No AbstractUser found with key login matching anon" : strange !
Administrator is a subclass of AbstractUser
and the login data is set...
"reference to class EOGenericRecord which can not be loaded ": strange
! cannot be loaded as it's not yet written into the DB
Sounds like maybe something is wrong in the model where you set up the
inheritance.
Chuck
------- here is my code, in AdminPage ( extends ValidatingPage)
public void createAdministrator(){
EOEditingContext ec = editingContext();
ec.lock();
try {
Administrator.authenticatedUser(ec, "anon", "emouse");
} catch (EOObjectNotAvailableException e) {
Administrator anAdministrator = new Administrator();
ec.insertObject(anAdministrator);
anAdministrator.setLogin("anon");
anAdministrator.setPassword("emouse");
Language englishLanguage = null;
try {
englishLanguage = (Language)
EOUtilities.objectMatchingKeyAndValue(ec, "Language", "languageCode",
"en");
} catch(Exception ex) {}
if (englishLanguage != null) {
anAdministrator.setMotherTongue(englishLanguage);
anAdministrator.addObjectToBothSidesOfRelationshipWithKey(englishLangua
ge, "languages");
this.attemptSave();
if (errors().count()>0) {
System.out.println("An exception occurred while
trying to save administrator data " );
System.out.println(errors().toString());
}
}
} finally {
ec.unlock();
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development 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