繁体   English   中英

这两条指令之间的性能有何不同?

[英]Is there any difference in performance between these two instructions?

我有以下标准规范,并想知道它们的性能或内存使用情况是否有任何差异。 第一种方式:

criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO))
        .add(Restrictions.eq("case.estadoAdministrativo", Caso.EstadoAdministrativo.TARIFICADO));

第二种方式:

criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO));
criteria.add(Restrictions.eq("case.estadoAdministrativo",Caso.EstadoAdministrativo.TARIFICADO));

没有区别, add方法返回this (对于方法链接),而不是新实例。

不。 来自http://docs.jboss.org/hibernate/core/3.3/api/上的api文档

add(Criterion criterion)
    Add a restriction to constrain the results to be retrieved.

您还没有真正检索到任何结果。 在你打电话给.list()之前,你的任何限制都不重要

简而言之,没有。 编译后,criteria.add和.add将在功能上相同。 编译时可能会稍微快一个,但差别在于几纳秒的编译时间,并且在运行时没有差异。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM