繁体   English   中英

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

[英]application is not using user_id and table also doesnt have user_id in users table, but getting error as The column name user_id is not valid

应用程序未使用 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;

表数据

在此处输入图像描述

用户 Model class

在此处输入图像描述

请帮忙解决这个问题

对此有多个修复

我们必须为每一列注释@column

并且必须在 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\"")

提供对我有帮助的帖子的链接@column 和 properties

大小写混合的列名称

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM