JPA column with incorrect underscore

后端 未结 4 463
盖世英雄少女心
盖世英雄少女心 2020-12-30 20:16

I use JPA for database access and annotated every column with the correct name. Now if I execute a query (e.g. findAll()) it returns

Unknown co         


        
相关标签:
4条回答
  • 2020-12-30 20:49

    http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

    spring.jpa.hibernate.naming.strategy is not a supported property for Spring JPA implementation using Hibernate 5.

    Use the below property in application.properties

    spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    
    0 讨论(0)
  • 2020-12-30 20:55

    Were able to map

    @Column(name = "PersonFullName")

    private String PersonFullName;


    to the database table column name "PersonFullName" without the underscore.

    The below worked for me. Add this in the application settings and then use @Column to specify the physical database column name for the model's property.

    @Column(name = "PersonFullName")

    In Application.properties

    spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

    0 讨论(0)
  • 2020-12-30 20:58

    As described in spring-boot-jpa-column-name-annotation-ignored, your column name is being converted to snake case.

    Possible solutions:

    • Setup a Naming Strategy
    • Use lowercase column names in your annotations
    0 讨论(0)
  • 2020-12-30 21:06

    use below in application.properties

    spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

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