Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a table name for the class User #7

Open
Dieblich opened this issue Apr 24, 2022 · 2 comments
Open

Define a table name for the class User #7

Dieblich opened this issue Apr 24, 2022 · 2 comments

Comments

@Dieblich
Copy link

Hi,

when you use the class /taco-cloud-sfc/src/main/java)/tacos/User.java with a h2 db, this could run into an issue with the h2-Usertable "User" like this:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax Fehler in SQL Befehl "drop table if exists [*]user CASCADE "; erwartet "identifier"
Syntax error in SQL statement "drop table if exists [*]user CASCADE "; expected "identifier"; SQL statement:
drop table if exists user CASCADE  [42001-210]

Spring cannot create the data-table.

I solved this issue with an annotation for the table:

...
@Table(name="TACO_USER")
public class User implements UserDetails {
...

This solves the issue with the h2 database and the apps starts fine.

@mrigankvallabh
Copy link

One could also update the application.yml file to (check jpa.properties.hibernate)

spring:
  datasource:
    generate-unique-name: false
    name: tacocloud
  h2:
    console:
      enabled: true
  jpa:
    properties:
      hibernate:
        "[globally_quoted_identifiers]": true
        "[globally_quoted_identifiers_skip_column_definitions]": true

@lsxol
Copy link

lsxol commented Sep 20, 2022

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants