Question

It took me forever to figure out how to get JPQL auto-completing to working in eclipse. The only place I can see that happening is to add a <mapping-file> to my persistance.xml and in the mapping .xml file I can define a <named-query> . Then if I add the "JPA Details" view and I select the query I want to edit, I get a tiny 4-line textbox in which I must edit my query. Only in this tiny textbox do I get content assistance.

A) Is there any way to hack this textbox to be bigger? (My queries are quite complicated and I need a lot more lines)

B) Is there any other bigger place to get JPQL content assist?

(I have the same issue in Indigo 3.7 and Juno 4.2)

Was it helpful?

Solution

Content assistant is also available via @NamedQuery annotation. If it makes no difference for you to store configuration in XML file or using annotations over Entity class, then you can take advantage of the latter. As soon as you begin editing 'query' element of a @NamedQuery, the same content assistant is available as in JPA Details / Queries. It gives you plenty of space; however, since it's a String constant defined in Java code, you'll have to deal with extra quotes and concatenation in case of query split into multiple lines. At the same time, you will be able to review this query in JPA Details view.

As for JPA Details view, I doubt if this Query editbox is configurable, unless modifying plug-in sources and rebuilding.

EDIT In response to comment (3),- here's a 'direction':

  • JPA Details view along with panels/panes defined in org.eclipse.jpt.jpa.ui plug-in
  • Named Query edit views are defined in classes NamedQueryPropertyComposite and NamedQueryProperty2_0Composite for JPA v1 and JPA v2 accordingly.
  • the code fragment that adjusts named query editor box to 4 lines, looks as following:

    adjustMultiLineTextLayout(
        4,
        provider.getStyledText(),
        provider.getStyledText().getLineHeight()
    );
    

.. where 4 is line count.

The sources are found here: :pserver:anonymous@dev.eclipse.org:/cvsroot/webtools (not sure which specific Eclipse version they are targeted on, but this is definitely newer than what comes with Indigo).

OTHER TIPS

I have entered a bug against the Dali Eclipse project to make this text area larger and have it expand. No hack needed once that is fixed.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=386416

In response to comment (4) - Please enter bugs against Dali for the specific validation errors you are seeing with your complex queries. We definitely want to fix those if they are spec-compliant JPQL queries. If they include anything hibernate specific, the hibernate tools extension would be responsible for that validation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top