Comments (6)
I have also managed to reproduce it with the BytecodeEnhancerRunner
.
Upstream issue | https://hibernate.atlassian.net/browse/HHH-17828 |
Reproducer PR | hibernate/hibernate-orm#7961 |
from quarkus.
Also, I tried to reproduce this with just Hibernate alone, and it looks like the error does NOT occur there. So, I would assume that this really is a Quarkus bug this time around.
My hibernate test case:
package org.hibernate.orm.test.locking;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.LockModeType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Version;
import org.hibernate.Hibernate;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.Jpa;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@JiraKey("HHH-?????")
@Jpa(
annotatedClasses = {
LockFindAndLockReferencedTest.MainEntity.class,
LockFindAndLockReferencedTest.ReferencedEntity.class
}
)
public class LockFindAndLockReferencedTest {
@BeforeAll
public void setUp(EntityManagerFactoryScope scope) {
scope.inTransaction(
entityManager -> {
final ReferencedEntity e1 = new ReferencedEntity( 0L );
entityManager.persist( e1 );
final MainEntity e3 = new MainEntity( 0L, e1 );
entityManager.persist( e3 );
}
);
}
@Test
public void testFindAndLockAfterLock(EntityManagerFactoryScope scope) {
scope.inTransaction(
entityManager -> {
// First find and lock the main entity
MainEntity m = entityManager.find( MainEntity.class, 0L, LockModeType.PESSIMISTIC_WRITE );
assertNotNull( m );
ReferencedEntity lazyReference = m.referencedLazy();
assertNotNull( lazyReference );
assertFalse( Hibernate.isInitialized( lazyReference ) );
// Then find and lock the referenced entity
ReferencedEntity lazyEntity = entityManager.find( ReferencedEntity.class, 0L, LockModeType.PESSIMISTIC_WRITE );
assertNotNull( lazyEntity );
assertEquals( LockModeType.PESSIMISTIC_WRITE, entityManager.getLockMode( lazyEntity ) );
} );
}
@Entity(name = "MainEntity2")
public static class MainEntity {
@Id
private long id;
@Version
private long tanum;
private String name;
@ManyToOne(targetEntity = ReferencedEntity.class, fetch = FetchType.LAZY)
@JoinColumn(name = "LAZY_COLUMN")
private ReferencedEntity referencedLazy;
protected MainEntity() {
}
public MainEntity(long id, ReferencedEntity lazy) {
this.id = id;
this.referencedLazy = lazy;
}
public ReferencedEntity referencedLazy() {
return referencedLazy;
}
}
@Entity(name = "ReferencedEntity2")
public static class ReferencedEntity {
@Id
private long id;
@Version
private long tanum;
protected ReferencedEntity() {
}
public ReferencedEntity(long id) {
this.id = id;
}
}
}
from quarkus.
Hey @mensinda thanks for reporting this issue.
Quarkus applies a few settings that are different from the standalone Hibernate ORM configuration. Hence we've recently created this new test template to make it behave a bit closer to how Quarkus works: https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java
I've tried your case using that template and the issue is reproducable within it. Could you please give it a try and report the bug to the ORM JIRA here https://hibernate.atlassian.net/browse/HHH ? Thanks!
from quarkus.
@marko-bekhta the existence of that specific template should probably be documented somewhere. If there is already documentation, I couldn't find any.
from quarkus.
Thanks for creating the ticket and reproducer upstream!
the existence of that specific template should probably be documented somewhere
that's a good idea, I'm not sure where to add it though ... maybe @yrodiere would have a suggestion?
from quarkus.
For Quarkus, not really, since the point of this reproducer is that it's useful only when a bug isn't actually about Quarkus.
I suppose there could be some guidance in the Quarkus issue template, but not sure we want anything specific to ORM there.
For ORM, adding stuff to the various readmes in the test case templates repo would be enough as far as I'm concerned.
from quarkus.
Related Issues (20)
- MessageBundle naming issue HOT 3
- WebAuthn usage with JWT instead of cookies HOT 9
- Upgrading to 3.9.2 from 3.8.3 RolesAllowed on implementing class of an interface using jaxrs are not used. HOT 24
- Upgrading to 3.9.2 from 3.8.1 Multiple Delete from Multiple datasources in One Transactional throw HOT 4
- Add a configuration to serve a local directory with a static handler HOT 17
- Information Exposure Through Environmental Variables HOT 1
- OTEL EUSP error when using Custom Jakarta REST SecurityContext HOT 3
- Discrepancy between Quarkus REST behavior and Cache @CacheInvalidateAll behavior HOT 8
- Programmatically building logger only works with log4j2-jboss-logmanager:1.0.0 HOT 2
- Hot Reloading conflicts with Maven Flatten Plugin HOT 3
- Resteasy Reactive: Ignore JAX-RS Resource method field thanks to custom logic HOT 4
- Jackson: custom ObjectMapper not delegated to MicroProfile RestClient HOT 7
- Jib can't authenticate to the docker.io registry HOT 13
- Mock not executed when running native Tests HOT 2
- Unable to publish app to OpenShift: `field is immutable` HOT 5
- () breaks title in devui HOT 3
- REST Client `@RestForm` does not convert for `List<T>` HOT 3
- Failed to generate Java classes from proto files HOT 2
- Signed JARs may be modified during a native build HOT 1
- Access token is verified also if not needed and using the wrong JWKS HOT 2
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.