Skip to content
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

Support for querying against @MappedSuperclass #75

PClaus opened this issue Jan 3, 2012 · 3 comments

Support for querying against @MappedSuperclass #75

PClaus opened this issue Jan 3, 2012 · 3 comments


Copy link

@PClaus PClaus commented Jan 3, 2012

Hi Timo!

I've posted this on StackOverflow:

and you said to create a ticket here as this "is easily implemented" ;)

Basicly we'll need the @MappedSuperclass annotation to be treated as an @entity annotation when generating querytypes.

Summary of our setup:

We are working with single table inheritance for all entities in our application but don't need or want a discriminator column in the database as it would be redundant and cost a lot of space and performance. Hibernate's alternative instead of using

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)

(which is already supported by queryDSL) is to use


so that no discriminator type is required to map the data from an extended entity back to its abstract parent object.

However: The Query DSL querytype generator does not generate an accessor for @MappedSuperclass.


@Inheritance(strategy = InheritanceType.SINGLE_TABLE)@table(name = "client")
public abstract class Client extends AbstractPersistable {
private String name;
// getter, setter...

public class ClientSimple extends Client {

should support a query like this:


with the query.list ultimately returning a List of Client objects than can then be mapped to ClientSimple objects.

This behaviour is neccessairy, because another application instance of the same base application might extend the Client in a different way (ClientAdvanced) but still has to use most of the same querying methods to find objects of the Client type but then cast them to ClientAdvanced.

Copy link

@PClaus PClaus commented Jan 5, 2012

That was fast! Nice! Will integrate and test as soon as a release is available via maven.

Copy link

@timowest timowest commented Feb 7, 2012

released in 2.3.1

@timowest timowest closed this Feb 7, 2012
Copy link

@jaumzera jaumzera commented Sep 26, 2016

Nice. Also worked for me.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants