JPA Entity attribute names missing in generated JSON

后端 未结 3 1117
旧巷少年郎
旧巷少年郎 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条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-28 04:52

    In the first case, your JPQL returns a List; each item in the list is an array containing the values of o.empNo and o.empName. Of course, when JSON is produced, it is produced as an array/list of items.

    In the second case, you get a List, which each item being an Employee instance, so it is serialized like an object would be (list of attribute-values).

提交回复
热议问题