Closed DarkendHall closed 4 months ago
It fails caused by size of groupIds
greater than 1, I suspect it's bug of Hibernate, it shouldn't expands Collection to (?,?,?)
in such case.
This was indeed the cause of the issue.
Thank you for your quick reply!
I managed to fix it by changing the method name which seems to generate the same query regardless of the number of items in either side (both canViewBlogpost
and groupsIds
)
// Doesn't work
List<Blogpost> findAllByCanViewBlogpostContains(@NotEmpty Set<Long> canViewBlogpost, Pageable pageable);
// Does work!
List<Blogpost> findAllByCanViewBlogpostIn(@NotEmpty Set<Long> canViewBlogpost, Pageable pageable);
Description of the issue
After making my repository method accept a
Pageable
it generates different queries on different machines causing anSQLException
to be thrown.The thing is it is all run in Docker containers, so there should not be any difference in the environment.
They have the same spring profile selected namely:
prod
and the database tables columns are the same.Log output
Code
Repository
Entity
Service (where the method is called)
Database Tables
Live server
`blogpost` | Field | Type | Null | Key | Default | Extra | | :--- | :--- | :--- | :--- | :--- | :--- | | id | bigint | NO | PRI | null | auto\_increment | | title | varchar\(255\) | NO | UNI | null | | | content | text | NO | | null | | | is\_pinned | tinyint\(1\) | NO | | 0 | | `blogpost_can_view_blogpost` | Field | Type | Null | Key | Default | Extra | | :--- | :--- | :--- | :--- | :--- | :--- | | blogpost\_id | bigint | NO | PRI | null | | | can\_view\_blogpost | bigint | NO | PRI | null | |Local
`blogpost` | Field | Type | Null | Key | Default | Extra | | :--- | :--- | :--- | :--- | :--- | :--- | | id | bigint | NO | PRI | null | auto\_increment | | title | varchar\(255\) | NO | UNI | null | | | content | text | NO | | null | | | is\_pinned | tinyint\(1\) | NO | | 0 | | `blogpost_can_view_blogpost` | Field | Type | Null | Key | Default | Extra | | :--- | :--- | :--- | :--- | :--- | :--- | | blogpost\_id | bigint | NO | PRI | null | | | can\_view\_blogpost | bigint | NO | PRI | null | |Generated SQL
Live server
Local