Advantages of Stream and Spring Data

前端 未结 3 1131
灰色年华
灰色年华 2021-02-20 12:13

Some people override the CrudRepository\'s method findAll to return an Stream (java 8), but I saw they finally transform the Stream to a List in order to send it through a rest

3条回答
  •  温柔的废话
    2021-02-20 13:06

    There might be various reasons why people want to use Streams.

    1. If you do any processing that you can't or don't want to do in the database, Streams might be nicer to work with.

    2. It's so hip and "functional". Almost everybody still seems to be experimenting what the right combination of features is. So it is perfectly possible and even likely that there is no benefit in using Streams. But then, it doesn't cost much either.

提交回复
热议问题