Can someone help me figure out why this .form compiles yet the query to perform a search throws this error?
I have one entity manager,at startup "query and list set the table with all data from <splashtemplateda.Content> combobox and textfield and button(action) should config search specs and refresh table with searchQuey1 and searchList1 using the same entitymanager that the the start up query uses (the one that displays SELECT *.

Thanks
-Steve

Error message:

init: 
deps-jar: 
compile: 
run: 
[TopLink Info]: 2008.05.06 04:17:40.048--ServerSession(21662929)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build 

b09d-fcs (12/06/2007)) 
[TopLink Info]: 2008.05.06 04:17:40.672--ServerSession(21662929)-- 

file:/C:/Users/depot/Documents/ceyesuma/program_cache/in_progress/Enterprise/splashbookinprogress/target/SplashTemplateDA/bui 

ld/classes/-splashbookdbPU login successful 
May 6, 2008 4:17:40 AM org.jdesktop.application.Application$1 run 
SEVERE: Application class splashtemplateda.SplashTemplateDAApp failed to launch 
java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager 
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:209) 
        at splashtemplateda.SplashTemplateDAView.initComponents(SplashTemplateDAView.java:342) 
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:40) 
        at splashtemplateda.SplashTemplateDAApp.startup(SplashTemplateDAApp.java:19) 
        at org.jdesktop.application.Application$1.run(Application.java:171) 
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) 
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) 
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) 
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) 
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) 
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) 
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) 
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) 
Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): 

oracle.toplink.essentials.exceptions.EJBQLException 
Exception Description: Syntax error parsing the query [:partial], line 1, column 1: unexpected token [:partial]. 
Internal Exception: line 1:1: unexpected token: :partial 
        at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:350) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:278) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:378) 
        at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:156) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99) 
        at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86) 
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204) 
        ... 12 more 
Caused by: line 1:1: unexpected token: :partial 
        at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:150) 
        ... 21 more 
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class splashtemplateda.SplashTemplateDAApp failed to 

launch 
        at org.jdesktop.application.Application$1.run(Application.java:177) 
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) 
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) 
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) 
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) 
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) 
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) 
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) 
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) 
Caused by: java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager 
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:209) 
        at splashtemplateda.SplashTemplateDAView.initComponents(SplashTemplateDAView.java:342) 
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:40) 
        at splashtemplateda.SplashTemplateDAApp.startup(SplashTemplateDAApp.java:19) 
        at org.jdesktop.application.Application$1.run(Application.java:171) 
        ... 8 more 
Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): 

oracle.toplink.essentials.exceptions.EJBQLException 
Exception Description: Syntax error parsing the query [:partial], line 1, column 1: unexpected token [:partial]. 
Internal Exception: line 1:1: unexpected token: :partial 
        at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:350) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:278) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:378) 
        at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:156) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166) 
        at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114) 
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99) 
        at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86) 
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204) 
        ... 12 more 
Caused by: line 1:1: unexpected token: :partial 
        at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:150) 
        ... 21 more 
BUILD SUCCESSFUL (total time: 4 seconds)
private void initComponents() { 
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); 
<b>
        ... 

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory     

   ("splashbookdbPU").createEntityManager(); 
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance         

(splashtemplateda.SplashTemplateDAApp.class).getContext().getResourceMap(SplashTemplateDAView.class); 
        query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery(resourceMap.getString("query.query"));     

    //NOI18N 
        list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :
org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList()); 
        searchQuery1 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery(resourceMap.getString     

("searchQuery1.query")); // NOI18N 
        searchList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : searchQuery1.getResultList();
mainPanel.setName("mainPanel"); // NOI18N </b>

        masterScrollPane.setName("masterScrollPane"); // NOI18N 

        masterTable.setName("masterTable"); // NOI

A combo box to set what kind of (search)(relavent actionCommand()//aparently the var holdQuery is unused at present;

private void searchJComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {                                                 

  

    <b>if (searchJComboBox1.getSelectedItem().equals("by Artist")) { 
        String holdQuery = searchJComboBox1.getSelectedItem().toString(); 
        setSearchInput(holdQuery); 

        //searchJTextField1.setText(getSearchQuery1()); 
    } 
    if (searchJComboBox1.getSelectedItem().equals("by Song")) { 
        String holdQuery = searchJComboBox1.getSelectedItem().toString(); 
        setSearchInput(holdQuery); 

       // searchJTextField1.setText(getSearchQuery1()); 
    } 
}

</b>


concatenate (textfield input to SQL) and create query.
the var partial is a entered as :partial in the properties window for the query of the created query searchQuery1.

@Action 
 <b>   public Task searchSplash() { 
        if (searchJComboBox1.getSelectedItem().equals("by Artist")) { 
            String like = searchJTextField1.getText(); 
            String partial = ("SELECT c FROM content c WHERE c.artist LIKE \"%" + like + "%\""); 
            Query searchQuery1 = (Query) entityManager.createQuery(partial); 
            query.setParameter("like", "searchJTextField1.getText()"); 
            List<Content> contents = query.getResultList(); 
            
            //searchJTextField1.setText(getSearchQuery()); 

        } 
        if (searchJComboBox1.getSelectedItem().equals("by Song")) { 
            String like = searchJTextField1.getText(); 
            String partial = ("SELECT c FROM content c WHERE c.song LIKE \"%" + like + "%\""); 
            Query searchQuery1 = (Query) entityManager.createQuery(partial); 
            query.setParameter("like", "searchJTextField1.getText()"); 
            List<Content> contents = query.getResultList(); 
            
            //searchJTextField1.setText(getSearchQuery()); 

        } 
        return new SearchSplashTask(getApplication()); 
    }

</b>


To transfer searchQuery1 to table;

private class SearchSplashTask extends Task { 

        SearchSplashTask(org.jdesktop.application.Application app) { 
            super(app); 
        } 

        @SuppressWarnings("unchecked") 
        @Override 
        protected Void doInBackground() { 
            try { 
                setProgress(0, 0, 4); 
                setMessage("Rolling back the current changes..."); 
                setProgress(1, 0, 4); 
                entityManager.getTransaction().rollback(); 
                Thread.sleep(1000L); // remove for real app 

                setProgress(2, 0, 4); 

                setMessage("Starting a new transaction..."); 
                entityManager.getTransaction().begin(); 
                Thread.sleep(500L); // remove for real app 

                setProgress(3, 0, 4);

<b>

setMessage("Fetching new data..."); 
                java.util.Collection search = searchQuery1.getResultList();

</b>

/* 
                for (Object entity : data) { 
                entityManager.refresh(entity); 
                } 
                */ 
                
                Thread.sleep(1300L); // remove for real app 

                setProgress(4, 0, 4); 

                Thread.sleep(150L); // remove for real app 

                list.clear(); 
            list.addAll(search); 
            } catch (InterruptedException ignore) { 
            } 
            return null; 
        } 

        @Override 
        protected void finished() { 
            setMessage("Done."); 
            setSaveNeeded(false); 
        } 
    }

Read the stack trace. It's clear from this

Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): 

oracle.toplink.essentials.exceptions.EJBQLException 
[B]Exception Description: Syntax error parsing the query [:partial], line 1, column 1: unexpected token[/B] [:partial]. 
Internal Exception: line 1:1: unexpected token: :partial

that you have a syntax error in your query.

Yes. Thank you.
That is exactly what I am working on. I am trying to find a way to change the query details. with a getter(). I am now exploring a way to createNamedQuery(). and have one for each search condition. I have to find out the best way to build a query on the fly and use the correct getResultList().
the easiest way could be to use custom code but I am not sure what code that could be used for searchQuery1 = java.beans.Beans.isDesignTime() ? null : ((javax.persistence.EntityManager)null).createQuery(:partial); -Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.