0

In my project, I fetched all data with Stream but encoding didn't work.

My code looks like:

Repository:

@QueryHints(value = {
    @QueryHint(name = HINT_FETCH_SIZE, value = "" + Integer.MIN_VALUE),
    @QueryHint(name = HINT_CACHEABLE, value = "false"),
    @QueryHint(name = HINT_READONLY, value = "true"),
})
Stream<Book> findAllBy();

Service:

try (var allBooks = bookRepository.findAllBy())
            {
                allBooks.forEach(book -> {
                    
                   logger.info("Coming book name={}", book.getName());

                    // we need to free the memory
                    entityManager.detach(book);
                });
            }

When I fetch it, book name look like: ????, en ???? ??, ????? ????? ?? ...

Then I implement encoding on database url: JPA utf-8 characters not persisted But it didn't work also.

Is there any suggestion? How can I solve this encoding problem?

Solved like:

I gave environmental variable for file-encoding.

-Dfile.encoding=utf8
Sha
  • 921
  • 17
  • 46

1 Answers1

0

I solved my problem using environmental variable:

java -Dfile.encoding=utf8 -jar jar-path
Sha
  • 921
  • 17
  • 46