我还有另一个问题(似乎与:未找到存储过程'auto_pk_for_table')但我使用自动增量字段在主键中放置了 ID 和“数据库生成”的自动增量和唯一索引, 看 :
public abstract class _DateInfo extends CayenneDataObject {
public static final String ENDDATETIME_PROPERTY = "enddatetime";
public static final String STARTDATETIME_PROPERTY = "startdatetime";
public static final String USER_ID_PROPERTY = "userId";
public static final String DATEINFOID_PK_COLUMN = "DATEINFOID";
public static final String USERID_PK_COLUMN = "USERID";
public void setEnddatetime(Date enddatetime) {
writeProperty(ENDDATETIME_PROPERTY, enddatetime);
}
public Date getEnddatetime() {
return (Date)readProperty(ENDDATETIME_PROPERTY);
}
public void setStartdatetime(Date startdatetime) {
writeProperty(STARTDATETIME_PROPERTY, startdatetime);
}
public Date getStartdatetime() {
return (Date)readProperty(STARTDATETIME_PROPERTY);
}
public void setUserId(int userId) {
writeProperty(USER_ID_PROPERTY, userId);
}
public int getUserId() {
Object value = readProperty(USER_ID_PROPERTY);
return (value != null) ? (Integer) value : 0;
}
}
单击保存按钮时,我尝试保存本地时间:
Button save = new Button("Save", event -> {
DateInfoFactory date = CayenneUtil.getContext().newObject(
DateInfoFactory.class);
date.setUserId(userIdSelected);
if (startTime.getValue() != null) {
LocalTime startDate = startTime.getValue();
date.setStartdatetime(toDate(startDate));
}
date.getObjectContext().commitChanges();
});
save.addStyleName(ValoTheme.BUTTON_PRIMARY);
但是后来,我收到了这个错误:
juin 12, 2017 9:38:32 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
INFOS: LOCK TABLES AUTO_PK_SUPPORT WRITE
juin 12, 2017 9:38:32 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
INFOS: UNLOCK TABLES
juin 12, 2017 9:38:32 PM com.vaadin.server.DefaultErrorHandler doDefault
GRAVE:
org.apache.cayenne.CayenneRuntimeException: [v.4.0.M5 Feb 24 2017 07:47:55] Commit Exception
..
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'mam.auto_pk_support' doesn't exist
我应该怎么办?
谢谢,