Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable HQL/JPQL auto completion in IntelliJ 12

I have problem in IntelliJ 12 to enable the JPQL/HQL auto completion support. Whenever I edit a query IDEA does not suggest me anything on Ctrl-Space.

I have the following plugins enabled

  • Database
  • Hibernate
  • Persistence Frameworks
  • Java EE
  • SQL

Lets say we have this entity.

@Entity
public class SubKonto extends PersistentEntity implements Serializable {    
    @OneToOne
    private Hierarchieknoten hierarchieknoten;

    @ManyToOne
    private SchnittstellenKonfiguration schnittstellenKonfiguration;

    @Column
    private String kontoNummer;
}

If I write a JP Query myself I have seen that IntelliJ supports in auto completing.

"from Sub

with Ctrl-Space completes to

"from SubKonto

Then from

"from SubKonto sk where sk.k

with Ctrl-Space completes to

"from SubKonto sk where sk.kontoNummer

Can anyone give me a hint how to enable it? .

like image 537
saw303 Avatar asked May 30 '13 14:05

saw303


1 Answers

I don't think that your plugins are the issue. There are two things that you should check:

  • Make sure that you have a JPA facet set up. You can do this under the project structure menu (see screenshot below).

enter image description here

  • Set up a persistence unit by clicking on View -> Tool Windows -> Persistence. You will then see the panel shown in the screenshot below in the bottom left. Right click on the top most node here (in my example it would be "Collaborative platform" and then you can choose to add a new persistence unit.

NB: A recommended but optional step is to set up a data source as well and link this to your persistence unit. You can do this in the database panel shown on the right of the screenshot. Once you have added the data source then you can right click back on your persistence unit and choose "Assign data sources..."

enter image description here

Your auto-completion should then be up and running (it works for me :) ).

like image 158
brent777 Avatar answered Sep 19 '22 01:09

brent777