I attempt to create a string variable to a setter() that is used as query property
What am I missing in the procedure to implement a simple query on the database?
It stops here.
searchList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :
searchQuery1.getResultList();
@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.toString());
searchQuery1=searchEntityManager1.createQuery(getSearchQueryString());
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.toString());
searchQuery1=searchEntityManager1.createQuery(getSearchQueryString());
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);
searchEntityManager1.getTransaction().rollback();
Thread.sleep(1000L); // remove for real app
setProgress(2, 0, 4);
setMessage("Starting a new transaction...");
searchEntityManager1.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;
}
init:
deps-jar:
Compiling 1 source file to
C:\Users\depot\Documents\ceyesuma\program_cache\in_progress\Enterprise\splashbookinprogress
\target\SplashTemplateDA\build\classes
Note:
C:\Users\depot\Documents\ceyesuma\program_cache\in_progress\Enterprise\splashbookinprogress
\target\SplashTemplateDA\src\splashtemplateda\SplashTemplateDAView.java uses unchecked or
unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
compile:
run:
[TopLink Info]: 2008.05.08 05:51:04.301--ServerSession(21662929)--TopLink, version: Oracle
TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2008.05.08 05:51:04.966--ServerSession(21662929)--
file:/C:/Users/depot/Documents/ceyesuma/program_cache/in_progress/Enterprise/splashbookinpr
ogress/target/SplashTemplateDA/build/classes/-splashbookdbPU login successful
May 8, 2008 5:51:05 AM org.jdesktop.application.Application$1 run
SEVERE: Application class splashtemplateda.SplashTemplateDAApp failed to launch
java.lang.NullPointerException
at splashtemplateda.SplashTemplateDAView.initComponents
(SplashTemplateDAView.java:340)
at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:41)
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:340)
at splashtemplateda.SplashTemplateDAView.<init>(SplashTemplateDAView.java:41)
at splashtemplateda.SplashTemplateDAApp.startup(SplashTemplateDAApp.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 8 more
BUILD SUCCESSFUL (total time: 6 seconds)
Thank you for your time
-
Steve