在 IntelliJ IDEA 中哪里可以找到已弃用方法的替代方法?
Where to find the deprecated method's alternative method in IntelliJ IDEA?
我有一个问题,如果我在 IntelliJ IDEA 中编写代码,当我遇到一个我想调用的方法,但发现它已被弃用时。但是IntelliJ IDEA没有提示信息提示寻找替代方法,我怎么知道替代方法在哪里?
我的代码可能对我的问题有帮助:
sessionFactory.getCurrentSession().createQuery("from Admin where admin_name=? and pwd=?").setString();
我运行进入了Query.class
,也没有声明alternatime的方法。
Idea 无法帮助您,因为您使用的是反编译源并且那里没有其他信息。如果您 select "Download..." 在顶部的黄色工具栏中,您很可能会获得 Hibernate 的实际来源,并且您会看到类似于我在最新 GitHub 版本中看到的内容Query.java or another Query.java 这两者都在 JavaDoc 上面相应的方法说
* @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
* instead
至于为什么不推荐使用这些方法,我认为 Migration Guide 5.2 提供了一些见解:
Lots of work has been done for 6.0. One of the things 6.0 will need is a unified view of "type systems" including its own type system (Type, EntityPersister, CollectionPersister, etc) and JPA’s type system - which would mean unifying all of this in hibernate-core. Because of this and the other large changes slated for 6.0 we decided to release a 5.2 that showed a clear migration path to the changes in 6.0 but that still supported the older calls and expectations as much as possible.
我有一个问题,如果我在 IntelliJ IDEA 中编写代码,当我遇到一个我想调用的方法,但发现它已被弃用时。但是IntelliJ IDEA没有提示信息提示寻找替代方法,我怎么知道替代方法在哪里?
我的代码可能对我的问题有帮助:
sessionFactory.getCurrentSession().createQuery("from Admin where admin_name=? and pwd=?").setString();
我运行进入了Query.class
,也没有声明alternatime的方法。
Idea 无法帮助您,因为您使用的是反编译源并且那里没有其他信息。如果您 select "Download..." 在顶部的黄色工具栏中,您很可能会获得 Hibernate 的实际来源,并且您会看到类似于我在最新 GitHub 版本中看到的内容Query.java or another Query.java 这两者都在 JavaDoc 上面相应的方法说
* @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
* instead
至于为什么不推荐使用这些方法,我认为 Migration Guide 5.2 提供了一些见解:
Lots of work has been done for 6.0. One of the things 6.0 will need is a unified view of "type systems" including its own type system (Type, EntityPersister, CollectionPersister, etc) and JPA’s type system - which would mean unifying all of this in hibernate-core. Because of this and the other large changes slated for 6.0 we decided to release a 5.2 that showed a clear migration path to the changes in 6.0 but that still supported the older calls and expectations as much as possible.