I am having trouble setting a query property for searchQuery1
I must be a return from a getter() (getSearchQuery())
Is it possible to set this query property using a return from a method?

init:
deps-jar:
compile:
run:
[TopLink Info]: 2008.05.06 07:54:48.192--ServerSession(17548445)--TopLink, version: Oracle 

TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2008.05.06 07:54:48.835--ServerSession(17548445)--

file:/K:/ceyesuma/program_cache/in_progress/Enterprise/splashbookinprogress/target/SplashTe

mplateDA/build/classes/-splashbookdbPU login successful
May 6, 2008 7:54:49 PM org.jdesktop.application.Application$1 run
SEVERE: Application class splashtemplateda.SplashTemplateDAApp failed to launch
java.lang.NullPointerException
        at splashtemplateda.SplashTemplateDAView.initComponents

(SplashTemplateDAView.java:352)
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:42)
        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)
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.NullPointerException
        at splashtemplateda.SplashTemplateDAView.initComponents

(SplashTemplateDAView.java:352)
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:42)
        at splashtemplateda.SplashTemplateDAApp.startup(SplashTemplateDAApp.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        ... 8 more
BUILD SUCCESSFUL (total time: 9 seconds)


 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());


searchList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : 

((javax.persistence.Query)null).getResultList();

    searchQuery1 = java.beans.Beans.isDesignTime() ? null : 

searchEntityManager1.createQuery(getSearchQueryString());
        searchEntityManager1 = java.beans.Beans.isDesignTime() ? null : 

javax.persistence.Persistence.createEntityManagerFactory

("splashbookdbPU").createEntityManager();



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



    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());
    }
}                                                 



 @Action
    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 + 

"%\"");
            setSearchQueryString(partial);
            setSearchQuery((Query) searchEntityManager1.createQuery(getSearchQueryString

()));
            searchQuery1=(javax.persistence.Query) getSearchQuery();
            searchQuery1.setParameter("like", "searchJTextField1.getText()");
            List<Content> contents = searchQuery1.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 + "%

\"");
            setSearchQueryString(partial);
            setSearchQuery((Query) searchEntityManager1.createQuery(getSearchQueryString

()));
            searchQuery1=(javax.persistence.Query) getSearchQuery();
            searchQuery1.setParameter("like", "searchJTextField1.getText()");
            List<Content> contents = searchQuery1.getResultList();

            //searchJTextField1.setText(getSearchQuery());

        }
        return new SearchSplashTask(getApplication());
    }


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);

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

           /*
            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);
    }

Edited 3 Years Ago by Dani: Formatting fixed

It seems that the method is set for the query yet the searchList1 needs to be configured.
Does anyone have any insight to setting the binding for the searchQuey and ths searchList?

Is it possible to set this List property using a return from a method?

init:
deps-jar:
Compiling 1 source file to 

K:\ceyesuma\program_cache\in_progress\Enterprise\splashbookinprogress\target\SplashTemplate

DA\build\classes
Note: 

K:\ceyesuma\program_cache\in_progress\Enterprise\splashbookinprogress\target\SplashTemplate

DA\src\splashtemplateda\SplashTemplateDAView.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
compile:
run:
[TopLink Info]: 2008.05.06 10:36:32.479--ServerSession(21662929)--TopLink, version: Oracle 

TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2008.05.06 10:36:33.022--ServerSession(21662929)--

file:/K:/ceyesuma/program_cache/in_progress/Enterprise/splashbookinprogress/target/SplashTe

mplateDA/build/classes/-splashbookdbPU login successful
May 6, 2008 10:36:33 PM org.jdesktop.application.Application$1 run
SEVERE: Application class splashtemplateda.SplashTemplateDAApp failed to launch
java.lang.NullPointerException
        at splashtemplateda.SplashTemplateDAView.initComponents

(SplashTemplateDAView.java:362)
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:43)
        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)
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.NullPointerException
        at splashtemplateda.SplashTemplateDAView.initComponents

(SplashTemplateDAView.java:362)
        at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:43)
        at splashtemplateda.SplashTemplateDAApp.startup(SplashTemplateDAApp.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        ... 8 more
[TopLink Info]: 2008.05.06 10:36:34.422--ServerSession(21662929)--

file:/K:/ceyesuma/program_cache/in_progress/Enterprise/splashbookinprogress/target/SplashTe

mplateDA/build/classes/-splashbookdbPU logout successful
BUILD SUCCESSFUL (total time: 9 seconds)




  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());


        searchList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : 

searchQuery1.getResultList();


        searchQuery1 = java.beans.Beans.isDesignTime() ? null : 

searchEntityManager1.createQuery(getSearchQueryString());
        searchEntityManager1 = java.beans.Beans.isDesignTime() ? null : 

javax.persistence.Persistence.createEntityManagerFactory

("splashbookdbPU").createEntityManager();



searchList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : 

((javax.persistence.Query)null).getResultList();


        searchQuery1 = java.beans.Beans.isDesignTime() ? null : 

searchEntityManager1.createQuery(getSearchQueryString());
        searchEntityManager1 = java.beans.Beans.isDesignTime() ? null : 

javax.persistence.Persistence.createEntityManagerFactory

("splashbookdbPU").createEntityManager();



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



    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());
    }
}                                                 

 @Action
    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 + 

"%\"");
            setSearchQueryString(partial);
            setSearchQuery((Query) searchEntityManager1.createQuery(getSearchQueryString

()));
            searchQuery1=(javax.persistence.Query) getSearchQuery();
            searchQuery1.setParameter("like", "searchJTextField1.getText()");
            setQueryPerParameter(searchQuery1);
            List<Content> contents = searchQuery1.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 + "%

\"");
            setSearchQueryString(partial);
            setSearchQuery((Query) searchEntityManager1.createQuery(getSearchQueryString

()));
            searchQuery1=(javax.persistence.Query) getSearchQuery();
            searchQuery1.setParameter("like", "searchJTextField1.getText()");
            setQueryPerParameter(searchQuery1);
            List<Content> contents = searchQuery1.getResultList();


        }
        return new SearchSplashTask(getApplication());
    }


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);


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


           /*
            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);
    }

Edited 3 Years Ago by Dani: Formatting fixed

This question has already been answered. Start a new discussion instead.