JPA Entity attribute names missing in generated JSON

后端 未结 3 1149
旧巷少年郎
旧巷少年郎 2021-01-28 04:34

I am using JPA and and Jackson is used for generating JSON

Emp.java

@Entity
@NamedQuery(name = \"Emp.findAll\", 
           query = \"select o.empNo, o.         


        
3条回答
  •  萌比男神i
    2021-01-28 04:45

    The difference is that in the query select o.empNo, o.empName from Emp o you select specific entity fields and the every result row is an Object[]. Thus that array of the specified properties.

    The second query select o from Emp o selects the entire entity with all its fields, and what you see is the JSON-marashalled entity.

提交回复
热议问题