Solution of @ Column Mapping Inconsistency

  • 2021-12-04 10:03:44
  • OfStack

@ Column mapping is not 1

Problem recurrence


@Column(name = "userName", nullable = true, length = 20)
private String userName;

But the table field generated in mysql is user_name

Solution


  jpa:
    hibernate:
      ddl-auto: update
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    show-sql: true

Mainly set physical-strategy properties

In addition, mysql primary key self-increasing method


 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)

@ Column Annotation Mapping Not Effective

@ Column doesn't work inexplicably when mybatis-plus, so use @ TableField instead.

Note that the value value of tableField should be completely 1 to the database table name (hump to hump, underline to underline)


Related articles: