Comments (9)
/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)
from quarkus.
Hey @alomine, thanks for reporting.
Are you sure this is specific to Quarkus? Can you reproduce with plain Hibernate ORM test case templates?
from quarkus.
Hello @yrodiere, thanks for response.
I'll try this. For now i can say two things - its not working in both quarkus 2.x.x version and 3.x.x (different hibernate versions) and its totally working on wildfly 26
from quarkus.
Thanks, looking forward to the reproducer.
from quarkus.
@yrodiere
I did two test cases with plain hibernate based on examples that you posted. Both 7/7 successful
from quarkus.
My guess is that it's related to the bytecode enhancement.
from quarkus.
I have some research on this issue.
1. Transactional annotation on the TestBugTest class instead of TestEntityService.
All tests will be passed, but the data in the database will not be updated.
2. QuarkusTransaction instead of annotation. You will have two possible variants:
2.1 Test fail, data not updated.
@Test
public void saveAndCheckWithNonNullNumber_test() {
QuarkusTransaction.begin();
testEntityService.clean();
TestEntity testEntity = createEntityWithNonNullNumber();
testEntityService.save(testEntity);
QuarkusTransaction.commit();
assertEquals(1, testEntityService.find(1L).getNumberField());
QuarkusTransaction.begin();
testEntity = createEntityWithAllNulls();
testEntityService.update(testEntity);
QuarkusTransaction.commit();
assertEquals(null, testEntityService.find(1L).getNumberField());
}
2.2 Test passed, data not updated (similar to placing the Transactional annotation on the TestBugTest class).
@Test
public void saveAndCheckWithNonNullNumber_test() {
QuarkusTransaction.begin();
testEntityService.clean();
TestEntity testEntity = createEntityWithNonNullNumber();
testEntityService.save(testEntity);
assertEquals(1, testEntityService.find(1L).getNumberField());
QuarkusTransaction.commit();
QuarkusTransaction.begin();
testEntity = createEntityWithAllNulls();
testEntityService.update(testEntity);
assertEquals(null, testEntityService.find(1L).getNumberField());
QuarkusTransaction.commit();
}
3. Update "refreshed" data after save (Transactional on TestEntityService).
3.1 Works as intended data in db updated.
@Test
public void saveAndCheckWithNonNullNumber_test() {
testEntityService.clean();
TestEntity testEntity = createEntityWithNonNullNumber();
TestEntity savedEntity = testEntityService.save(testEntity);
assertEquals(1, testEntityService.find(1L).getNumberField());
savedEntity.setDateField(null);
savedEntity.setNumberField(null);
savedEntity.setStringField(null);
testEntityService.update(savedEntity);
assertEquals(null, testEntityService.find(1L).getNumberField());
}
public TestEntity save(TestEntity entity) {
testEntityRepository.getEntityManager().persist(entity);
testEntityRepository.getEntityManager().flush();
testEntityRepository.getEntityManager().refresh(entity);
return entity;
}
3.2 Save and find. Works similar to 3.1
@Test
public void saveAndCheckWithNonNullNumber_test() {
testEntityService.clean();
TestEntity testEntity = createEntityWithNonNullNumber();
testEntityService.save(testEntity);
assertEquals(1, testEntityService.find(1L).getNumberField());
TestEntity savedEntity = testEntityService.find(1L);
savedEntity.setDateField(null);
savedEntity.setNumberField(null);
savedEntity.setStringField(null);
testEntityService.update(savedEntity);
assertEquals(null, testEntityService.find(1L).getNumberField());
}
I hope this helps in some way.
from quarkus.
Hello @Nikita-V0lkov,
in 3.1 and 3.2 entity you named as savedEntity is in persistent state and in this state this seems to be working. However by explicitly calling merge it shouldnt really matter.
from quarkus.
Hey,
I did two test cases with plain hibernate based on examples that you posted. Both 7/7 successful
As Guillaume suggested, you'd need to add bytecode enhancement to reproduce the issue with Hibernate ORM only. Here's a bug report based on this in ORM's JIRA: https://hibernate.atlassian.net/browse/HHH-17761
from quarkus.
Related Issues (20)
- OidcProvider throws NPE when certificate chain is configured with OIDC server which has no JWK keys at the startup HOT 1
- Build Card Page for Dev UI results in NPE in ArtifactInfoUtil HOT 10
- ARJUNA012095: Abort of action id <ID> invoked while multiple threads active within it. HOT 2
- allow fetching of lazy relations outside of its original transaction HOT 12
- Customize Vert.x builder to update the Vert.x Cluster manager configuration HOT 1
- `ImageMetricsITCase.verifyImageMetrics` failures in `main` HOT 15
- quarkus-quartz: CDIAwareJob destroys instance of Quartz Job too early when Job is a @Dependent bean HOT 4
- try it out in swagger configuration option HOT 5
- Agroal Data Source Health check failing for reactive data source HOT 5
- Offer a way to block inside custom `SecurityContext.isUserInRole` with resteasy-reactive HOT 15
- Hibernate Reactive can't persist a many-to-many relation when one of the entities is a child (with the "joined" inheritance type) and the batch size is greater than 1 HOT 10
- Postgresql bump causing detection of instance Random/SplittableRandom HOT 11
- jpamodelgen fails with range out of bounds HOT 9
- Properly pass errors from JsonRPC backends to Dev UI HOT 2
- Unable to build a container with Jib when podman is running HOT 7
- Exception thrown when stopping devmode and with dev services running with Podman HOT 1
- Quarkus opentelemetry extension WARNING when exporting to dynatrace HOT 11
- GRPC server doesn't respond when running on the same server as HTTP and using TLS HOT 6
- Add @PermissionsAllowed to Panache Resources HOT 9
- Native: Introduce flag to favor build time improvements at the cost of using more resources and vice versa HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quarkus.