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);
                }
    }

This sets the connection for each model to the DB, but I actually only see two connection messages:

2006-06-21 17:23:46,900 DEBUG main NSLog (ERXNSLogLog4jBridge.java:appendln:44) - connecting with dictionary: {plugin = ""; username = "admin"; driver = ""; password = "<password deleted for log>"; URL = "jdbc:openbase://127.0.0.1/CronusIII:wo"; }

If I insert any entity into this DB, I should get:

2006-06-21 16:51:27,818 DEBUG WorkerThread1 NSLog (ERXNSLogLog4jBridge.java:appendln:44) - evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "INSERT INTO PERSON(PRIMARY_KEY, GENDER_KEY, PERSON_TYPE_KEY, DATE_OF_BIRTH, TERMINATION_DATE, UNIQUE_ID, CREATION_DATE, ALIAS, MODIFICATION_DATE, IS_A_DOCTOR, TYPE, FIRST_NAME, TITLE_KEY, IS_A_MANAGER, SURNAME, MIDDLE_NAMES) VALUES (?, ?, ?, NULL, NULL, NULL, ?, NULL, ?, ?, ?, ?, ?, ?, ?, NULL)" withBindings: 1:573 (NeededByEOF0), 2:6(gender_key), 3:11(person_type_key), 4:2006-06-21 16:51:27(creation_date), 5:2006-06-21 16:51:27(modification_date), 6:"F"(is_a_doctor), 7:"M"(type), 8:"Aaaad"(first_name), 9:1 (title_key), 10:"F"(is_a_manager), 11:"Aaaad"(surname)>

but instead I get an INSERT without a primary_key:

2006-06-21 16:54:25,805 DEBUG WorkerThread14 NSLog (ERXNSLogLog4jBridge.java:appendln:44) - evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "INSERT INTO PERSON(GENDER_KEY, PERSON_TYPE_KEY, DATE_OF_BIRTH, TERMINATION_DATE, UNIQUE_ID, CREATION_DATE, ALIAS, MODIFICATION_DATE, IS_A_DOCTOR, TYPE, FIRST_NAME, TITLE_KEY, IS_A_MANAGER, SURNAME, MIDDLE_NAMES) VALUES (?, ?, NULL, NULL, NULL, ?, NULL, ?, ?, ?, ?, ?, ?, ?, NULL)" withBindings: 1:6(gender_key), 2:11 (person_type_key), 3:2006-06-21 16:54:25(creation_date), 4:2006-06-21 16:54:25(modification_date), 5:"F"(is_a_doctor), 6:"M"(type), 7:"Aabb"(first_name), 8:1(title_key), 9:"F"(is_a_manager), 10:"Aabb"(surname)> java.sql.SQLException: ERROR - Value can not be NULL for column 'PRIMARY_KEY' SQL: INSERT INTO PERSON(GENDER_KEY, PERSON_TYPE_KEY, DATE_OF_BIRTH, TERMINATION_DATE, UNIQUE_ID, CREATION_DATE, ALIAS, MODIFICATION_DATE, IS_A_DOCTOR, TYPE, FIRST_NAME, TITLE_KEY, IS_A_MANAGER, SURNAME, MIDDLE_NAMES) VALUES (6, 11, NULL, NULL, NULL, 172565665.602, NULL, 172565665.602, 'F', 'M', 'Aabb', 1, 'F', 'Aabb', NULL)

Any thoughts as to what is preventing EO from generating the PKs?

Thanks
Ian Joyner
Sportstec
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to