<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Create a Query Service</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>Recent changes to Create a Query Service</description><atom:link href="https://sourceforge.net/p/do-db/wiki/Create%20a%20Query%20Service/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 24 Feb 2016 06:33:14 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/do-db/wiki/Create%20a%20Query%20Service/feed" rel="self" type="application/rss+xml"/><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v9
+++ v10
@@ -38,6 +38,6 @@
 ~~~~

 The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
-To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.
+To push the list of view objects to the JavaFX table view simply call **controller.setViewObjects(list)**.

 The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. Therefore it is important to implement the matching methods in view objects as well as in the entity classes.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Wed, 24 Feb 2016 06:33:14 -0000</pubDate><guid>https://sourceforge.net15c786ff3056da749e0d2c407c0880c9b36c697b</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v8
+++ v9
@@ -5,35 +5,38 @@

 ~~~~
-final Service&amp;lt;Integer&amp;gt; service = new Service&amp;lt;Integer&amp;gt;() {
-   @Override
-   protected Task&amp;lt;Integer&amp;gt; createTask() {
-       return new Task&amp;lt;Integer&amp;gt;() {
-           @SuppressWarnings("unchecked")
-           @Override
-           protected Integer call() throws Exception {
-               int listElements = 0;
-               ContractListController&amp;lt;VoContract&amp;gt; controller = 
-                  (ContractListController&amp;lt;VoContract&amp;gt;) ContractListController.this;
-               TypedQuery&amp;lt;Contract&amp;gt; searchQuery =
-                    PersistenceManager.getEntityManager()
-                    .createNamedQuery("ta.getAll", Contract.class);
-               List&amp;lt;Contract&amp;gt; resultList = searchQuery.getResultList();
-               List&amp;lt;VoContract&amp;gt; viewObjectList = new ArrayList&amp;lt;&amp;gt;(resultList.size());
-               // create a view object factory ...
-               EntityViewObjectMapper&amp;lt;V, Contract=""&amp;gt; factory = EntityViewObjectMapperFactory
-                           .getMapper(VoContract.class, Contract.class);
-               // ... and create the list of view objects
-               viewObjectList = (List&amp;lt;VoContract&amp;gt;) factory.getViewObjectList(resultList);
-               // push the list of value objects to the controller
-               controller.synchronize(viewObjectList);
-           }
-           return Integer.valueOf(listElements);
-       }
-   };
-  }
-;
+  final Service&amp;lt;Integer&amp;gt; service = new Service&amp;lt;Integer&amp;gt;() {
+
+    @Override
+    protected Task&amp;lt;Integer&amp;gt; createTask() {
+      return new Task&amp;lt;Integer&amp;gt;() {
+
+        @SuppressWarnings("unchecked")
+        @Override
+        protected Integer call() throws Exception {
+          int listElements = 0;
+          PersonListController&amp;lt;VoPerson&amp;gt; controller = (PersonListController&amp;lt;VoPerson&amp;gt;) PersonListController.this;
+
+          TypedQuery&amp;lt;Person&amp;gt; searchQuery = null;
+          EntityManager entityManager = PersistenceManager.getEntityManager();
+          searchQuery = entityManager.createNamedQuery("Person.getAll", Person.class);
+
+          List&amp;lt;VoPerson&amp;gt; resultList = new ArrayList&amp;lt;&amp;gt;(searchQuery.getResultList().size());
+          // create a view object factory ...
+          EntityViewObjectMapper&amp;lt;V, Person=""&amp;gt; factory = EntityViewObjectMapperFactory.getMapper(VoPerson.class,
+              Person.class);
+          // ... and create the list of view objects
+          resultList = (List&amp;lt;VoPerson&amp;gt;) factory.getViewObjectList(searchQuery.getResultList());
+          listElements = resultList.size();
+          // push the list of view objects to the controller
+          controller.setViewObjects(resultList);
+          return Integer.valueOf(listElements);
+        }
+      };
+    }
+  };
 ~~~~
+
 The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
 To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Thu, 11 Feb 2016 17:13:43 -0000</pubDate><guid>https://sourceforge.net9e051d4df215db54920d7c1fab701d6a8754078a</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -37,4 +37,4 @@
 The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
 To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.

-The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. Therefore it is important to implement these methods in view objects as well as in the entity classes.
+The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. Therefore it is important to implement the matching methods in view objects as well as in the entity classes.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 15:01:17 -0000</pubDate><guid>https://sourceforge.netbfd7b72f6022c3369e242fb1150fbbb39a656cc1</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -37,4 +37,4 @@
 The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
 To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.

-The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. 
+The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. Therefore it is important to implement these methods in view objects as well as in the entity classes.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:38:15 -0000</pubDate><guid>https://sourceforge.net0ae7a128bc99b35fd976eeb9a6e3fa5dbcd60855</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -36,3 +36,5 @@
 ~~~~
 The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
 To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.
+
+The mapping between view object classes and entity classes are simply done by calling the opposite get/set methods of the objects. 
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:36:17 -0000</pubDate><guid>https://sourceforge.net82ef64bea069cdbc00890c9ee4db02c03bcce922</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -34,5 +34,5 @@
   }
 ;
 ~~~~
-The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The methods provides a mapping functionality between the entity object and the view object. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For different combinations of Vo- and entity classes you get a new mapper.
+The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The method provides a mapping functionality between the entity class and the view object class. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For new combinations of Vo- and entity classes you get a new mapper.
 To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:34:30 -0000</pubDate><guid>https://sourceforge.net75347253d48920c7647f6a0bf4f30b1f07e7bae8</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -16,7 +16,8 @@
                ContractListController&amp;lt;VoContract&amp;gt; controller = 
                   (ContractListController&amp;lt;VoContract&amp;gt;) ContractListController.this;
                TypedQuery&amp;lt;Contract&amp;gt; searchQuery =
-                    PersistenceManager.getEntityManager().createNamedQuery("ta.getAll", Contract.class);
+                    PersistenceManager.getEntityManager()
+                    .createNamedQuery("ta.getAll", Contract.class);
                List&amp;lt;Contract&amp;gt; resultList = searchQuery.getResultList();
                List&amp;lt;VoContract&amp;gt; viewObjectList = new ArrayList&amp;lt;&amp;gt;(resultList.size());
                // create a view object factory ...
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:33:01 -0000</pubDate><guid>https://sourceforge.netb63a30570de1cf786b1d185f6effccc3e07a12a9</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -13,8 +13,8 @@
            @Override
            protected Integer call() throws Exception {
                int listElements = 0;
-               ContractListController&amp;lt;VoTransportAgreement&amp;gt; controller = 
-                  (ContractListController&amp;lt;VoTransportAgreement&amp;gt;) ContractListController.this;
+               ContractListController&amp;lt;VoContract&amp;gt; controller = 
+                  (ContractListController&amp;lt;VoContract&amp;gt;) ContractListController.this;
                TypedQuery&amp;lt;Contract&amp;gt; searchQuery =
                     PersistenceManager.getEntityManager().createNamedQuery("ta.getAll", Contract.class);
                List&amp;lt;Contract&amp;gt; resultList = searchQuery.getResultList();
@@ -33,3 +33,5 @@
   }
 ;
 ~~~~
+The important statement is to call **EntityViewObjectMapperFactory.getMapper()**. The methods provides a mapping functionality between the entity object and the view object. For each call of this method you get the same mapper if the Vo-class and the Entity-class are the same. For different combinations of Vo- and entity classes you get a new mapper.
+To push the list of view objects to the JavaFX table view simply call **controller.synchronize()**.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:32:11 -0000</pubDate><guid>https://sourceforge.net87c6a93f4726a55a35b6ca4f7566847315d96854</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -3,74 +3,33 @@

 Lets create a simple service to perform a query:

