Using sql column names in hibernate createSQlquery result

后端 未结 3 2051
误落风尘
误落风尘 2020-12-05 10:42

I have a couple of sql views with composite primary keys that I want to query, and since Hibernate makes it a pain to work with composite keyes, I\'m using createSQLQ

3条回答
  •  感动是毒
    2020-12-05 11:02

    I got the same problem but it solved when i used this

    Query query=session.createSQLQuery("your query");
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    

    I get the result with header name but i got a new problem when i create a new column in sql query Select 'DCA5E3' as Shipmentcolor from Employee.class But in this case i got SHIPMENTCOLOR: "D". How to get whole value of SHIPMENTCOLOR.

提交回复
热议问题