• 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
Re: Usercoded database fails to generate PKs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Usercoded database fails to generate PKs


  • Subject: Re: Usercoded database fails to generate PKs
  • From: Ian Joyner <email@hidden>
  • Date: Thu, 22 Jun 2006 11:54:47 +1000


On 21/06/2006, at 9:20 PM, Mike Schrag wrote:

Is Person a subclass of another entity by any chance? If so, you are probably running into

http://en.wikibooks.org/wiki/Programming:WebObjects/EOF/Using_EOF/ Common_Pitfalls_and_Troubleshooting (Subclass Missing Primary Key)

Excellent advice. Thanks for creating this page Mike.

. Is there a reason you're using forceConnectionWithModel rather than just setConnectionDictionary on the EOModel?

A very good reason – it's the code on p 106 of Apple's Enterprise Objects Programming Guide (5.3)! However, as you suggest, setConnectionDictionary works better because it sets the dictionary rather than overrides it, so has the effect of clearing out the jdbc2Info setting.


On investigation, the jdbc2Info only differs in the 'defaultJDBCType' settings, some models have a CLOB type and others a BLOB (although I don't use that), so it looks like this is enough to make EO use a separate connection and thus for some reason not generate PKs. So this following code works:

    public Application () {
	        super ();

NSMutableDictionary d = new NSMutableDictionary ();
d.takeValueForKey (Server_configuration.db_username, "username");
d.takeValueForKey (Server_configuration.db_password, "password");
d.takeValueForKey (Server_configuration.db_URL, "URL");
EOEditingContext ec = new EOEditingContext ();

try {
Enumeration /*[EOModel]*/ e = EOModelGroup.defaultGroup ().models ().objectEnumerator ();

while (e.hasMoreElements ()) {
((EOModel)e.nextElement ()).setConnectionDictionary (d);
}
} catch (Exception x) {
log.fatal ("Problem connecting to database. Reason: " + x.getMessage ());
System.exit (99);
}
}


Thanks again
Ian
Sportstec

For those WhO WOnder what we do, here is a little story at the BBC about our software (not the WO stuff) being used at the WOrld Cup:

http://www.bbcworld.com/content/template_clickonline.asp? pageid=665&co_pageid=3


ms

On Jun 21, 2006, at 3:28 AM, Ian Joyner wrote:

Good evening Mr Phelps,

I have put a usercode and password on our database to restrict any kind of access beneath Enterprise Objects (eg, with OpenBaseManager, but this should be independent of any particular database). I have added code to the Application constructor to log the EOModels into this DB with the following code:

    public Application () {
        	super ();

NSMutableDictionary d = new NSMutableDictionary ();
d.takeValueForKey (Server_configuration.db_username, "username");
d.takeValueForKey (Server_configuration.db_password, "password");
d.takeValueForKey (Server_configuration.db_URL, "URL");
EOEditingContext ec = new EOEditingContext ();

try {
Enumeration e = EOModelGroup.defaultGroup ().models ().objectEnumerator ();

while (e.hasMoreElements ()) {
EODatabaseContext.forceConnectionWithModel ((EOModel) e.nextElement (), d, ec);
}
} catch (Exception x) {
log.fatal ("Problem connecting to database. Reason: " + x.getMessage ());
System.exit (99);
}
}


_______________________________________________
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


References: 
 >Usercoded database fails to generate PKs (From: Ian Joyner <email@hidden>)
 >Re: Usercoded database fails to generate PKs (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: Convert UNIX timestamp
  • Next by Date: Problems creating a framework with model inside
  • Previous by thread: Re: Usercoded database fails to generate PKs
  • Next by thread: AW: Usercoded database fails to generate PKs
  • Index(es):
    • Date
    • Thread