Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in query results #163

Closed
doardin opened this issue Aug 1, 2021 · 3 comments
Closed

Bug in query results #163

doardin opened this issue Aug 1, 2021 · 3 comments
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@doardin
Copy link

doardin commented Aug 1, 2021

I noticed a bug regarding the results of some queries, JPA Streamer does not always return what is actually in the database. My test was simple, I did a specific query that was based on the status of a column, which returned only records whose column specified that record was active and I realized that even after modifying the column's value directly in the database, JPA still returned the record which it shouldn't return, after some tests and revisions I noticed this bug in JPA and for it to return the data correctly I needed to restart the application, I looked for some documentation that talked about it but unfortunately I didn't find anything so decide report this error through github.

@minborg
Copy link
Contributor

minborg commented Aug 4, 2021

Can you provide a code snippet showing the problem please?

@minborg minborg added the bug Something isn't working label Aug 4, 2021
@doardin
Copy link
Author

doardin commented Mar 10, 2022

I noticed that bug it happens if you update values directly by database.

INITIAL VALUES

Captura de Tela 2022-03-10 às 11 25 12

Database
Captura de Tela 2022-03-10 às 11 08 43

I updated directly by database, the new values is
Captura de Tela 2022-03-10 às 11 26 30

but the response of application is the old values of object
Captura de Tela 2022-03-10 às 11 27 19

if i restart application the updated values are show
Captura de Tela 2022-03-10 às 11 38 59

source code i used to replicate this bug

@julgus julgus added next and removed next labels Sep 1, 2022
@julgus julgus self-assigned this Sep 9, 2022
@julgus
Copy link
Member

julgus commented Sep 29, 2022

This issue arises as the JPAStreamer instance reuses a single JPA EntityManager throughout its lifetime. JPA's first-level cache automatically caches the query results which means repeated queries are not run against the database but the cache - explaining why the change is not reflected in the application until restart. We are working on a solution for the next release.

@julgus julgus added this to To do in 1.1.4 Sep 30, 2022
@julgus julgus moved this from To do to Done in 1.1.4 Sep 30, 2022
@julgus julgus closed this as completed in 211ac69 Sep 30, 2022
@julgus julgus added this to the 1.1.0 milestone Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
1.1.4
  
Done
Development

No branches or pull requests

3 participants