Ute,

Both of these are most likely modeling errors.  See below...

On Sep 19, 2007, at 3:48 AM, Ute Hoffmann wrote:

Hallo,
I have a app, where I need to delete some data before reading more data in via an import mechanism.

But my seemingly simple deletes throws weird errors - perhaps someone knows what is going on here.

Delete jointable from many to many (Objects where the joins point to are to stay intact):

Exception:
com.webobjects.eoaccess.EOGeneralAdaptorException: deleteRowDescribedByQualifierEntity -- com.webobjects.jdbcadaptor.JDBCChannel: method deleted 4 rows, it is only permitted to update 1 row at com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContex tInformationAdded(EODatabaseContext.java:4686)

Code:

NSArray produktverknuepfungen1 = EOUtilities.objectsForEntityNamed (ec, "Jgruppeprodukt");

if(produktverknuepfungen1.count()!=0){
        for(int m=0; m<produktverknuepfungen1.count(); m++){
        Jgruppeprodukt aPZWert = new Jgruppeprodukt();
        aPZWert = (Jgruppeprodukt)produktverknuepfungen1.objectAtIndex(m);
        ec.deleteObject(aPZWert);
        ec.saveChanges();
        }
}

Any idea what goes wrong here???

This only occurs when you have duplicate primary keys in your database. Are you using any inheritance here? Is anything outside of EOF modifying the database table? If you could provide the details of the entity, it would be helpful, but the first thing I would do is something like:

select count(*) from table

select count(distinct primary_key) from table

These numbers should always be equal - my guess is that in your case, they're not. You should also verify that the little key symbols in your EO properly reflect what you think the primary key is.


Second case (even more inexplainable to me):

A one- to many. I try to delete the to-many part, I do exactly the same with same code before I do this and it works. With this relationship however I get an Exception that the "pzusatzgruppes" in produkt (Produkt <->>Pzusatzgruppe) is not an array. I checked and checked and IT SEEMS TO BE AN Array. Nothing I can see differentiates the relationship and the java-classes belonging to it from the relationship which works :-(

Im at a loss. Some ideas?

Again, almost certainly a modeling error. Make sure the to-many relationship is modeled properly. Also, make sure that you're not overriding any of the awake methods (awakeFromInsertion(EC)) without calling super().


Can it be that mysql 5 has problems with my JDBC-Driver? Which one should be used with mysql 5? I need one which is able to handle international characters ISO-Latin something. This could explain Exception 1 but not Exception 2??

Possibly. Are your primary keys strings? With EOF, it's highly recommended that you use non-user controlled integer primary keys.


Thank you for your help,

Regards

Ute

PS. Running WO 5.2.4 on Mac OS X 10.4.10 with Xcode 2.0 -> could that combination make for the problems?

Doubtful...I've used EOF since the early days, and these problems are almost always model based.

Good luck!

Ken



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kenlists% 40anderhome.com

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
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