application is not using user_id column and table also doesn't have user_id in users table, but getting error as o.h.engine.jdbc.spi.SqlExceptionHelper: The column name user_id is not valid.
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
Dao interface
@Query(value="Select * from Users u WHERE u.UserName=:username", nativeQuery = true)
User findByUsername(@Param("username") String username) throws SQLException;
Table data
User Model class
Please help on this
there are multiple fixes for this
we have to annotate @column for each column
and have to use below properties on 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
and also we have to use mixedcase columne names in hyphens
@Column(name="\"UserId\"")
Provide links to posts that helped me @column and properties
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.