-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[BUG] SuperBuilder with generics #3510
Comments
The error is occurring because both BaseEntity and IsDeletedEntity have a method named builder() that causes a name clash due to erasure when you use a generic type for BaseEntity. |
It works! Thank you |
That's a limitation due to static method "overriding" in Java (which is not a real overriding). |
thanks @janrieke I appreciate your help |
I have been trying to make an architecture for my database models. and I'm using BaseEntity and IsDeletedEntity for storing common fields. and BaseEntity accepts a generic but IsDeletedEntity doesn't.
So let me give you an example from my models:
It is my child model which extends BaseEntity model with generic Long type
The BaseEntity
IsDeletedEntity
And finally, the error is
java: name clash: <ID>builder() in com.webperside.courseerpbackend.models.mybatis.base.BaseEntity and builder() in com.webperside.courseerpbackend.models.mybatis.base.IsDeletedEntity have the same erasure, yet neither hides the other
Actually, there is a solution to fix it. If you just add a generic to IsDeletedEntity, and pass it from BaseEntity, it will work. But I want to follow that way, otherwise, I have to create a dummy generic for IsDeletedEntity. which I don't need it in this model.
Version info (please complete the following information):
Lombok version: 1.18.28
Platform
IntelliJ IDEA 2023.1 (Community Edition)
Build #IC-231.8109.175, built on March 28, 2023
Runtime version: 17.0.6+10-b829.5 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.5.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Registry:
debugger.new.tool.window.layout=true
ide.experimental.ui=true
Non-Bundled Plugins:
Docker (231.8109.217)
com.liuzhihang.toolkit.mybatis-jump (1.0.1)
GsonFormatPlus (1.6.1)
com.intellij.lang.jsgraphql (4.0.0)
com.bruce.intellijplugin.generatesetter (2.8.3)
wl-spring-assistant (1.2.222.231)
Kotlin: 231-1.8.20-IJ8109.175
The text was updated successfully, but these errors were encountered: