简体   繁体   English

QUERYDSL:无法获取继承的实体中主键的查询类型

[英]QUERYDSL: Unable to get query type for primary key in the inherited entity

All the entities I have inherit a parent class whose role is to generate the primary key. 我拥有的所有实体都继承了一个父类,其作用是生成主键。 However when I'm trying to join two tables something like this from the documentation 但是,当我尝试连接两个表时,文档中的内容类似

 query.from(customer)
 .leftJoin(company).on(customer.company.eq(company.id))
.list(customer.firstName, customer.lastName, company.name);

However I do not have the Id field in generated query types. 但是,我在生成的查询类型中没有Id字段。 Is there any alternative rather than using native queries as I also have filters which are dynamically generated as BooleanExpression which I want to pass in where clause. 除了使用本机查询,还有其他选择吗,因为我还有一些过滤器,这些过滤器是作为BooleanExpression动态生成的,因此我想在where子句中传递它。

You need a @MappedSuperclass in you parent/super-class 您的父级/超类中需要一个@MappedSuperclass

If you derive from more than one super-class, you MUST tag all the super-classes with @MappedSuperclass to get the inherited fields. 如果您从多个父类派生,则必须使用@MappedSuperclass标记所有父类以获取继承的字段。 This is mandatory for QueryDSL. 这对于QueryDSL是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM