0
我无法启动服务器,因为它抱怨在查询中找不到继承的属性。继承类型加入JPA - 在Spring中查询属性JPA
为便于讨论,我已经建立了一个类层次结构是这样的:
BaseContent
==============
id
createUser
Category
===============
id
otherProperties
我声明的类型,像这样:
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "base_content")
public class BaseContent {
...
}
和
@Entity
@Table(name="categories")
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name = "base_content_id", referencedColumnName = "id")
public class Category extends BaseContent{
}
请注意,相关的属性都有getter/setter等。
我使用Spring数据/ JPA和我的服务器和IntelliJ都抱怨说,继承财产createUser
(其中包括)无法为此查询发现:
@Query("select c from Category c " +
"left join fetch c.createUser " +
"left join fetch c.lastUpdateUser " +
"left join fetch c.galleries g " +
"left join fetch g.media " +
"left join fetch c.parentRelationship pr " +
"left join fetch c.productCategoryRelationships pcr " +
"left join fetch pcr.child " +
"left join fetch c.appliedLayouts l " +
"left join fetch pr.parent " +
"where c.id = ?1")
public Category findById(Long categoryId);
我的问题是,因为我m试图将其移动到继承模型(加入),我如何引用注释查询中的继承属性?
(注意,该酒店是在BaseContent公共的getter/setter私有可见)
谢谢