I've a Spring web application which uses Spring Data JPA to interact with DB. I've a table consisting millions of records and I want to export a CSV consisting huge amount of data, for this I considered using Stream.
@Query(value = "SELECT * FROM table WHERE id=:id", nativeQuery = true)
public Stream<Object[]> getData(@Param("id") long id);
Executing query works fine and I get the data as stream but the problem occurs when I try to process the stream and I get ClassCastException
ie BigInteger
cannot be cast to Object
. Can someone please suggest where I'm mistaking.
You got ClassCastException because it fetches only first field in select query which may be a numeric type. I have the same problem and updating spring-boot-starter-parent to version 1.4.1.RELEASE make it works. (spring-data-jpa: 1.10.3.RELEASE hibernate-core: 5.0.11.Final)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.