You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the Spring R2DBC documentation I can use this syntax (copy/paste from documentation):
@Query("select u from User u")
Stream<User> findAllByCustomQueryAndStream();
Error A
Here the equivalent with my code:
@Query("SELECT u FROM UserEntity u WHERE u.id = :email AND u.hash = :hash")
Mono<UserEntity> findByEmailAndHash(String email, String hash);
Error:Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USERENTITY" not found; SQL statement:
So the Entity's name isn't supported, I have to use table's name.
Error B
Same example but with table's name:
@Query("SELECT u FROM user u WHERE u.id = :email AND u.hash = :hash")
Mono<UserEntity> findByEmailAndHash(String email, String hash);
Error:Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "U" not found; SQL statement:
So it considers u as a column, because u.* works as expected
Error C
The FROM x syntax:
@Query("FROM user WHERE id = :email AND hash = :hash")
Mono<UserEntity> findByEmailAndHash(String email, String hash);
Error:Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "FROM[*] USER WHERE ID = $1 AND HASH = $2"; SQL statement:
This syntactic sugar where we are omitting SELECT * doesn't work (it doesn't really matter for me, just wanted to tell you)
The only solution which works
The only solution which works is SELECT * :
@Query("SELECT * FROM user WHERE id = :email AND hash = :hash")
Mono<UserEntity> findByEmailAndHash(String email, String hash);
Code
For my Entities I don't use JPA annotations/classes, I use these:
Error:Caused by: java.lang.UnsupportedOperationException: Query derivation not yet supported! Question 2: Will "Derived Query Methods" be supported with 1.0.0 ?
Question 3: I have noticed that we are using the $ symbol for placeholders with R2DBC, instead of ? like in JPA, was there a specific reason?
Question 4: Does the org.springframework.transaction.annotation.Transactional annotation on my services' method work when we are using ReactiveCrudRepository or only when we are using org.springframework.data.r2dbc.core.DatabaseClient instance?
Thanks
The text was updated successfully, but these errors were encountered:
Versions
io.r2dbc:r2dbc-h2:0.8.3.RELEASE
Current Behavior
According to the Spring R2DBC documentation I can use this syntax (copy/paste from documentation):
Error A
Here the equivalent with my code:
Error:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USERENTITY" not found; SQL statement:
So the Entity's name isn't supported, I have to use table's name.
Error B
Same example but with table's name:
Error:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "U" not found; SQL statement:
So it considers
u
as a column, becauseu.*
works as expectedError C
The
FROM x
syntax:Error:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "FROM[*] USER WHERE ID = $1 AND HASH = $2"; SQL statement:
This syntactic sugar where we are omitting
SELECT *
doesn't work (it doesn't really matter for me, just wanted to tell you)The only solution which works
The only solution which works is
SELECT *
:Code
For my Entities I don't use JPA annotations/classes, I use these:
My repository:
Questions
Question 1: Are error A, B and C are expected behaviours or will they be supported with 1.0.0 ?
It doesn't work without
@Query
:Error:
Caused by: java.lang.UnsupportedOperationException: Query derivation not yet supported!
Question 2: Will "Derived Query Methods" be supported with 1.0.0 ?
Question 3: I have noticed that we are using the
$
symbol for placeholders with R2DBC, instead of?
like in JPA, was there a specific reason?Question 4: Does the
org.springframework.transaction.annotation.Transactional
annotation on my services' method work when we are usingReactiveCrudRepository
or only when we are usingorg.springframework.data.r2dbc.core.DatabaseClient
instance?Thanks
The text was updated successfully, but these errors were encountered: