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

quarkus-hibernate-orm entity manager merge of detached entity does not work #2815

Closed
waldimiro opened this issue Jun 12, 2019 · 18 comments · Fixed by #40102
Closed

quarkus-hibernate-orm entity manager merge of detached entity does not work #2815

waldimiro opened this issue Jun 12, 2019 · 18 comments · Fixed by #40102
Labels
area/hibernate-orm Hibernate ORM area/persistence kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Milestone

Comments

@waldimiro
Copy link

With quarkus-hibernate-orm extension, entityManager.merge(entity) for a detached entity in a transactional method does not work. Entity will not be updated.

@waldimiro waldimiro added the kind/bug Something isn't working label Jun 12, 2019
@gsmet
Copy link
Member

gsmet commented Jun 13, 2019

@waldimiro could you create a reproducer?

@waldimiro
Copy link
Author

@gsmet I have a simple multi module scenario where:

module-1
Contains my JPA model (Entities)

module-2
Imports module-1
Exposes a REST endpoint that consumes a JSON
A service class serialize the JSON in a module-1 entity
A transactional method of service class try to merge the entity

@Sanne Sanne added this to To do in Quarkus persistence Jun 27, 2019
@gsmet
Copy link
Member

gsmet commented Jul 3, 2019

@waldimiro a simple reproducer would help. It shouldn't take you too much time.

@gsmet gsmet added this to To do in Deprecated - Quarkus 1.0 via automation Oct 7, 2019
@gsmet
Copy link
Member

gsmet commented Oct 7, 2019

We had several reports of this. We should try to investigate.

@gsmet
Copy link
Member

gsmet commented Oct 7, 2019

This might be related to this issue: #3127 .

@Sanne
Copy link
Member

Sanne commented Oct 7, 2019

@dreab8 could you add a test for this?

@dreab8
Copy link
Contributor

dreab8 commented Oct 14, 2019

Hi @waldimiro,
I created a project https://github.com/dreab8/qurkus-merge-detached that tries to replicate the issue you described but without any luck, can you please give a look at it and tell me if I am missing anything? thanks a lot

@waldimiro
Copy link
Author

waldimiro commented Oct 14, 2019

Hi @dreab8

Thank you for your time. The differences are:

model module

-- there are no application.properties, persistence properties are declared in service.
-- All my entities inherits from AbstractEntity (with an abstract getId, setId)

service module
-- application.properties contains persistence properties (quarkus.hibernate-orm.database.generation=none)
-- TestEntityService inherits from AbstractRepository where is injected the EntityManager.
-- TestEntityService has at class level the @transactional annotation.
-- TestEntityService has at class level another interceptor @lock(LockType.READ) (the concurrency solution that you can find here https://www.knitelius.com/2016/01/25/concurrency-control-for-cdi/)
-- MergedEntityResource is @RequestScoped

@waldimiro
Copy link
Author

mhh I ask me if it is related to #2918, please read my last comment.

@gsmet
Copy link
Member

gsmet commented Oct 15, 2019

@waldimiro I don't think we will be able to make progress on this this way.

Could you create a simple reproducer so that we can clearly see what's going wrong. It shouldn't be too hard and it would help us a lot.

Thanks.

@Sanne Sanne added the area/hibernate-orm Hibernate ORM label Oct 30, 2019
@gsmet gsmet closed this as completed Nov 13, 2019
Quarkus persistence automation moved this from To do to Done Nov 13, 2019
Deprecated - Quarkus 1.0 automation moved this from To do to Done Nov 13, 2019
@gsmet gsmet added the triage/out-of-date This issue/PR is no longer valid or relevant label Nov 13, 2019
@gsmet
Copy link
Member

gsmet commented Nov 13, 2019

Please open another issue with a full reproducer if you end up having one.

@Sanne
Copy link
Member

Sanne commented Nov 14, 2019

Reopening, we crafted a reproducer in ORM. We're working on this.

@Sanne Sanne reopened this Nov 14, 2019
Quarkus persistence automation moved this from Done to In progress Nov 14, 2019
Deprecated - Quarkus 1.0 automation moved this from Done to In progress Nov 14, 2019
@Sanne Sanne removed the triage/out-of-date This issue/PR is no longer valid or relevant label Nov 14, 2019
@rsvoboda
Copy link
Member

@Sanne any update on this ?

@Sanne
Copy link
Member

Sanne commented Jan 24, 2020

It's very complex but at last week's meeting we brainstormed this. I think I know now what we should do, but will need the time to explore further.

Described as:

@EfraimLA
Copy link

EfraimLA commented Jun 1, 2020

So there's not other way to merge entire entity collections?

@famod famod added the triage/upstream Used for issues which are caused by issues in upstream projects/dependency label Mar 27, 2021
@claud1nho
Copy link

@Sanne Even with the latest Quarkus 2.3 it is still not possible to reliably set fields back to null with em.merge() when the entity is detached. I am a little disappointed of my favorite framework that after more than one and a half year passing by, there is still no fix. In my opinion merging detached entities is not an edge case that could be ignored. Looking forward to a solution.

@guoxunbo
Copy link

guoxunbo commented Nov 8, 2022

any update related to this merge issue? We're facing the same issue?

@yrodiere
Copy link
Member

FWIW this seems to relate to https://hibernate.atlassian.net/browse/HHH-17761, which was fixed in Hibernate ORM 6.5 and thus should be fixed when we upgrade to that version in Quarkus (PR incoming).

Quarkus persistence automation moved this from In progress to Done Apr 26, 2024
@quarkus-bot quarkus-bot bot added this to the 3.11 - main milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/persistence kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Projects
Development

Successfully merging a pull request may close this issue.

10 participants