Jan Timar
10/02/2024, 7:32 PMimplementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("io.r2dbc:r2dbc-h2")
runtimeOnly("org.postgresql:postgresql")
runtimeOnly("org.postgresql:r2dbc-postgresql")
My repository is:
@Repository
interface UserRepository: CoroutineCrudRepository<User, String>
User class:
@Table("app_user")
data class User(
@Id
@Column("EMAIL")
val email: String,
@Column("COMPANY_ID")
val companyId: Long?,
@Column("PASSWORD")
val password: String? = null,
@Column("ROLE")
val role: String?
)
And when I call
userRepository.findById(email)
I receive:
[o-auto-1-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.r2dbc.BadSqlGrammarException: executeMany; bad SQL grammar [SELECT app_user.* FROM app_user WHERE app_user.EMAIL = $1 LIMIT 2]] with root cause
io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: column app_user.email does not exist
at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:96) ~[r2dbc-postgresql-1.0.5.RELEASE.jar:1.0.5.RELEASE]
at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:65) ~[r2dbc-postgresql-1.0.5.RELEASE.jar:1.0.5.RELEASE]
at io.r2dbc.postgresql.ExceptionFactory.handleErrorResponse(ExceptionFactory.java:132) ~[r2dbc-postgresql-1.0.5.RELEASE.jar:1.0.5.RELEASE]
at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:179) ~[reactor-core-3.6.10.jar:3.6.10]
...
sorry for stupid question probably but I dont see anything bad in a code or logs 😕
1. what is wrong with my code? 😄
2. Why it ask WHERE app_user.EMAIL =
and not only WHERE EMAIL =
?
3. Is there some a good way ho read a logs ( crashes ) and find what happen? Because I think little bit a problem can be somewhere else 😕
Thank you for any help, suggestion!
A Scheme and tables was created from Spring so connection should be okay but here is my application.yaml
spring:
application:
name: voyager
jpa:
defer-datasource-initialization: true
sql:
init:
mode: always
r2dbc:
url: r2dbc:<postgresql://localhost:5432/>
username: voyager
password: voyager
schema: voyager
Johann Pardanaud
10/03/2024, 6:02 AM"app_user.EMAIL"
instead of app_user.EMAIL
Postgres is case-insensitive by default.Jan Timar
10/03/2024, 5:34 PMCoroutineCrudRepository
Johann Pardanaud
10/03/2024, 6:51 PM