1

I have created this class which is created in my 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;

I want to insert that into the db:

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

However, I get an exception, even if I manually insert via the postgresql interface:

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

Whats wrong with my query?

1 Answer 1

3

You have to pass string values with singlequotes. Like this:

INSERT INTO test (id, type, test, test_String, test_1, space)
VALUES (0, 'Type1' , 5, 'String', 1, 'room');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.