【发布时间】:2020-05-30 02:47:54
【问题描述】:
是否有可能以 CSV 数据的形式从 spring-data JPA 中获取数据,而不是 ArrayList of pojos like
下面是扩展JpaRepository的接口。
public interface FactAggRepository extends JpaRepository<FactAggRepository,Integer> {
@Query("select p from FactAggRepository as p where p.pId=:pId and p.periodStart=:periodStart")
public List<FactAggRepository> getAggregates(@Param("pId") Long pId,@Param("periodStart")LocalDateTime periodStart);
@Query("select p from UsageAgg as p where p.pId=:pId")
public List<UsageAgg> UsageAggregates(@Param("pId") Long pId);
}
自动装配存储库以使用以下相同的方法。
fetchedRecord = AggRepo.getAggregates(pId, periodStart);
现在上面的代码返回了列表。是否可以在不进行任何转换的情况下获取包含列表中数据的 CSV 文件。请告诉我。提前致谢。
【问题讨论】:
标签: oracle csv jpa java-8 spring-data-jpa