1

我创建了这个在我的 postgresql 数据库中创建的类:

@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 回答