-
Notifications
You must be signed in to change notification settings - Fork 92
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-Reactive Type error for TypedQuery #537
Comments
Strange one. By the way, instead of using |
Ah Sorry, I forgot to add it to the Query above, but sadly i was using it already, when the errors occured. |
I wrote this test class to attempt to reproduce the problem: /* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright: Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.reactive;
import io.vertx.ext.unit.TestContext;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import java.util.Collection;
public class TypedQueryBugTest extends BaseReactiveTest {
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
configuration.addAnnotatedClass( Reaction.class );
configuration.addAnnotatedClass( PostReaction.class );
return configuration;
}
@Test
public void testBug(TestContext context) {
test(context, getMutinySessionFactory()
.withSession( session -> session.persist( new Reaction() )
.chain( ()-> session.createQuery("From Reaction", Reaction.class)
.getResultList().invoke( list-> {
context.assertEquals( 1, list.size() );
list.forEach( reaction -> context.assertTrue(reaction instanceof Reaction));
} )
)
)
);
}
@Entity(name = "Reaction")
public static class Reaction {
@Id
private long id;
private String iconURL;
@Transient
@OneToMany(mappedBy = "react")
private Collection<PostReaction> reactions;
//Getters & Setters
}
@Entity(name = "PostReaction")
public static class PostReaction {
@Id
private long id;
}
} And it passes. So there must be something extra going on here. |
@Sanne could this be Quarkus-specific? |
yes, the error message smells of classloader issue, which would depend on the runtime and how it's integrated. It's strange as Quarkus has a flat classloader, with the exception of support for build and dev-mode, which generally shouldn't have an impact on query execution. We'll need to try reproducing this on Quarkus. |
Right, when I first saw the issue, I thought "classloader". But then I saw Quarkus in the stack trace and decided that mustn't be the problem. |
@Sanne this issue has turned into a bit of a zombie. I doubt it's an issue with HR itself, if anything it's more likely something related to Quarkus. Should we just, like, close it? |
I'm fine with closing this issue. We can re-open it if it happens again |
So let's remember that Quarkus has a "flat classloader" only when running the built application (so called "production" mode); otherwise there are multiple classloaders at play, especially when developing with live-reload. This was most likely related to quarkusio/quarkus#18299 @Artyukin I'll close the issue, but if you could try doing this again after the next Quarkus release that would be great. If you still see this error, please report them to Quarkus. Thanks! |
While working on a Project with Quarkus and Hibernate-Reactive with Mutiny I'm getting a weird error when creating TypedQuerys that appears only on some Entities.
For Example the Query
return mutinySession.createQuery("From Reaction", Reaction.class).getResults();
results in the following exeption:Not sure what could cause that since the class is actually quite minimal
}
The Workaround I found is a bit Hacky, but it works:
return mutinySession.createQuery("From Reaction").getResults().map(ent -> {return (Reaction)ent;});
The text was updated successfully, but these errors were encountered: