ceyesuma -4 Posting Pro

Could you help me gain understanding the process I need to address?:
String partial = ("SELECT c FROM content AS c WHERE c.artist LIKE \"%" + like + "%\"");
(specifically I wanted("SELECT artist,song,book_title,pag_num FROM content WHERE artist LIKE \"%+like +"%"");
String partial = ("SELECT c FROM content AS c WHERE c.artist LIKE \"%" + like + "%\"");
Is there any one that can explain the procedure to get this query introduced into the persistence unit so it can be run?
(netbeans6.1,MySQL,JDescktopApp)
Brief ex:

private void searchJComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {                                                  
 
    if (searchJComboBox1.getSelectedItem().equals("by Artist")) {
        String holdQuery = searchJComboBox1.getSelectedItem().toString();
        setSearchInput(holdQuery);

        //searchJTextField1.setText(getSearchQuery());
    }
    if (searchJComboBox1.getSelectedItem().equals("by Song")) {
        String holdQuery = searchJComboBox1.getSelectedItem().toString();
        setSearchInput(holdQuery);
      
        //searchJTextField1.setText(getSearchQuery());
    }
}
@Action
    public Task searchSplash() {
        if (searchJComboBox1.getSelectedItem().equals("by Artist")) {
            String like = searchJTextField1.getText();
            String partial=("SELECT c FROM content AS c WHERE c.artist LIKE \"%" + like + "%\"");
            setSearchQuery(partial);
            
           //entityManager.createNativeQuery(partial);
         ;;   searchJTextField1.setText(getSearchQuery());
            
        }
        if (searchJComboBox1.getSelectedItem().equals("by Song")) {
            String like = searchJTextField1.getText();
            String partial = ("SELECT c FROM content AS c WHERE c.artist LIKE \"%" + like + "%\"");
            setSearchQuery(partial);
            // entityManager.createNativeQuery(partial);
            //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 = query.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;
        }

Thank you for your time
-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.