how should be looks like code which return Json from database without @Table(tableName) @Entity etc. ? for example , that CustomResponse is not mapped to database table, but by that select I want get same result as normal @Entity @Table class
{
name : "myname",
count: 5
}
@Query(value = """
SELECT name,count from mytable
"""
,nativeQuery = true)
List<CustomResponse> getData();
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomResponse {
private String name;
private Integer count;
}
Try this using JPA constructor expresion :