ayylmao123xdd
JCHJava Community | Help. Code. Learn.
•Created by ayylmao123xdd on 1/15/2025 in #java-help
fetch subclasses and their associations with one query
demo for simplicity and to avoid being sued :GnuTrolling:
so the question is whether its possible to fetch all the associations to their respective classes when calling the find all method
without eager fetching and avoiding n+1 and without extra queries for getting the associations
33 replies
JCHJava Community | Help. Code. Learn.
•Created by ayylmao123xdd on 1/13/2025 in #java-help
left fetch join creates race condition with optimistic locking
if i use query to left join authors books the test suddenly doesnt pass
made a demo for simplicity
163 replies
JCHJava Community | Help. Code. Learn.
•Created by ayylmao123xdd on 10/24/2024 in #java-help
handling lost update problem happening with one thread updating a resource at a time
so i got this quite an interesting problem where i got a piece of code that edits a entity
there is one class and a bunch of other classes that inherit it
the superclass has a version field for optimistic locking
all subclasses are stored in the same jpa repository
the lost update/stale data problem comes when sending an update command
example scenario
employee gets updated salary to 3000 but the request will sent later
employee gets updated salary to 5000 but the request is sent immediately
so the employee gets 3000 salary even though he was supposed to have 5000
i was thinking of comparing the version of the entity and the version thats sent in the command but that generates race condition
example code
349 replies