mysql - Cayenne "resets" primary key value? -


i using cayenne add records mysql database, , seeing strange behavior.

when run application, create datacontext, perform series of adds, close application. works out well, because using integer primary key, , when add record database, key automatically increments. reason, starts @ 200 first record, goes 201 second record, etc.

if, however, stop application, run again, primary key starts @ 200 again! this, of course, causes exception thrown because new record ends having duplicate primary key. looking when create new object using datacontext's newobject() after starting application, cayenne not "remember" how far primary key incremented when application run.

does know causing reset of primary key values, , (more importantly) how stop happening??? or have found bug in current version of cayenne? using version 3.0.2.

someone please advise...

the last used pk given table stored in special table called auto_pk_support. please check contents of table between restarts of app. check application cayenne logs reads , writes auto_pk_support. should give idea of what's happening.

aside might switch auto-increment pk (see "primary key provided database" section here). mysql supports auto-incremented pk columns , if have option of altering schema, imo cleanest pk generation strategy out of available. (and doesn't require auto_pk_support).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -