Generic Attributes in MappedSuperclasses

32 views
Skip to first unread message

Diogo Ferreira

unread,
Oct 30, 2025, 3:44:25 PMOct 30
to Ebean ORM
Hi Rob,

I was trying to use a generic attribute in a MappedSuperclass but it does not seem to work. What I wanted was to have a typified Id for all the children classes of this MappedSuperclass. Something like this:

```
@MappedSuperclass
public abstract class DomainObject<T> {

    @Id
    private T id;

...

    public T getId() {
        return this.id;
    }

...

}

@Entity
public class Client extends DomainObject<ClientId> {

...

}
```

Since there seemed to be no support for this, I went ahead and tried adding it in the following Pull Request https://github.com/ebean-orm/ebean/pull/3692. It adds support for generics in both ebean-core and the querybean-generator. I tested this version in one of my projects and it seemed to work.

Is this something you can see added to the main repo? If so, let me know anything I can improve in the pull request. If not, I would be curious as to the why.

Thanks in advance,

Diogo Ferreira

coolz...@gmail.com

unread,
Nov 15, 2025, 4:29:42 PMNov 15
to Ebean ORM
Is there any news about this?
Reply all
Reply to author
Forward
0 new messages