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: kadoudal <email@hidden>
- Date: Wed, 25 May 2005 07:15:37 +0200
Re read... Yes ! I 'll use definitly a one-sided relationship...
As I used a connection dictionnary as stated in your example, I
forgot to change the connection data in the connection dictionary
as in EOModeler so I had a mix and mismatch between my test DB and
WPO example test DB.....
thanks for putting me back on trail....
btw: I'll buy also a DVD of your next session training if ever
produced ! sorry I'm living so far from California (or Canada)
Erwin
Le 24 mai 05 à 19:41, Chuck Hill a écrit :
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
(englishLanguage, "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:
40global-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