+
+~~~~
 final Service&amp;lt;Integer&amp;gt; service = new Service&amp;lt;Integer&amp;gt;() {
-       @Override
-       protected Task&amp;lt;Integer&amp;gt; createTask() {
-           return new Task&amp;lt;Integer&amp;gt;() {
-               @SuppressWarnings("unchecked")
-               @Override
-               protected Integer call() throws Exception {
-
-                   taTableView.setVisible(false);
-                   int listElements = 0;
-
-                   ContractListController&amp;lt;VoTransportAgreement&amp;gt; controller = (ContractListController&amp;lt;VoTransportAgreement&amp;gt;) ContractListController.this;
-
-                   TextField search = controller.getTaListSeachTextField();
-                   CheckBox activeOnly = controller.getTaListActiveOnlyCheckBox();
-                   CheckBox ownerOnly = controller.getTaListOwnerOnlyCheckBox();
-                   String pattern = search.getText();
-                   StringTokenizer stoken = new StringTokenizer(pattern, "-");
-                   if (stoken.hasMoreElements()) {
-                       String code = stoken.nextToken().toUpperCase();
-                       TypedQuery&amp;lt;TransportAgreement&amp;gt; searchQuery;
-                       if (code.matches("\\d+[_%]?")
-                               || code.matches("[A-Z0-9][A-Z0-9]([A-Z0-9])?([A-Z0-9])?([A-Z0-9])?[_%]?")) {
-                           String type = "%";
-
-                           if (stoken.hasMoreTokens()) {
-                               type = stoken.nextToken().toUpperCase();
-                           }
-
-                           if ("CAR".equals(type)) {
-                               searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByCarCode",
-                                       TransportAgreement.class);
-                               type = "CAR";
-                           } else {
-                               searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByOrig",
-                                       TransportAgreement.class);
-                               if (stoken.hasMoreTokens()) {
-                                   searchQuery.setParameter("agrNo", stoken.nextToken() + "%");
-                               } else {
-                                   searchQuery.setParameter("agrNo", "%");
-                               }
-                           }
-                           searchQuery.setParameter("code", code);
-                           searchQuery.setParameter("type", type);
-                       } else {
-                           searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByNameCar",
-                                   TransportAgreement.class);
-                           searchQuery.setParameter("buNameCar", pattern + "%");
-                       }
-
-                       searchQuery.setParameter("active", (activeOnly.isSelected() ? 1 : 0));
-                       searchQuery.setParameter("userCodeIns", (ownerOnly.isSelected() ? Main.getUsercode() : "%"));
-                       searchQuery.setParameter("sysdate", new Date());
-
-                       List&amp;lt;TransportAgreement&amp;gt; resultList = searchQuery.getResultList();
-                       List&amp;lt;VoTransportAgreement&amp;gt; viewObjectList = new ArrayList&amp;lt;&amp;gt;(resultList.size());
-                       // create a view object factory ...
-                       EntityViewObjectMapper&amp;lt;V, TransportAgreement=""&amp;gt; factory = EntityViewObjectMapperFactory
-                               .getMapper(VoTransportAgreement.class, TransportAgreement.class);
-                       // ... and create the list of view objects
-                       viewObjectList = (List&amp;lt;VoTransportAgreement&amp;gt;) factory.getViewObjectList(resultList);
-
-                       // push the list of value objects to the controller
-                       controller.synchronize(viewObjectList);
-                   }
-                   taTableView.setVisible(true);
-                   return Integer.valueOf(listElements);
-               }
-           };
+   @Override
+   protected Task&amp;lt;Integer&amp;gt; createTask() {
+       return new Task&amp;lt;Integer&amp;gt;() {
+           @SuppressWarnings("unchecked")
+           @Override
+           protected Integer call() throws Exception {
+               int listElements = 0;
+               ContractListController&amp;lt;VoTransportAgreement&amp;gt; controller = 
+                  (ContractListController&amp;lt;VoTransportAgreement&amp;gt;) ContractListController.this;
+               TypedQuery&amp;lt;Contract&amp;gt; searchQuery =
+                    PersistenceManager.getEntityManager().createNamedQuery("ta.getAll", Contract.class);
+               List&amp;lt;Contract&amp;gt; resultList = searchQuery.getResultList();
+               List&amp;lt;VoContract&amp;gt; viewObjectList = new ArrayList&amp;lt;&amp;gt;(resultList.size());
+               // create a view object factory ...
+               EntityViewObjectMapper&amp;lt;V, Contract=""&amp;gt; factory = EntityViewObjectMapperFactory
+                           .getMapper(VoContract.class, Contract.class);
+               // ... and create the list of view objects
+               viewObjectList = (List&amp;lt;VoContract&amp;gt;) factory.getViewObjectList(resultList);
+               // push the list of value objects to the controller
+               controller.synchronize(viewObjectList);
+           }
+           return Integer.valueOf(listElements);
        }
    };
