我正在尝试使用HQL使用JOIN FETCH获取我的实体以及子实体,如果我想要所有结果,这是正常工作但如果我想要一个页面则不是这样
我的实体是
@Entity
@Data
public class VisitEntity {
@Id
@Audited
private long id;
.
.
.
@OneToMany(cascade = CascadeType.ALL,)
private List<VisitCommentEntity> comments;
}
Run Code Online (Sandbox Code Playgroud)
因为我有数百万次访问,我需要使用Pageable,我想在单个数据库查询中获取注释,如:
@Query("SELECT v FROM VisitEntity v LEFT JOIN FETCH v.comments WHERE v.venue.id = :venueId and ..." )
public Page<VisitEntity> getVenueVisits(@Param("venueId") long venueId,...,
Pageable pageable);
Run Code Online (Sandbox Code Playgroud)
该HQL调用抛出以下异常:
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=com.ro.lib.visit.entity.VisitEntity.comments,tableName=visitdb.visit_comment,tableAlias=comments1_,origin=visitdb.visit visitentit0_,columns={visitentit0_.visit_id ,className=com.ro.lib.visit.entity.VisitCommentEntity}}] …Run Code Online (Sandbox Code Playgroud) 我刚刚重命名了我的facebook应用程序,但Like按钮和链接共享器没有改变,即使我使用了调试工具(没有更多的Linter工具??).任何想法我该怎么做?
有没有办法使用从查询抛出DIH(DataImportHandler)返回的值创建动态列(作为键/值)名称?
例如:
<entity name="foo" dataSource="my_database" query="select key,value from foo where id=${item.id}">
<field column="${foo.key}" value="${foo.value}" name="${foo.key}_s"/>
</entity>
Run Code Online (Sandbox Code Playgroud)
??
我正在使用Spring数据jpa 1.2,我无论如何都找不到像下面那样检索聚合查询结果.
select count(v), date(v.createTimestamp) from UserEntity v
group by date(v.createTimestamp)
Run Code Online (Sandbox Code Playgroud)
哪个与原生JPA完美配合
@Entity()
public class UserEntity {
@Id
private long id;
.
.
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Timestamp createTimestamp;
}
Run Code Online (Sandbox Code Playgroud)
我的JPA存储库是
public interface UserRepository extends JpaRepository<UserEntity, Long>,
JpaSpecificationExecutor<UserEntity> {
}
Run Code Online (Sandbox Code Playgroud)
那么如何才能进行聚合查询抛出Spring数据,我在文档中找不到任何内容