add a query add a list

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 239
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

add a query add a list

 
0
  #1
Jan 9th, 2008
How can I create a new query and a new List to hold a resultset?
I have tried by using the follong code in the class below



  1. @Action
  2. public Task search() {
  3. return new SearchTask(getApplication());
  4. }
  5.  
  6. private class SearchTask extends Task {
  7. private String searchQuery;
  8. private List searchList;
  9.  
  10.  
  11. SearchTask(org.jdesktop.application.Application app) {
  12. super(app);
  13.  
  14. searchList = org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
  15.  
  16. }
  17. //public <PropertyType> get<PropertyName>();
  18.  
  19.  
  20. @Override protected Void doInBackground() {
  21. try {
  22. setProgress(0, 0, 4);
  23. setMessage("Rolling back the current changes...");
  24. setProgress(1, 0, 4);
  25. entityManager.getTransaction().rollback();
  26. Thread.sleep(1000L); // remove for real app
  27. setProgress(2, 0, 4);
  28.  
  29. setMessage("Starting a new transaction...");
  30. entityManager.getTransaction().begin();
  31. Thread.sleep(500L); // remove for real app
  32. setProgress(3, 0, 4);
  33.  
  34. setMessage("Fetching new data...");
  35. java.util.Collection data = query.getResultList();
  36. Thread.sleep(1300L); // remove for real app
  37. setProgress(4, 0, 4);
  38.  
  39. Thread.sleep(150L); // remove for real app
  40. list.clear();
  41. list.addAll(data);
  42. } catch(InterruptedException ignore) { }
  43. return null;
  44. }
  45. @Override protected void finished() {
  46. setMessage("Done.");
  47. setSaveNeeded(false);
  48. }
  49. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC