我的理论是,spring无法为扩展另一个类的实体(在我的情况下,该类是DomainObject)创建投影。
这是我的实体(JobEntity):ternary operator
我的资料库
@RepositoryRestResource(excerptProjection = JobExcerpt.class)
public interface JobExcerptRepository extends JpaRepository<JobEntity, Long> {
JobExcerpt findByIdAndRetailerId(Long jobId, Long retailerId);
}
JobExcerpt类:
@Projection(
name = "jobProjection",
types = { JobEntity.class })
public interface JobExcerpt {
Long getId();
Long getRetailerId();
}
在您告诉我必须使我的存储库#findByIdAndRetailerId方法返回类型为“ JobEntity”之前,我已经尝试过并且未应用该投影,因为我能够访问该实体中未定义的字段投影。我正在关注Baeldung的教程以及网络上的其他一些资源。
堆栈跟踪消息
java.lang.ClassCastException: au.com.parcelpoint.domain.batch.JobEntity cannot be cast to au.com.parcelpoint.domain.batch.projection.JobExcerpt