Coder Social home page Coder Social logo

Comments (8)

marko-bekhta avatar marko-bekhta commented on June 20, 2024 1

I created a hibernate bug (though I'm not 100% sure it's not originating from Quarkus integration yet): https://hibernate.atlassian.net/browse/HHH-17750

Thanks for taking a closer look. I have reproduced a similar error with just ORM; let's track the progress of this in the issue you've created in ORM JIRA.

from quarkus.

quarkus-bot avatar quarkus-bot commented on June 20, 2024

/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

from quarkus.

ymajoros avatar ymajoros commented on June 20, 2024

I created a hibernate bug (though I'm not 100% sure it's not originating from Quarkus integration yet): https://hibernate.atlassian.net/browse/HHH-17750

from quarkus.

ymajoros avatar ymajoros commented on June 20, 2024

Stack trace when GreetingResource:37 is uncommented in the reproducer:

	at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4168)
	at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:293)
	at org.hibernate.type.EntityType.replace(EntityType.java:315)
	at org.hibernate.type.TypeHelper.replace(TypeHelper.java:88)
	at org.hibernate.event.internal.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:576)
	at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:427)
	at org.hibernate.event.internal.DefaultMergeEventListener.merge(DefaultMergeEventListener.java:208)
	at org.hibernate.event.internal.DefaultMergeEventListener.doMerge(DefaultMergeEventListener.java:146)
	at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:126)
	at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
	at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:847)
	at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:833)
	at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.merge(TransactionScopedSession.java:156)
	at org.hibernate.engine.spi.SessionLazyDelegator.merge(SessionLazyDelegator.java:271)
	at org.hibernate.Session_OpdLahisOZ9nWRPXMsEFQmQU03A_Synthetic_ClientProxy.merge(Unknown Source)
	at org.acme.services.ServiceB.doSomething(ServiceB.java:36)
	at org.acme.services.ServiceB_Subclass.doSomething$$superforward(Unknown Source)
	at org.acme.services.ServiceB_Subclass$$function$$4.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:136)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:107)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:61)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:30)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
	at org.acme.services.ServiceB_Subclass.doSomething(Unknown Source)
	at org.acme.services.ServiceB_ClientProxy.doSomething(Unknown Source)
	at org.acme.GreetingResource.hello(GreetingResource.java:37)
	at org.acme.GreetingResource$quarkusrestinvoker$hello_e747664148511e1e5212d3e0f4b40d45c56ab8a1.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)```

from quarkus.

cghislai avatar cghislai commented on June 20, 2024

Note: We noticed this error only occurs when the entity behind the lazy relation has a @Version field. I edited original post accordingly. The reproducer will be updated as well.

from quarkus.

ymajoros avatar ymajoros commented on June 20, 2024

@marko-bekhta I think this issue is typically mitigated in various frameworks:

  • Spring has "Open session in view".
  • Wildfly seems to have a similar mechanism by default (our application is migrating from Wildfly and the problem wasn't present).
  • Eclipselink (JPA RI) also allows to access lazy properties of detached entities by default (not even sure you can disable that).
  • enable_lazy_load_no_trans is mentioned in multiple sources, although I tried to activate it with quarkus.hibernate-orm.unsupported-properties."hibernate.enable_lazy_load_no_trans"=true, which is actually being read, but I couldn't find any usage besides configuration in Hibernate 6.4.

So I'm wondering: shouldn't Quarkus provide a similar mechanism?

from quarkus.

yrodiere avatar yrodiere commented on June 20, 2024

@ymajoros Feel free to open a feature request (or, more likely, link to an existing one), we can discuss that there.

Though I need to mention that "Open session in view" is widely considered as an anti-pattern, so the discussion (and eventual solution) will have to address that.

from quarkus.

ymajoros avatar ymajoros commented on June 20, 2024

Good idea, I'll check out how to open a feature request if it's the way to go.

It's considered an antipattern by Vlad, which doesn't make it widely accepted. It's the default in Spring, Wildfly and equivalently in the reference implementation (Eclipselink does it by default). It's an endless discussion, I'm well aware of the pro's and con's, but truth is: if you have more than 1 transaction and lazy relations, you will end up with the need to fetch them outside of the first transaction. Projections our (which basically comes down to eager fetching) isn't always the right solution for that.

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.