0

こんにちは、SQL コンテナーに新しく追加された項目のプロパティを変更しようとすると、SQLIntegrityConstraintViolationException が発生します。私は非常に単純なテーブルを持っています:

CREATE TABLE person(
id int not null primary key,
name varchar(30),
surname varchar(30),
age int
)

すべてのプロパティを 1 つずつ設定しようとしていますが、最初の仕上げ (id) の後、次は例外がスローされて終了します。

java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: unique constraint or index violation; SYS_PK_10096 table: PERSON
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
at com.vaadin.data.util.sqlcontainer.query.TableQuery.executeUpdateReturnKeys(TableQuery.java:588)
at com.vaadin.data.util.sqlcontainer.query.TableQuery.storeRow(TableQuery.java:284)
at com.vaadin.data.util.sqlcontainer.SQLContainer.itemChangeNotification(SQLContainer.java:1069)
at com.vaadin.data.util.sqlcontainer.ColumnProperty.setValue(ColumnProperty.java:207)
at slawek.MyVaadinUI.init(MyVaadinUI.java:93)
at com.vaadin.ui.UI.doInit(UI.java:610)

コードは次のとおりです。

FormLayout form = new FormLayout();
    TextField idTextField = new TextField("Id");
    TextField nameTextField = new TextField("Name");
    TextField surnameTextField = new TextField("Surname");
    TextField ageTextField = new TextField("Age");
    Button submit = new Button("Add user");
    form.addComponents(idTextField, nameTextField, surnameTextField, ageTextField, submit);

    layout.addComponent(form);
    Item item = container.getItem(container.addItem());
    container.setAutoCommit(true);
    Property propertyId = item.getItemProperty("ID");
    Property propertyName = item.getItemProperty("NAME");
    Property propertySurname = item.getItemProperty("SURNAME");
    Property propertyAge = item.getItemProperty("AGE");

    propertyId.setValue(3);
    propertyName.setValue("someName"); // line number 93
    propertySurname.setValue("someSurname");
    propertyAge.setValue(51);

データベースで確認できるのは、ID 番号が設定された新しい行のみです。残りのフィールドは null です。私は何を間違っていますか?

4

1 に答える 1