小编Eha*_*ati的帖子

具有分页的Spring-Data FETCH JOIN不起作用

我正在尝试使用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)

java spring jpa spring-data spring-data-jpa

27
推荐指数
3
解决办法
1万
查看次数

Facebook缓存不会刷新?

我刚刚重命名了我的facebook应用程序,但Like按钮和链接共享器没有改变,即使我使用了调试工具(没有更多的Linter工具??).任何想法我该怎么做?

iframe caching facebook

6
推荐指数
1
解决办法
1万
查看次数

使用DIH的动态列名称(DataImportHandler)

有没有办法使用从查询抛出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)

??

lucene search solr

6
推荐指数
1
解决办法
1898
查看次数

如何使用spring-data-jpa检索聚合函数查询

我正在使用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数据,我在文档中找不到任何内容

java spring jpa spring-data spring-data-jpa

4
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×2

jpa ×2

spring ×2

spring-data ×2

spring-data-jpa ×2

caching ×1

facebook ×1

iframe ×1

lucene ×1

search ×1

solr ×1