+  }
+;
+~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:26:24 -0000</pubDate><guid>https://sourceforge.net39c7a1a2bc2351b8c3c29d733ae44002a222a26c</guid></item><item><title>Create a Query Service modified by Ralph</title><link>https://sourceforge.net/p/do-db/wiki/Create%2520a%2520Query%2520Service/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;A controller extending the DbListController has to provide a QueryService.&lt;br/&gt;
This service implements functionality to query data from the database and map the entities to the view objects.&lt;/p&gt;
&lt;p&gt;Lets create a simple service to perform a query:&lt;/p&gt;
&lt;p&gt;final Service&amp;lt;Integer&amp;gt; service = new Service&amp;lt;Integer&amp;gt;() {&lt;br/&gt;
        @Override&lt;br/&gt;
        protected Task&amp;lt;Integer&amp;gt; createTask() {&lt;br/&gt;
            return new Task&amp;lt;Integer&amp;gt;() {&lt;br/&gt;
                @SuppressWarnings("unchecked")&lt;br/&gt;
                @Override&lt;br/&gt;
                protected Integer call() throws Exception {&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;                taTableView.setVisible(false);
                int listElements = 0;

                ContractListController&amp;lt;VoTransportAgreement&amp;gt; controller = (ContractListController&amp;lt;VoTransportAgreement&amp;gt;) ContractListController.this;

                TextField search = controller.getTaListSeachTextField();
                CheckBox activeOnly = controller.getTaListActiveOnlyCheckBox();
                CheckBox ownerOnly = controller.getTaListOwnerOnlyCheckBox();
                String pattern = search.getText();
                StringTokenizer stoken = new StringTokenizer(pattern, "-");
                if (stoken.hasMoreElements()) {
                    String code = stoken.nextToken().toUpperCase();
                    TypedQuery&amp;lt;TransportAgreement&amp;gt; searchQuery;
                    if (code.matches("\\d+[_%]?")
                            || code.matches("[A-Z0-9][A-Z0-9]([A-Z0-9])?([A-Z0-9])?([A-Z0-9])?[_%]?")) {
                        String type = "%";

                        if (stoken.hasMoreTokens()) {
                            type = stoken.nextToken().toUpperCase();
                        }

                        if ("CAR".equals(type)) {
                            searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByCarCode",
                                    TransportAgreement.class);
                            type = "CAR";
                        } else {
                            searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByOrig",
                                    TransportAgreement.class);
                            if (stoken.hasMoreTokens()) {
                                searchQuery.setParameter("agrNo", stoken.nextToken() + "%");
                            } else {
                                searchQuery.setParameter("agrNo", "%");
                            }
                        }
                        searchQuery.setParameter("code", code);
                        searchQuery.setParameter("type", type);
                    } else {
                        searchQuery = PersistenceManager.getEntityManager().createNamedQuery("ta.getByNameCar",
                                TransportAgreement.class);
                        searchQuery.setParameter("buNameCar", pattern + "%");
                    }

                    searchQuery.setParameter("active", (activeOnly.isSelected() ? 1 : 0));
                    searchQuery.setParameter("userCodeIns", (ownerOnly.isSelected() ? Main.getUsercode() : "%"));
                    searchQuery.setParameter("sysdate", new Date());

                    List&amp;lt;TransportAgreement&amp;gt; resultList = searchQuery.getResultList();
                    List&amp;lt;VoTransportAgreement&amp;gt; viewObjectList = new ArrayList&amp;lt;&amp;gt;(resultList.size());
                    // create a view object factory ...
                    EntityViewObjectMapper&amp;lt;V, TransportAgreement&amp;gt; factory = EntityViewObjectMapperFactory
                            .getMapper(VoTransportAgreement.class, TransportAgreement.class);
                    // ... and create the list of view objects
                    viewObjectList = (List&amp;lt;VoTransportAgreement&amp;gt;) factory.getViewObjectList(resultList);

                    // push the list of value objects to the controller
                    controller.synchronize(viewObjectList);
                }
                taTableView.setVisible(true);
                return Integer.valueOf(listElements);
            }
        };
    }
};
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ralph</dc:creator><pubDate>Fri, 05 Feb 2016 12:22:02 -0000</pubDate><guid>https://sourceforge.net9cfc75e873a2ee13c51d2e958a8a8552d972fac0</guid></item></channel></rss>