• 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
many-to-many insert/edit relationship [w PWO identification scheme]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

many-to-many insert/edit relationship [w PWO identification scheme]


  • Subject: many-to-many insert/edit relationship [w PWO identification scheme]
  • From: kadoudal <email@hidden>
  • Date: Sat, 21 May 2005 09:58:02 +0200

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

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


------- 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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: many-to-many insert/edit relationship [w PWO identification scheme]
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: Java 101 ? question about return values (lost)
  • Next by Date: Re: many-to-many insert/edit relationship
  • Previous by thread: Re: Exception occurred while handling request: ... Unable to createpage....
  • Next by thread: Re: many-to-many insert/edit relationship [w PWO identification scheme]
  • Index(es):
    • Date
    • Thread