1

postgresql dbに作成されたこのクラスを作成しました:

@Entity
public class Test implements Serializable {

    @Id
    @GeneratedValue
    private Long id;

    @NotNull
    @Column(name="type")
    private String type;

    @NotNull
    @Column(name="test")
    private Integer test;

    @NotNull
    @Column(name="test_String")
    private String testString;

    @NotNull
    @Column(name="test_1")
    private Integer test1;

    @NotNull
    @Column(name="space")
    private String space;

それをデータベースに挿入したい:

    INSERT INTO test (id, type, test, test_String, test_1, space)
VALUES (0, "Type1" , 5, "String", 1, "room");

ただし、postgresql インターフェイスを介して手動で挿入しても、例外が発生します。

FEHLER:  Spalte »Type1« existiert nicht
LINE 2: VALUES (0, "Type1" , 5, "String", 1, "room");
                   ^

クエリの何が問題になっていますか?

4

1 に答える 1

3

一重引用符で文字列値を渡す必要があります。このような:

INSERT INTO test (id, type, test, test_String, test_1, space)
VALUES (0, 'Type1' , 5, 'String', 1, 'room');
于 2013-04-20T12:32:59.673 に答える