java 应用程序未使用user_id,并且表在用户表中也没有user_id,但收到错误,因为列名user_id无效

46qrfjad  于 2023-01-19  发布在  Java
关注(0)|答案(1)|浏览(173)

应用程序未使用user_id列,并且表的用户表中也没有user_id,但收到错误o.h.engine.jdbc.spi.SqlExceptionHelper:列名user_id无效。

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.orm.jpa.JpaSystemException: Unable to find column position by name: user_id] with root cause

刀接口

@Query(value="Select * from Users u WHERE u.UserName=:username", nativeQuery = true)
User findByUsername(@Param("username") String username) throws SQLException;

表格数据

用户模型类

请帮帮忙

gmxoilav

gmxoilav1#

对此有多个修复程序

我们必须为每列注解@column

并且必须使用www.example.com上的以下属性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

而且我们还必须使用大小写混合的列名称和连字符

@Column(name="\"UserId\"")

提供对我有帮助的帖子的链接@列和属性
混合大小写的列名称

相关问题