使用@Query在intellij中进行语言注入 [英] Language injection in intellij with @Query

查看:250
本文介绍了使用@Query在intellij中进行语言注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用intellij想法2016-3.4,是否可以基于参数注入语言?考虑一下

Using intellij idea 2016-3.4, is it possible to inject a language based on a parameter? Consider this

@Query(nativeQuery = true, value = "select * from Foo")
List<Foo> nativeQuery();

@Query(value = "select a from Foo a")
List<Foo> hqlQuery();

第一个示例是本机mySql查询,因此我想注入mySql方言,而第二个示例是hql查询,在此我想注入休眠查询语言.

The first example is a native mySql query, so I'd like to inject mySql dialect, while the second one is a hql query, where I would like to inject the hibernate query language.

现在,如果我在两个查询字符串之一中注入一种语言,则两者都将变为该语言注入.

Right now, if I inject a language in one of the both query strings, both change to that language injection.

我可以让我理解@Query批注中的nativeQuery参数吗?

Can I make idea understand the nativeQuery parameter in the @Query annotation?

推荐答案

是的.

您不能在语言注入窗口中进行操作.

但是您可以使用 语言注入评论 @语言注释 .下面,我使用注释在同一注释中注入 MySQL HTML :

But you can use language injection comments or @Language annotation. Below I inject MySQL and HTML in the same annotation using comments:

要删除评论,请按 Alt + Enter (OS X + Enter ),然后选择Un-inject Language/Reference

To remove comment hit Alt+Enter (OS X +Enter) and choose Un-inject Language/Reference.

这篇关于使用@Query在intellij中进行语言注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