简体   繁体   English

无法创建sessionFactory对象:java.lang.IllegalStateException HQL

[英]Failed to create sessionFactory object: java.lang.IllegalStateException HQL

I have try this one in many ways finally i found a way but it is not working on linux environment following HQL is that 我已经尝试了很多方法,最后我找到了一种方法,但是在HQL之后它不能在linux环境下工作。

SELECT es.eventId as eventId, MAX(es.raisedTimestamp) as raisedTimestamp, es.id as id, es.isReset as isReset FROM EsEvent es WHERE es.isReset=1 GROUP BY es.eventId ORDER BY es.raisedTimestamp DESC

this will end up with the enabled ONLY_FULL_GROUP_BY mode in mysql. 这最终将在mysql中启用ONLY_FULL_GROUP_BY模式。

so that i added ANY_VALUE() function to my hql below one is that. 所以我在下面的hql中添加了ANY_VALUE()函数。

SELECT es.eventId as eventId, MAX(es.raisedTimestamp) as raisedTimestamp, ANY_VALUE(es.id) as id, es.isReset as isReset FROM EsEvent es WHERE es.isReset=1 GROUP BY es.eventId ORDER BY ANY_VALUE(es.raisedTimestamp) DESC

in this case it will end up with HQL exception like this 在这种情况下,它将像这样出现HQL异常

Failed to create sessionFactory object: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode +-[METHOD_CALL] MethodNode: '('|  +-[METHOD_NAME] IdentNode: 'ANY_VALUE' {originalText=ANY_VALUE}|  \-[EXPR_LIST] SqlNode: 'exprList'|     \-[DOT] DotNode:'esevent0_.ID'{propertyName=id,dereferenceType=PRIMITIVE,getPropertyPath=id,path=es.id,tableAlias=esevent0_,className=org.reactor.monitoring.model.entity.EsEvent,classAlias=es}|        +-[ALIAS_REF] IdentNode: 'esevent0_.ID' {alias=es, className=org.reactor.monitoring.model.entity.EsEvent, tableAlias=esevent0_} |        \-[IDENT] IdentNode: 'id' {originalText=id}

please any one can help me to fix this out. 请任何人可以帮助我解决此问题。 it is really helpful and if you can give me reason behind this it's highly appreciate. 这真的很有帮助,如果您能为我提供背后的原因,我们将不胜感激。

You can't use ANY_VALUE() with HQL. 您不能将ANY_VALUE()与HQL一起使用。

But you can 但是你可以

  1. Use it with the native SQL https://www.mkyong.com/hibernate/hibernate-native-sql-queries-examples/ 结合使用本机SQL https://www.mkyong.com/hibernate/hibernate-native-sql-queries-examples/
  2. Add ANY_VALUE() as the custom function to HQL How to use native sql function with HQL query? ANY_VALUE()作为自定义函数添加到HQL 如何在HQL查询中使用本机sql函数?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 SessionFactory 添加到 DAO 导致 java.lang.IllegalStateException: Failed to load ApplicationContext - Adding SessionFactory to DAO results in java.lang.IllegalStateException: Failed to load ApplicationContext java.lang.IllegalStateException:未能创建子事件循环 - java.lang.IllegalStateException: failed to create a child event loop 无法创建JsonObject java.lang.IllegalStateException:不是JSON对象 - can't create a JsonObject java.lang.IllegalStateException: Not a JSON Object 呼叫记录失败,并出现java.lang.IllegalStateException - Call Recording failed with java.lang.IllegalStateException java.lang.IllegalStateException:无法获得表面 - java.lang.IllegalStateException: failed to get surface java.lang.IllegalStateException:无法内省类 - java.lang.IllegalStateException: Failed to introspect Class java.lang.IllegalStateException:无法执行 CommandLineRunner - java.lang.IllegalStateException: Failed to execute CommandLineRunner java.lang.IllegalStateException:无法加载ApplicationContext - java.lang.IllegalStateException: Failed to load ApplicationContext java.lang.IllegalStateException:不是JSON对象 - java.lang.IllegalStateException: Not a JSON Object 无法创建sessionFactory object.java.lang.NullPointerException - Failed to create sessionFactory object.java.lang.NullPointerException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM