0

I was already searching for a solution but I cannot find any.

My problem is that I cannot my Postgres database, called IncomeOutgo, via Hibernate.

I always get this error message when calling my Thymeleaf/HTML website.

enter image description here

So does my application.properties look like

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.show-sql=true spring.datasource.url=jdbc:postgresql://192.168.0.227:5432/IncomeOutgo spring.datasource.username=postgres spring.datasource.password=XXX #spring.jpa.properties.hibernate.format_sql=true 

So does my table look like in Postgres (DBeaver):

enter image description here

And last but not least so does my Domain/Entity look like:

@Data @NoArgsConstructor @AllArgsConstructor @Builder @Entity @Table public class IncomeOutgo extends AbstractPersistable<Long> { @Version @Column(name ="id") private Long id; @Column(name="dayofweek") private Date dayofweek; @Size(min = 5, max = 50) @Column(name ="person") private String person; @Min(0) @Column(name ="version") private Integer version; @Column(name="income") private int income; @Column(name="outgo") private int outgo; } 

Maybe, someone can tell me what my error is?

Thanks in advance!

6
  • Try explicit table name using @Table annotation Commented Feb 16, 2021 at 9:21
  • I tried it with @Table="incomeoutgo" (omitting spring.datasource.url=jdbc:postgresql://192.168.0.227:5432/--OMITTED--) error message: org.postgresql.util.PSQLException: ERROR: relation "incomeoutgo" does not exist as well as @Table="IncomeOutgo" and omitting spring.datasource.url=jdbc:postgresql://192.168.0.227:5432/--OMITTED--) error message: org.postgresql.util.PSQLException: ERROR: relation "income_outgo" does not exist Commented Feb 16, 2021 at 9:31
  • 1
    What is your default schema? Try @Table(name="incomeoutgo", schema="IncomeOutgo") I guess you already checked the grants on the table. Commented Feb 16, 2021 at 9:34
  • Try also @Table(name="\"incomeoutgo\"") Commented Feb 16, 2021 at 9:35
  • To answer a question: SELECT current_schema(); yields IncomeOutgo. Then I tried your suggestions (always using spring.datasource.url=jdbc:postgresql://192.168.0.227:5432/): @Table(name="incomeoutgo", schema="IncomeOutgo"); error_message: ERROR: relation "income_outgo.incomeoutgo" does not exist and for @Table(name="\"incomeoutgo\""); error_message: ERROR: relation "incomeoutgo" does not exist Commented Feb 16, 2021 at 9:47

1 Answer 1

0

I was able to make it work now. Lesiak´s hint with the schema name made me do a workaround.

I created a new database: incomeoutgo (lower letter case), and under schema: public, a new table: incomeoutgo with lower letters, too.

enter image description here

And so does my Domain definition look like:

@Data @NoArgsConstructor @AllArgsConstructor @Builder @Entity @Table(name="incomeoutgo", schema = "public") public class IncomeOutgo extends AbstractPersistable<Long> { @Version @NotNull @Column(name ="id") private Long id; @Column(name="dayofweek") private Date dayofweek; @Size(min = 5, max = 50) @Column(name ="person") private String person; @Min(0) @Column(name ="version") private Integer version; @Column(name="income") private int income; @Column(name="outgo") private int outgo; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.