Autocompleting queries with Data Source

I was able to add a JDBC data source without any trouble, and the queries run fine, but even after refreshing the tables it won't auto complete any table or column names.  Any thoughts?  Also, is there a way to point it to the hibernate mappings, so I can write queries referencing the java classes and the mapped names instead of the actual columns?  That's obviously not necessary, it would just be cool and I'd hate to miss out on cool that's there....if it's there.

Thanks in advance.

9 comments

Where it does not auto complete? The sql console or in the code? I had to do nothing special for the auto complete on the console to work. At the code strings, use alt+enter->inject language->SQL or HQL.

To point out to the hibernate mapping do ctrl+shift+alt+S, go to the Hibernate facet and associate your data source to the hibernate.cfg or to the sessionFactory.

0

I'm lacking auto complete in the console, when trying to type out queries manually.  When I first read your reply I hadn't configured the hibernate facet, so I thought that might be the problem, but now having done so that didn't help either.  There is a complete listing of the table and their columns/datatypes in the Data Sources tab on the right, and again, the queries run fine it just won't auto complete the table or column names with ctrl-space.  I'm using an MSSQL db and bound by my employer to use Hibernate 2, so one or both of those might be the cause.

0

Which version if IDEA are you using?
If you're using IDEA 10, you might need to mark the schema as default.

0

Version 8.1.4 build 9952 for Mac, but I experience the same lack of auto complete with version 8 on Windows 7 and Linux (Arch).

0

Hi.

If you use SQL (not HQL) console then the first thing to check is the SQL dialect in console options. Generic dialect does not support DB objects name resolve.
Other dialects do, but notice that MS SQL is not supported, and different dialect may highlight false errors in MS SQL code, and in general, work "incorrectly".

Regards,
Alexander.

0

I hadn't even seen the console options, but choosing Generic SQL and refreshing the tables still doesn't fix it.  For poops and giggles I made a mock MySQL db on a remote server to see if it was an MSSQL issue, but that doesn't work either. I've attached a screen shot of a connection to the MySQL test database where I've selected everything from the table test, but typing "select * from t(ctrl-space)" would not complete the table name test.  You can also see that the dialect was correctly set (automatically) to MySQL.  Thoughts?  Thanks in advance.



Attachment(s):
Screen shot 2010-09-13 at 9.33.11 AM.png
0

For what it's worth, MySQL table/column completion has been working for me since the first version where it was introduced in IDEA (7?).
Are you including the database name in the JDBC URL?

0

Adding the database to the connection string fixed it for MySQL, but not MSSQL (even with the Genereic SQL dialect)  thanks for the suggestion Taras.  So its seeming more like an MSSQL thing....

0

A number of comments:
* It would be worth trying IDEA 10 EAP ("early access program") builds: http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP
* For better MSSQL (Transact-SQL) dialect support, please add a vote to this issue: http://youtrack.jetbrains.net/issue/IDEA-53860 (my vote is there already)
* Note that IDEA 10 has "Smart Completion" (Ctrl-Shift-Space) for SQL , based on PK/FK table relationships. Typing out joins is now like a hot knife slicing through butter :)

-tt

0

Please sign in to leave a comment.