JPA Uppercase table names

前端 未结 4 1135
你的背包
你的背包 2020-12-06 10:51

I have a table in Postgresql:

CREATE TABLE "UTILISATEUR"(
 
 "IdUtilisateur" serial NOT NULL,
 "Nom" character varying(50),
 &qu         


        
相关标签:
4条回答
  • 2020-12-06 11:19

    I reproduced your UTILISATEUR table (role removed) in postgres 8.4 and hibernate 5.0.3.

    It works as expected with explicit table and column names annotation:

    @Entity(name="\"UTILISATEUR\"")
    public class Utilisateur {
    
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO) 
        @Column(name="\"IdUtilisateur\"")
        private Long id ;
    
        @Column(name="\"Nom\"")
        private String Nom ; 
        @Column(name="\"Prenom\"")
        private String Prenom ; 
        @Column(name="\"Profil\"")
        private String Profil ; 
        @Column(name="\"Pseudo\"")
        private String Pseudo ; 
    
        @Column(name="\"Password\"")
        private String Password ;
    
        ... getter / setters
    
    }
    
    0 讨论(0)
  • 2020-12-06 11:24

    maybe because you are using MYSQL5DIALECT there's a Postgres Dialect just used post it like this and for the improved naming strategy use EJB3 like Spring boot JPA insert in TABLE with uppercase name with Hibernate

    spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
    

    hope it works for you

    0 讨论(0)
  • 2020-12-06 11:26

    You can configure your application with the next line depend the database:

    MySql

    spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.DefaultNamingStrategy
    

    Postgres

    spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
    

    Oracle

    spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
    
    0 讨论(0)
  • 2020-12-06 11:32

    I faced the same issue and I back quoted ( ` ) my table name in the entity declaration like this "`UTILISATEUR`". @Table(name = "`UTILISATEUR`")

    ` using postgresql 11 with dialect : org.hibernate.dialect.PostgreSQL95Dialect it generated me an upercased table name on database.

    0 讨论(0)
提交回复
热议问题