How to solve: Column "id" not found [42122-197]?

0

Folks, I'm creating an API that will display random phrases, from a table in the database.

The problem is that whenever I access the route, in the console, I get this exception:

  

org.h2.jdbc.JdbcSQLException: Column "id" not found [42122-197]

And in Postman:

{
    "timestamp": "2018-11-01T00:47:59.559+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "could not execute query; SQL [SELECT detail FROM scripts ORDER BY RANDOM() LIMIT 1]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query",
    "path": "/v1/quote"
}

I'm using the bank's H2. In the resources folder, there is a schema.sql file, which contains the SQL for the table, and a data.sql , with the data load.

Only the ID exists in the scripts table, within schema.sql :

CREATE TABLE scripts (
  id INTEGER PRIMARY KEY,
  /* mais código*/
);

And it exists in class Quote , which should map the class to table scripts :

@Entity
@Table(name="scripts")
public class Quote {

    @Id
    @Column(name="id")
    private Integer id;

        /*Outra variáveis*/      

       /*Getters e Setters*/
}

Now I do not know if I could not map the table correctly ...

Mapping this table should be automatic, right?

Complete project in the GitHub .

    
asked by anonymous 01.11.2018 / 02:08

1 answer

0

Folks, the problem has been solved. If you are having a similar problem, I decided after I made some modifications, as they appear in this other question I made here in the PTSO: Spring Data JPA does not recognize the SQL command 'Limit'?

    
01.11.2018 / 23:34