SQL, HQL and Criteria code completion questions.
Hello,
I am new to the IntelliJ community, and to the IDE itself. I am using IntelliJ Community Edition for about 2 months and now I decided to give a try to the Ultimate Edition. I am using hibernate+spring+jsf. The facet configuration of those technologies was very easy, but I got some questions about code completion of SQL, HQL and Criteria on IDEA:
Criteria: There is not such feature on IDEA, am I right? If not, how does it work? Simple Ctrl + Space does not work.
HQL and SQL: There is the console, which is by itself a stunning feature, but the really WOW feature is the code completion on strings created on the code. I was able to see the code completion working by using the getHibernateTemplate().find("..."), but I almost never create an HQL directly on the getHibernateTemplate().find() method. Rather than that, I use a StringBuilder to create the query and then pass its toString() to the getHibernateTemplate().find(). The situation is analogous to the SQL queries. So I would like to know if there is code completion of HQL and SQL statements other than by the getHibernateTemplate().find() and the statement.executeQuery(). There is something like that on IDEA?
Thanks in advance,
Vitor
请先登录再写评论。
Hello Vitor,
I don't use HQL myself but have a read of this, I think it answers a couple
of your questions: http://grahamhackingscala.blogspot.com/2010/08/impossible-possible-intellij-idea-love.html
Chris
Criteria completion is in IDEA 10 (currently in development).
Get builds from here: http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP
Not that criteria completion works in most cases, but not all. This is expected, as it's simple not possible/unambiguous in all cases.
IDEA provides a "best effort" implementation here.
Regarding the second question: yes, IDEA will provide SQL/HQL code completion for String variables being passed into getHibernateTemplate().find().
At the moment, no code completion is provided for similar variables created through StringBuilder/StringBuffer.
There's an existing feature requests for this, feel free to vote for it:
http://youtrack.jetbrains.net/issue/IDEA-15818
Very interesting. I tried those language injection and it is really an amazing feature. The only thing strange is that IntelliJ added some dependencies to my project (e.g.. org.intellij.lang.annotations) that I cannot remove, but it seams to be something required only by the IDE, an it does not affect the project as a whole. Sometimes this language injection adds an annotation to the code (???), but only when I do not separate the declaration from the definition of the the variable... Guess I have a lot to learn. :)
The language injection worked on a StringBuilder variable, but it does not work correctly when i use the append function. It recognizes each string in each append as one separated query. Thanks for the clarification and for the track link.
Hello Vitor,
The annotation is added in some cases to make the injection persistent otherwise it may be lost on some code modifications.
And it will be definitely lost if a file is closed.
If the temporary injection is what you need feel free to create a feature request.
Regards,
Gregory Shrago
On 02.09.2010 16:57, Vitor Medina Cruz wrote:
>
consider:
String teste = "select * from A"
and :
String teste;
teste = "select * from A"
When i inject in the first case, it puts the annotation, which is not done to the latter example. Lets see, i am still trying this feature, and i didn't have a good oportunity to test it yet.