There is no hard and fast rule, but it is not considered good practice (for very good reasons and its very stubborn look) to use JPA objects as DTO (data transfer objects).
In addition to DTOs, which are light versions of entities in terms of size, there are other advantages.
, , - , . , DTO, JSON .
, JSON ( ) DTO , , DB, - .
( DTO Entity ). API- mapper, .
, , DTO , .
SO , ,
DTO ?
DTO
REST API - DTO ?
DTO.