-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 3.4.x - Build failure: java.lang.Object is used as an embeddable but does not have an @Embeddable annotation #36421
Comments
Reproducer: jpa.zip Note the |
@gsmet Is it possible to get this on someones radar. It's a showstopper for us. Suspect it's a simple fix and a reproducer is already attached. Thanks. |
Confirmed, affects 3.5.0 as well. I'm having a look. |
Also, while at it could we improve the error message to give more context? Because with |
So it looks like Jandex is actually returning the method definition in the superclass instead of the one in the subclass... I'll try to work around that but it's weird. Hey, @Ladicek is it normal that with the following model, when I do @MappedSuperclass
public static interface Identifiable {
Object getId();
}
@Entity
public static class MyEntity implements Identifiable {
private MyEmbeddable id;
@Override
@EmbeddedId
public MyEmbeddable getId() {
return id;
}
public void setId(MyEmbeddable id) {
this.id = id;
}
}
@Embeddable
public static class MyEmbeddable {
private String text;
protected MyEmbeddable() {
// For Hibernate ORM only - it will change the property value through reflection
}
public MyEmbeddable(String text) {
this.text = text;
}
public String getText() {
return text;
}
} |
So actually the returned |
Yeah so it really looks like a bug in Jandex, if I look into the content of the Weirdly, it looks like @Ladicek Please let me know whether I'm mistaken, whether there is a workaround, and whether I should submit a bug report with a reproducer to Jandex itself. In the meantime, this can be reproduced and debugged by checking out this branch: https://github.com/yrodiere/quarkus/tree/i36421 |
I suppose one of the |
Looking at the code above, @MappedSuperclass
public static interface Identifiable {
Object getId();
}
@Entity
public static class MyEntity implements Identifiable {
private MyEmbeddable id;
@Override
@EmbeddedId
public MyEmbeddable getId() {
return id;
}
public void setId(MyEmbeddable id) {
this.id = id;
}
}
@Embeddable
public static class MyEmbeddable {
private String text;
protected MyEmbeddable() {
// For Hibernate ORM only - it will change the property value through reflection
}
public MyEmbeddable(String text) {
this.text = text;
}
public String getText() {
return text;
}
} you will indeed see 2 |
Understood, will do. I confirm this is a bridge method. Thanks a lot! Is it expected that the bridge method is considered annotated with |
Also, if you're interested why the bridge method has the annotation, that's what javac does. Here's a simple test I made:
You see that even the bridge method has the annotation. Jandex is just being faithful here. |
Yes, see above.
That is a great question. It is my opinion that Jandex, being a faithful representation of the bytecode, makes for a poor language model, due to issues like this (which are often ignored, because things work most of the time). On and off, I was thinking if we should introduce an actual language model in Jandex that would shield users from these details. We don't have anything like that yet, I'm afraid. |
Agreed. FWIW @sebersole is currently working on a "domain model" layer (well, multiple layers, because of me 😅) that would sit between Jandex and Hibernate ORM. It's probably not exactly what you have in mind, since it's rather "javabean" oriented (with a concept of attributes like in JPA), but it's close. And would be a library separate from Hibernate ORM, at least for the part we're interested in here. |
Understood. On my side, I was thinking I would add an implementation of the CDI Language Model (which is in fact independent of CDI) as a separate module of Jandex, and it would also include the annotation transformation layer. That should be good enough for a vast majority of users in Quarkus, but Jandex would still be available. In case anyone is interested, the API is in https://github.com/jakartaee/cdi/tree/main/lang-model/src/main/java/jakarta/enterprise/lang/model |
Discussed in #36368
Originally posted by jimbogithub October 10, 2023
I'm seeing this new build error with Quarkus 3.4.2 (was fine for 3.3.3 and prior):
I can't find any explicit use of
Object
as an embedded type in our JPA models.Is it possible that #35598 / #35822 has caused this?
Looks like the new
@Embeddable
checks are being polluted by abstract super-structure and causing false positives.The text was updated successfully, but these errors were encountered: