Can someone show me what to do to get a query to run with persisence?
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 artist,song,book_title,page_num FROM content WHERE 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;
}