tags:

views:

46

answers:

1

Hi, I'm trying to persist an object into the database using Cayenne Entity Manager. And unfortunately I get the following error:

org.apache.cayenne.CayenneRuntimeException: [v.3.0 Apr 26 2010 09:59:17] Commit Exception

Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'myDatabase.auto_pk_support' doesn't exist

Any idea how i could solve this issue? Thanks.

+1  A: 

In the case of your error, it looks to me that you choose from Cayenne Modeler the "default" "PK Generation Strategy" (Click on your DB Entites to see the comobox with that option). This means that Cayenne expects a populated "auto_pk_support" table to be present in your schema (in order to be able to generate and keep track of primary keys).

Cayenne Modeler can generate this table + content for you: select from Tools menu the "Generate DB Schema", select the right connection, and from the next dialog select only the checkbox "Create PK Support": - you will see the SQL required to generate it - you can copy and paste it in you favorite SQL tool, or let Cayenne Modeler run it.

Since you are using MySQL you have of course other PK generation options too (the above is the classical/default one and works on any database - but requires an extra table).

I suggest consulting the Cayenne Modeler documentation, or better the entire cayenne documentation (since it's very good) as all the above items are very well explained there.

A. Ionescu