Native SQL query for an Hibernate entity using @Formula results in NullPointerException

前端 未结 3 2089
忘掉有多难
忘掉有多难 2020-12-11 15:58

I\'ve got an simple Hibernate entity for which I use the @Formula annotion:

    @Id
private Long id;

private String name;

@Formula(\"(select count(f.*) fro         


        
相关标签:
3条回答
  • 2020-12-11 16:14

    Indeed, this seems to be the problem reported in HHH-2225 (that HHH-2536 duplicates). Unfortunately, the issue is not fixed and I'm afraid you'll have to either use HQL or submit a patch (you can start with voting on the issue but I wouldn't expect a fast resolution given that this issue is almost four years old).

    0 讨论(0)
  • 2020-12-11 16:16

    Simply way , don't use createNativeQuery , just use createQuery .. or make a transiant with getter convat

    0 讨论(0)
  • 2020-12-11 16:27

    We could use currentSession.createQuery() instead of currentSession.createSQLQuery(). The query will be slightly different.

    http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/queryhql.html#queryhql-subqueries

    0 讨论(0)
提交回复
热议问题