我有一個@Entity使用querydsl代碼生成的類。問題:我的實體有一個包含一些@Transient字段的父實體。這些在生成過程中不會被跳過。package com.domain.myentity@Entitypublic class MyEntity extends AuditingEntity {}package com.auditing@MappedSuperclasspublic class AuditingEntity { @Transient private transient Object obj;}包信息.java:@QueryEntities(value = MyEntity.class)package com.domain.myentityimport com.querydsl.core.annotations.QueryEntities;import com.domain.myentity.MyEntity;問題:如何告訴 querydsl@Transient自動忽略任何字段?目前,根本原因可能是AuditingEntity與域實體位于不同的文件夾中,因此未在package-info.javaquerydsl 中列出。但是我怎么能在不移動審計實體的情況下解決它呢?期間產生:<plugin> <groupId>com.mysema.maven</groupId> <artifactId>apt-maven-plugin</artifactId> <version>${apt-maven-plugin.version}</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>process</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-apt</artifactId> <version>${querydsl.version}</version> </dependency> </dependencies></plugin>
2 回答

慕勒3428872
TA貢獻1848條經驗 獲得超6個贊
如果您想阻止 QueryDsl 映射字段或方法,您應該使用@QueryType - 帶有PropertyType的注釋。無。
值 PropertyType.NONE 可用于在查詢類型生成中跳過屬性。這種情況與 @Transient 或 @QueryTransient 注釋屬性不同,其中屬性不會持久化。PropertyType.NONE 只是省略了 Querydsl 查詢類型中的屬性。
@Entity
public class MyEntity {
@QueryType(PropertyType.NONE)
public String stringNotInQuerydsl;
}
在這里查看官方文檔
添加回答
舉報
0/150
提交
取消