工业数字模型驱动引擎-使用JDK 17版本应用运行态时,服务编排存在哪些约束与限制?:JPQL/SQL语句相关约束与限制

时间:2025-02-24 15:03:58

JPQL/SQL语句相关约束与限制

  • 使用JPQL(Java Persistence Query Language)进行更新或查询操作时,不允许使用可选的“from”关键字。

    例如,存在一个数据模型“MyEntity”,您想将所有属性“attr”设置为“null”

    在JDK 8版本的应用运行态中,您可以使用以下SQL语句。

    update from MyEntity e set e.attr=null

    使用JDK 17版本后,调用update语句时,需要将update后面的from删除。即:

    update MyEntity e set e.attr=null
  • 使用JPQL进行查询时,不支持使用列名来构建查询。如果存在实体属性的字段名与列名不一致,需要使用字段名进行查询。
  • JPQL不支持直接比较对象与ID,包括根对象(如where myentity=:param)和关联对象(如where myentity.association=:param)。

    如需使用真正的参考对象ID进行比较,可以直接在JPQL查询中使用这个字段,例如where myentity.id = :param

  • 在执行原生SQL查询并返回count()函数的结果时,返回类型为Long,而不是BigInteger
  • JPQL不再支持集合伪属性,例如.size、.elements、.indices、.index、.maxindex、.minindex、.max element、.minelement。如果您希望在JPQL中使用集合伪属性,需要参考如下示例进行修改。
    mycollection.size         ⇒   size(mycollection)
    mycollection.elements     ⇒   value(mycollection)
    mycollection.indices      ⇒   index(mycollection) (for lists) 或者 key(mycollection) (for maps)
    mycollection.maxindex     ⇒   maxindex(mycollection)
    mycollection.minindex     ⇒   minindex(mycollection)
    mycollection.maxelement   ⇒   maxelement(mycollection)
    mycollection.minelement   ⇒   minelement(mycollection)
support.huaweicloud.com/idme_faq/idme_faq_0079.html