In the JPA function, I used createnativequery to execute a query statement. This query statement uses union and left join. After the query result is displayed, the number of records is correct, however, the data of each record is exactly the same, and the query statement executed by the record is put in MySQL for query. The result is correct. Each record is a record, but after JPA is mapped to entity, it becomes the same record with the same number.
Later I found out that because union is used and left join is used, in the select Field List, Id points to a completely identical value, that is, although the queried records are different, but its ID result value is the same !!
Therefore, when JPA maps entity, it is divided into different entities based on the ID. If the IDs are the same, it is considered to be the same record and record the records repeatedly, rather than record the values of other fields separately.