<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4618693586282052137</id><updated>2024-10-24T05:07:31.188-07:00</updated><category term="WCS"/><category term="Websphere commerce"/><category term="Ajax"/><category term="Volatile"/><category term="Websphere commerce access control"/><category term="bash"/><category term="configuring gwt"/><category term="configuring hibernate"/><category term="configuring spring"/><category term="disable scroll javascript"/><category term="disable scroll jquery"/><category term="docker"/><category term="duplicated linux"/><category term="duplicates unix"/><category term="enum"/><category term="equals in java"/><category term="frameworks"/><category term="gwt application"/><category term="gwt tutorial"/><category term="hcl commerce"/><category term="hibernate tutorial"/><category term="jackson"/><category term="jackson tutorial"/><category term="jar execution in ant"/><category term="java"/><category term="java ant"/><category term="java ant execution"/><category term="javascript"/><category term="jaxcent"/><category term="json"/><category term="kubernetes"/><category term="linux"/><category term="quarkus"/><category term="rdbc"/><category term="reactive"/><category term="remove duplicates in linux"/><category term="remove duplicates in unix"/><category term="rest tutorial"/><category term="scripting"/><category term="shell"/><category term="synch"/><category term="thread"/><category term="volatile in java"/><category term="wcs shipping cost"/><title type='text'>Piero Steffano Del Aguila Macher</title><subtitle type='html'>Sun Certified Java Programmer</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-8756907174975300879</id><published>2021-03-03T06:38:00.002-08:00</published><updated>2021-03-03T06:38:16.471-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="docker"/><category scheme="http://www.blogger.com/atom/ns#" term="kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="quarkus"/><category scheme="http://www.blogger.com/atom/ns#" term="rdbc"/><category scheme="http://www.blogger.com/atom/ns#" term="reactive"/><title type='text'>Quarkus goes Reactive☢</title><content type='html'>In this tutorial I will explain how to create a quarkus based java application that will use reactive datasource to connect to a postgres database and be able to perform crud operations via rest endpoint. To make it more real this application will also be published into kubernetes cluster and will use configmap to store datasource configuration. To lern more about benefits of reactive data sources vs. jdbc regular data sources you can go to following link&amp;nbsp;https://cutt.ly/1l260tK.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 1: Configure Project&amp;nbsp;&lt;/h3&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to start we use and artifact to generate our base project by using the following command:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;b&gt;mvn io.quarkus:quarkus-maven-plugin:1.6.1.Final:create \ -DprojectGroupId=com.pierosteffano \ -DprojectArtifactId=quarkus-reactive-demo \&lt;br /&gt; -DclassName=&quot;com.pierosteffano.EmployeeResource&quot; \ -Dpath=&quot;/employees&quot; \ -Dextensions=&quot;quarkus-resteasy, quarkus-junit5, rest-assured, quarkus-resteasy-jsonb, quarkus-jdbc-postgresql, quarkus-hibernate-orm-rest-data-panache, quarkus-hibernate-orm-panache, quarkus-smallrye-openapi, quarkus-agroal, quarkus-kubernetes, quarkus-kubernetes-config, quarkus-container-image-docker, quarkus-reactive-pg-client, quarkus-resteasy-mutiny&quot; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; This will create a maven base project containing all the dependencies that will be used in this tutorial. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Step 2: Add pojo class&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;/h3&gt;In package com.pierosteffano create a class file named Employee. import io.smallrye.mutiny.Multi;&lt;br /&gt;import io.vertx.mutiny.pgclient.PgPool;&lt;br /&gt;import io.vertx.mutiny.sqlclient.Row;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;public class Employee {&lt;br /&gt;&lt;br /&gt; private Long id;&lt;br /&gt; private String name;&lt;br /&gt; private String lastname; &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On above I&#39;m showing the imports you will need to add and the properties of the Pojo class that will be mapped to table columns. Don&#39;t forget to generate mutators and accessors...&lt;br /&gt; After that we need to add the following methods that will be used to retrieve data from employee table.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;private static Employee from(Row row) {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return new Employee(row.getLong(&quot;id&quot;), row.getString(&quot;name&quot;),row.getString(&quot;lastname&quot;));&lt;br /&gt;}&lt;br /&gt;public static Multi&amp;lt;Employee&amp;gt; findAll(PgPool client) {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return client.query(&quot;SELECT id, name,lastname FROM employees ORDER BY name ASC&quot;).execute()&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.onItem().transformToMulti(set -&amp;gt; Multi.createFrom().iterable(set))&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.onItem().transform(Employee::from);&lt;br /&gt;}&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Step 3: Resource class&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Having done that you will need to create another class that will act as entrypoint of the application.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;import io.smallrye.mutiny.Multi;&lt;br /&gt;import org.eclipse.microprofile.config.inject.ConfigProperty;&lt;br /&gt;import javax.annotation.PostConstruct;&lt;br /&gt;import javax.inject.Inject;&lt;br /&gt;import javax.ws.rs.Consumes;&lt;br /&gt;import javax.ws.rs.GET;&lt;br /&gt;import javax.ws.rs.Path;&lt;br /&gt;import javax.ws.rs.Produces;&lt;br /&gt;import javax.ws.rs.core.MediaType;&lt;br /&gt;&lt;br /&gt;@Path(&quot;employees&quot;)&lt;br /&gt;@Produces(MediaType.APPLICATION_JSON)&lt;br /&gt;@Consumes(MediaType.APPLICATION_JSON)&lt;br /&gt;public class EmployeeResource {&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In this case I named the class as EmployeeResource but you can choose another name.&lt;br /&gt;The important things you need to follow is to include all the imports mentioned on above example, later on you will need to add following fields:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;@Inject&lt;br /&gt;io.vertx.mutiny.pgclient.PgPool client;&lt;br /&gt;@Inject&lt;br /&gt;@ConfigProperty(name = &quot;myapp.schema.create&quot;, defaultValue = &quot;true&quot;)&lt;br /&gt;boolean schemaCreate;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;Then you add the following methods in order to create table and populate it:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;@PostConstruct&lt;br /&gt;void config() {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if (schemaCreate) {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;initdb();&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void initdb() {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;client.query(&quot;DROP TABLE IF EXISTS employees&quot;).execute()&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;.flatMap(r -&amp;gt; client.query(&quot;CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT NOT NULL,lastname TEXT NOT NULL)&quot;).execute())&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.flatMap(r -&amp;gt; client.query(&quot;INSERT INTO employees (name,lastname) VALUES (&#39;John&#39;,&#39;Doe&#39;)&quot;).execute())&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.flatMap(r -&amp;gt; client.query(&quot;INSERT INTO employees (name,lastname) VALUES (&#39;Jane&#39;,&#39;Doe&#39;)&quot;).execute())&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.flatMap(r -&amp;gt; client.query(&quot;INSERT INTO employees (name,lastname) VALUES (&#39;Hamilton&#39;,&#39;Lincoln&#39;)&quot;).execute())&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;.await().indefinitely();&lt;br /&gt;}&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finnally as part of demostration we will add a GET operation in order to fetch employee&amp;nbsp;table information:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;@GET&lt;br /&gt;public Multi&amp;lt;Employee&amp;gt; get() {&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return Employee.findAll(client);&lt;br /&gt;}&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;In order to test you can use following docker sentence to create a postgress db instance:&lt;br /&gt;&lt;br /&gt;&lt;b&gt; docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name quarkus_test -e POSTGRES_USER=quarkus -e POSTGRES_PASSWORD=quarkus -e POSTGRES_DB=quarkusdb -p 5432:5432 postgres:10.5 &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;After container is up and running you can test the application by using following command:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Windows: mvn compile quarkus:dev&lt;br /&gt;Linux: ./mvn compile quarkus:dev&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When application is Up you can hit the following url in your browser: http://localhost:8080/employees in order to list Employee table contents.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Furter steps:&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;To be more real life example here we will set hostname of database connection as config map entry. In order to do that first we need to create a yml file with the sintax and the use kubectl apply command like the following:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;apiVersion: v1 data:&lt;br /&gt; database: &quot;172.17.0.2&quot;&lt;br /&gt;kind: ConfigMap&lt;br /&gt;metadata:&lt;br /&gt; name: quarkus-reactive-demo-config&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To use this configmap on our application we add the following on application.properties:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;%prod.kubernetes.env-vars[0].name=DB_HOST&lt;br /&gt;%prod.kubernetes.env-vars[0].value=database&lt;br /&gt;%prod.kubernetes.env-vars[0].configmap=quarkus-reactive-demo-config&lt;/b&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Notice %prod prefix. This means that property will be used only on prod profile defined on your pom.xml&lt;br /&gt;You can create a profile by adding following on your pom.xml file inside &amp;lt;profiles&amp;gt; tag:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;profile&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;lt;id&amp;gt;prod&amp;lt;/id&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;lt;activation&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;property&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;name&amp;gt;environment&amp;lt;/name&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;value&amp;gt;prod&amp;lt;/value&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;/property&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;lt;/activation&amp;gt;&lt;br /&gt;&amp;lt;/profile&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;After that you will be able to use configMap variable DB_HOST inside you application.properties but name will have some differences: Name will be lowercase and dash character need to be replaced as dot. You can see the following as an example:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;quarkus.datasource.reactive.url=postgresql://${db.host}:5432/quarkusdb&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;In order to package docker container in quarkus you have 3 options: &lt;b&gt;fast-jar, jvm or native&amp;nbsp;&lt;/b&gt;each of them has pro and cons(for more information on quarkus packae types you can go to https://quarkus.io/guides/maven-tooling).&lt;br /&gt;You can get how to package on the three different ways by having a look on src/main/docker directory.&lt;br /&gt;In this tutorial I&#39;ve chosen native profile and also added my own prod profile so app can make use of configmap values created before.&lt;br /&gt;To package the jar I used following sentence:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;mvn package -Pnative,prod -Dquarkus.native.container-build=true&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After jar is generated we can use following command to create docker image:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;docker build -f src/main/docker/Dockerfile.native -t pierosteffano/quarkus-reactive-demo:1.0-SNAPSHOT .&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I updated tag of the image in order to make it work with kubertnetes extension that is used after.&lt;br /&gt;After we do maven package ther will be a kubernetes yml and json files that can be used to create pods based on following properies defined on application.properties.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;quarkus.container-image.group=pierosteffano&lt;br /&gt;%prod.quarkus.kubernetes-config.enabled=true&lt;br /&gt;%prod.quarkus.kubernetes.replicas=1&lt;br /&gt;%prod.quarkus.kubernetes.readiness-probe.initial-delay=20s&lt;br /&gt;%prod.quarkus.kubernetes.readiness-probe.period=45s&lt;br /&gt;%prod.quarkus.kubernetes.deployment-target=kubernetes&lt;br /&gt;%prod.quarkus.container-image.tag=1.0-SNAPSHOT&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In order to create kubernetes pods / services / deployments we use the following:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;kubectl apply -f target/kubernetes/kubernetes.json&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;After that if we need to test in localhost we can create a port forward using the following command:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;kubectl port-forward service/quarkus-reactive-demo 8080:8080&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally we can test by using the following url:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;http://localhost:8080/employees&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/8756907174975300879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/8756907174975300879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8756907174975300879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8756907174975300879'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2021/03/quarkus-goes-reactive.html' title='Quarkus goes Reactive☢'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-2957779086558722165</id><published>2021-02-04T04:17:00.000-08:00</published><updated>2021-03-03T07:35:49.491-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="hcl commerce"/><category scheme="http://www.blogger.com/atom/ns#" term="WCS"/><category scheme="http://www.blogger.com/atom/ns#" term="wcs shipping cost"/><category scheme="http://www.blogger.com/atom/ns#" term="Websphere commerce"/><title type='text'>wcs query to fetch shipping cost  by store</title><content type='html'>&lt;p&gt;In websphere commerce 7 model you can use the folloging query to fetch the shipping cost of catalog entries. This query could also be useful for newer versions.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;select cr.calrange_id,cc.calcode_id, c.partnumber,j.code,j.description,value from catentry c&lt;br /&gt;
left outer join CATENCALCD cd on c.catentry_id=cd.catentry_id&lt;br /&gt;
left outer join calcode cc on&amp;nbsp; cd.calcode_id=cc.calcode_id&lt;br /&gt;
left outer join calrule r on cc.calcode_id=r.calcode_id&lt;br /&gt;
left outer join CRULESCALE s on r.calrule_id=s.calrule_id&lt;br /&gt;
left outer join CALRANGE cr on s.calscale_id=cr.calscale_id&lt;br /&gt;
left outer join CALRLOOKUP cl on cr.CALRANGE_id=cl.CALRANGE_id&lt;br /&gt;
left outer join SHPJCRULE sr on sr.calrule_id=r.calrule_id&lt;br /&gt;
left outer join JURSTGROUP jg on jg.jurstgroup_id=sr.jurstgroup_id&lt;br /&gt;
left outer join JURSTGPREL jgr on jgr.jurstgroup_id=jg.jurstgroup_id&lt;br /&gt;
left outer join JURST j on j.jurst_id=jgr.jurst_id&lt;br /&gt;
where (partnumber like &#39;partnumber% )&lt;br /&gt;
and catenttype_id in (&#39;ItemBean&#39;,&#39;PackageBean&#39;)&lt;br /&gt;
and cc.storeent_id=storeid&lt;br /&gt;
&lt;br /&gt;
and cr.markfordelete=0&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/2957779086558722165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/2957779086558722165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/2957779086558722165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/2957779086558722165'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/wcs-query-to-fetch-shipping-cost-by.html' title='wcs query to fetch shipping cost  by store'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-8210317067129675679</id><published>2021-02-04T04:14:00.002-08:00</published><updated>2021-03-03T07:35:28.739-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="shell"/><title type='text'>Replacing text and remove duplicates by first column</title><content type='html'>&lt;p&gt;When working with plain text files like csv&#39;s you can use the following sentence to remove duplicates. It is a combination of sed and awk commands &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;sed -E &#39;s/([-]{1})([0-9]+)([-]{1})/-WER-/g&#39; file.csv | awk -F- &#39;!seen[$1]++&#39; &amp;gt; outputfile.csv&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/8210317067129675679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/8210317067129675679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8210317067129675679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8210317067129675679'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/replacing-text-and-remove-duplicates-by.html' title='Replacing text and remove duplicates by first column'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-3010466900148803547</id><published>2018-04-13T08:34:00.003-07:00</published><updated>2018-04-13T08:34:59.340-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="duplicated linux"/><category scheme="http://www.blogger.com/atom/ns#" term="duplicates unix"/><category scheme="http://www.blogger.com/atom/ns#" term="remove duplicates in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="remove duplicates in unix"/><title type='text'>Removing duplicates with awk</title><content type='html'>To remove duplicates in linux you can use awk command as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;awk -F- &#39;!seen[$1]++&#39; file.txt &amp;gt; output.txt&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
-F is paraeter to deternime separator used to define columns and in ths case the dash 8-) is the sparator used&lt;br /&gt;
&lt;br /&gt;
&#39;!seen[$1]++&#39; is the expression used for the line in order to be printed&lt;br /&gt;
&lt;br /&gt;
&amp;gt; is the instruction to send command output o a file</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/3010466900148803547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/3010466900148803547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/3010466900148803547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/3010466900148803547'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/removing-duplicates-with-awk.html' title='Removing duplicates with awk'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-7272813074608079205</id><published>2018-04-13T05:41:00.001-07:00</published><updated>2018-04-13T05:41:35.034-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="disable scroll javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="disable scroll jquery"/><title type='text'>Disable scrolling temporary</title><content type='html'>Following example is with jquery but you can doit with plain javascript aswell.&lt;br /&gt;
&lt;br /&gt;
To disable a scroll in a webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;$(&#39;body&#39;).css(&#39;height&#39;, window.innerHeight+&#39;px&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;$(&#39;body&#39;).css(&#39;overflow&#39;, &#39;hidden&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To enable it again:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;$(&#39;body&#39;).css(&#39;height&#39;, &#39;inherit&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;$(&#39;body&#39;).css(&#39;overflow&#39;, &#39;none&#39;);&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/7272813074608079205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/7272813074608079205' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7272813074608079205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7272813074608079205'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/disable-scrolling-temporary.html' title='Disable scrolling temporary'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-3431137542581458481</id><published>2018-04-12T06:25:00.001-07:00</published><updated>2018-04-12T06:29:15.190-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jar execution in ant"/><category scheme="http://www.blogger.com/atom/ns#" term="java ant"/><category scheme="http://www.blogger.com/atom/ns#" term="java ant execution"/><title type='text'>Java execution using ant</title><content type='html'>&lt;b&gt;To execute a java program create a build xml like:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzIY0_m8KnfQ9hybYveO0Pxcguhkkb_eURoqf2H6fOe44fzh0gQ1eoW9q7JJeDtRGHQU5HDUTrWBxznbP8iUGmyAKVMQR6mRFfu0_TX6ZSgJ5Y-A0lh2Be2AJlyc0uF6H2nb7J5rprlBI/s1600/2018-04-12_10h24_07.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzIY0_m8KnfQ9hybYveO0Pxcguhkkb_eURoqf2H6fOe44fzh0gQ1eoW9q7JJeDtRGHQU5HDUTrWBxznbP8iUGmyAKVMQR6mRFfu0_TX6ZSgJ5Y-A0lh2Be2AJlyc0uF6H2nb7J5rprlBI/s400/2018-04-12_10h24_07.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
then execute it by using: &lt;span style=&quot;color: orange;&quot;&gt;ant -buildfile [whathevernameyouwant]&lt;whatevernameyouwant&gt;.xml&lt;/whatevernameyouwant&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/3431137542581458481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/3431137542581458481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/3431137542581458481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/3431137542581458481'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/java-execution-using-ant.html' title='Java execution using ant'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzIY0_m8KnfQ9hybYveO0Pxcguhkkb_eURoqf2H6fOe44fzh0gQ1eoW9q7JJeDtRGHQU5HDUTrWBxznbP8iUGmyAKVMQR6mRFfu0_TX6ZSgJ5Y-A0lh2Be2AJlyc0uF6H2nb7J5rprlBI/s72-c/2018-04-12_10h24_07.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-8085816571908055898</id><published>2018-04-12T05:58:00.001-07:00</published><updated>2018-04-12T06:00:14.587-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="WCS"/><category scheme="http://www.blogger.com/atom/ns#" term="Websphere commerce"/><category scheme="http://www.blogger.com/atom/ns#" term="Websphere commerce access control"/><title type='text'>Register new WCS store view by using database</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;To register a new view by using SQL queries:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;insert into acaction (acaction_id, action) values ((select counter from keys where tablename=&#39;acaction&#39;), &#39;NewView&#39;);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;insert into acactactgp (ACACTGRP_ID,ACACTION_ID) values&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;((SELECT ACACTGRP_ID FROM ACACTGRP WHERE GROUPNAME = &#39;AllSiteUsersViews&#39;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;and member_id in (select orgentity_id from orgentity where orgentityname=&#39;Root Organization&#39;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;),&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;(select acaction_id from acaction where action=&#39;NewView&#39;));&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;UPDATE KEYS SET COUNTER = COUNTER+1 WHERE TABLENAME = &#39;acaction&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;commit&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/8085816571908055898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/8085816571908055898' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8085816571908055898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/8085816571908055898'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2018/04/register-new-wcs-store-view-by-using.html' title='Register new WCS store view by using database'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-1050409503233624334</id><published>2012-08-14T09:35:00.004-07:00</published><updated>2012-08-14T09:35:50.158-07:00</updated><title type='text'>Configuring web application with gwt+spring+hibernate (continued)</title><content type='html'>Last Time we learned how to configure a hibernate+ spring+ GWT application.&lt;br /&gt;
Now we will continue explaining how I built this &amp;nbsp;application.&lt;br /&gt;
&lt;b&gt;First, we&#39;ll start with the Beans.&lt;/b&gt;&lt;br /&gt;
For this example we will define one bean called &lt;b&gt;Regions &lt;/b&gt;and an interface called &lt;b&gt;Bean&lt;/b&gt;.&lt;br /&gt;
Region will be the pojo class that contains the mapping for HR schema regions table&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDww7Ngw7qKu0bE-1WgHNLPGpR_byeeRayJC9UBgNHtYq3NaGQ8uv6NXfX2Qw2aOCu1NezaGnF_Iv3czagS3Oc-rOwYgPIgeNMKMtSEw_q5VaSJkuScWDjMB_QFdn5PQ2wwNzyoOj9x0/s1600/regionFields.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;145&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDww7Ngw7qKu0bE-1WgHNLPGpR_byeeRayJC9UBgNHtYq3NaGQ8uv6NXfX2Qw2aOCu1NezaGnF_Iv3czagS3Oc-rOwYgPIgeNMKMtSEw_q5VaSJkuScWDjMB_QFdn5PQ2wwNzyoOj9x0/s400/regionFields.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Entity&lt;/em&gt;&lt;/strong&gt;&amp;nbsp;annotation is used to mark this class as an Entity bean. To use this annotation the class must have at least a package scope no-argument constructor.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Table&lt;/em&gt;&lt;/strong&gt;&amp;nbsp;annotation is used to specify the table to persist the data. The&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;name&lt;/em&gt;&amp;nbsp;attribute refers to the table name. If&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;@Table&lt;/b&gt;&lt;/em&gt;&amp;nbsp;annotation is not specified then Hibernate will by default use the class name as the table name.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Id&lt;/em&gt;&lt;/strong&gt;&amp;nbsp;annotation is used to specify the identifier property of the entity bean. The placement of the&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Id&lt;/em&gt;&amp;nbsp;annotation determines the default access strategy that Hibernate will use for the mapping. If the&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Id&amp;nbsp;&lt;/em&gt;annotation is placed over the field, then field access will be used. Instead if it placed over the getter method of that field, then property access will be used. Here we use property access.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@Column&lt;/em&gt;&lt;/strong&gt;&amp;nbsp;annotation is used to specify the details of the column to which a field or property will be mapped. Here the regionName property is mapped to&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;REGION_NAME&lt;/em&gt;&amp;nbsp;column in the REGIONS table. If we don&#39;t use the property name of this annotation then hibernate will take the property name as column name.
&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The Bean interface extends Serializable and Comparable and will be implemented by our Pojo&#39;s&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8C7fcLTR81cycBtaL9pTsY-oPlHhJCsyjPNCpEnko-sdmIUKQk6ysAvRrkds27atwxgSHr2mycnkmaCbIVf_8gwsX1RYyH76Bo6AszbxDzbCyjuLCsFp2hvaBMN6TaT1X0NHaQwy2hK8/s1600/beanSource.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;140&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8C7fcLTR81cycBtaL9pTsY-oPlHhJCsyjPNCpEnko-sdmIUKQk6ysAvRrkds27atwxgSHr2mycnkmaCbIVf_8gwsX1RYyH76Bo6AszbxDzbCyjuLCsFp2hvaBMN6TaT1X0NHaQwy2hK8/s400/beanSource.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The comparable interface is for sorting purposes but is out of&amp;nbsp;the&amp;nbsp;scope of this example.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now well proceed to write the DAO.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
First will tell spring that this class will by a data accesor by using &lt;b&gt;@Repository&lt;/b&gt; annotation. The name param is optional, if you don define it then spring will put a default one.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The &lt;b&gt;@Transactional&lt;/b&gt; &amp;nbsp;annotation is used to make all the methods to be within a transaction. (the default is read-only)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNVx9r-Cy29mT_90Tt2m2otJNo8oibSv6Ji-CdArzYsfcl8ijBH8XFL6WV-OLkjDrQM0mutnn4jKU_qYNMf93NxxFVL0WXaHynbhx8mw8QTY4WXteEQdCQU-rAR9jblTeS2wCmoQTyfT8/s1600/regionDAO1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;147&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNVx9r-Cy29mT_90Tt2m2otJNo8oibSv6Ji-CdArzYsfcl8ijBH8XFL6WV-OLkjDrQM0mutnn4jKU_qYNMf93NxxFVL0WXaHynbhx8mw8QTY4WXteEQdCQU-rAR9jblTeS2wCmoQTyfT8/s400/regionDAO1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Next step, the method to retrieve regions:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2_XTxFgRpjA9UPYxudQ9NkfJhJnp29XF4Sz_zlSJ0BeGCtOJcfl5Rkk0BJ_WBLEXLJOREByUv_eepOycqX14BL60Q1gTil0HZ32tKCCm8ZdijLKvYp23z5op5MXt0bc8Z7wJoIqeu1H4/s1600/regionDAO2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;604&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2_XTxFgRpjA9UPYxudQ9NkfJhJnp29XF4Sz_zlSJ0BeGCtOJcfl5Rkk0BJ_WBLEXLJOREByUv_eepOycqX14BL60Q1gTil0HZ32tKCCm8ZdijLKvYp23z5op5MXt0bc8Z7wJoIqeu1H4/s640/regionDAO2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
I used criteria instead of HQL and also implemented the pagination on &quot;DB side&quot;.&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;I also use a &quot;Set&quot; implementation because it doesn&#39;t allow repeated values. (this is&amp;nbsp;necessary&amp;nbsp;in case of &lt;b&gt;@OneTo&lt;/b&gt;&lt;/span&gt;&lt;b&gt;Many&lt;/b&gt;&amp;nbsp;relationships).&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;There are some interfaces that&amp;nbsp;I&#39;ve&amp;nbsp;created but I think you could&amp;nbsp;infer&amp;nbsp;them.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;Now, with the DAO complete, I&#39;ll proceed to explain the Spring Service layer&lt;br /&gt;The business service layer for this example is too simple I will just mention it because of a couple of annotations&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDt_aXbG9_mtUedAafv5pK9bvFpDUR_2mGLfwkwGwrCQ5uSFz4VVCrbjYxFpB4WnHNCTdv47gPwt6DZ05jtoeRnJ76S3EYpX1ya2ur67LhignHaxdyil5IptOibOpc3k6fV_V5QKD7tuo/s1600/regionBService.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;60&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDt_aXbG9_mtUedAafv5pK9bvFpDUR_2mGLfwkwGwrCQ5uSFz4VVCrbjYxFpB4WnHNCTdv47gPwt6DZ05jtoeRnJ76S3EYpX1ya2ur67LhignHaxdyil5IptOibOpc3k6fV_V5QKD7tuo/s400/regionBService.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;To define a business service in spring It is needed to add the @Service annotation to the Class definition as you can see on the image above. The name attribute is optional.&lt;br /&gt;The &lt;b&gt;@Autowired&lt;/b&gt; annotations tells spring to automatically make an instance of the annotated Field. This instantation is made when the spring context loads.&lt;br /&gt;In this service class we call the DAO to read/write data, you could also put some business rules if you need to.&lt;br /&gt;Here, I&#39;ve defined the following method to retrieve the regions:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWDGfZWh4Wl-1yV8ieM0CF2xcmelG0qwyxETsTUDaNGyPaqXtrvsdSNf68seVy3DeMgzlHxUfQUrhFvL5roFqOS-KUfouW74F-1ZnBQIIPcYdHtRwbtL_xK_wWpkAnIMSFusdKpkLladQ/s1600/regionBService1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;102&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWDGfZWh4Wl-1yV8ieM0CF2xcmelG0qwyxETsTUDaNGyPaqXtrvsdSNf68seVy3DeMgzlHxUfQUrhFvL5roFqOS-KUfouW74F-1ZnBQIIPcYdHtRwbtL_xK_wWpkAnIMSFusdKpkLladQ/s400/regionBService1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Finally I will explain what you need to write to show the regions list on screen through GWT&lt;br /&gt;
First, you need to have an Entrypoint class as the one below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMZ3WeGX6S6r7vPRLxkAdTM74ZiLtFzBW4WuCS8Xx7vrUGxHPMeiDhlNDN-dt1Zng7z6SqjxJYAU2BNr38vdYUDaD0bEa_xnOLTeluAA6pHhA1X_XqCSA3AZ9Xu13Bldwg7hqaJBHRXWw/s1600/entryPoinHR1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMZ3WeGX6S6r7vPRLxkAdTM74ZiLtFzBW4WuCS8Xx7vrUGxHPMeiDhlNDN-dt1Zng7z6SqjxJYAU2BNr38vdYUDaD0bEa_xnOLTeluAA6pHhA1X_XqCSA3AZ9Xu13Bldwg7hqaJBHRXWw/s400/entryPoinHR1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
After we have this class we proceed to develop onModuleLoad to start the process of showing the regions list&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuvT_r_5sVycUV9kSzpOm80kG2_sT2EGWZrNFF-qufl382c4daIQELLLwbB3sk5WdBkLzZ0Bj1346c7160O35ZEirWbEGP221cY7IwV3pqWuagJZpglXrVPTC4R9y4Vli3n-sAb__qUvM/s1600/onModuleLoadCode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuvT_r_5sVycUV9kSzpOm80kG2_sT2EGWZrNFF-qufl382c4daIQELLLwbB3sk5WdBkLzZ0Bj1346c7160O35ZEirWbEGP221cY7IwV3pqWuagJZpglXrVPTC4R9y4Vli3n-sAb__qUvM/s400/onModuleLoadCode.png&quot; width=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
In this method we define new object and map objects that already exists on our mapped html.&lt;br /&gt;
&lt;i&gt;*Note: You have to tell GWT&amp;nbsp;which&amp;nbsp;module to bind by&amp;nbsp;declaring&amp;nbsp;it on your html as follows:&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEN1v33Otk-jkVRC5Tb5HSmXJpDHRDZg_ZtEAjwhCqW0EhHBTTqwGPvTgNqsCiXdxf-w8TnnlI58Ii9WI-BAgLws5_VTJtQVlKWJO7UfcVE24a8nwTx23YavRV3g9hZPOdRoU32uxsGTk/s1600/declareModule.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;i&gt;&lt;img border=&quot;0&quot; height=&quot;45&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEN1v33Otk-jkVRC5Tb5HSmXJpDHRDZg_ZtEAjwhCqW0EhHBTTqwGPvTgNqsCiXdxf-w8TnnlI58Ii9WI-BAgLws5_VTJtQVlKWJO7UfcVE24a8nwTx23YavRV3g9hZPOdRoU32uxsGTk/s400/declareModule.png&quot; width=&quot;400&quot; /&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The findRegions method is in charge of calling an AsynchService to get the&amp;nbsp;Regions&amp;nbsp;List.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9DxMcOjOTjulYOWeMaWwXzti3ys7sp8MIfbACv4HH_QIHLYj5G4GSRrEmW9sTeTQeiUM3zjVmwNSM6tssIiCX9vB5FToWcls0QcvkDHB6BTAizsDExrH5HC5xE1V0WukEvKQz8Ako0Q/s1600/finRegionsEP.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9DxMcOjOTjulYOWeMaWwXzti3ys7sp8MIfbACv4HH_QIHLYj5G4GSRrEmW9sTeTQeiUM3zjVmwNSM6tssIiCX9vB5FToWcls0QcvkDHB6BTAizsDExrH5HC5xE1V0WukEvKQz8Ako0Q/s400/finRegionsEP.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;In the method above the declare a new Table that will be inserted within the table container that is a&amp;nbsp;Paragraph&amp;nbsp;object (&lt;br /&gt;
)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;Once&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&amp;nbsp;you&amp;nbsp;finished&amp;nbsp;writing this you will get a lot of error and it because we need to define &amp;nbsp;the method en regionService. Will will do that now.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;We need to define 2 interfaces one for Synchronous communication and the other one for asynchronous communication (Ajax).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;We will start with synch interface: RegionsClientService&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRQDm5f9zUeyq6RiR7QatauzNvGZowq5jCN8jpHcWXK8OK6txyVRiBRIgS-WO8vdURC12Vpw4wDmKuvxK8Rc1kyTWeXLwfg13KzSWrVbWW5hRmPRVeBkIbXJIG2VPb-wGELHftb3bFblM/s1600/RegionClientService.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;107&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRQDm5f9zUeyq6RiR7QatauzNvGZowq5jCN8jpHcWXK8OK6txyVRiBRIgS-WO8vdURC12Vpw4wDmKuvxK8Rc1kyTWeXLwfg13KzSWrVbWW5hRmPRVeBkIbXJIG2VPb-wGELHftb3bFblM/s400/RegionClientService.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;The @RemoteServiceRelativePath enables the calling of this service by using a url string or as Javadoc says: &quot;&lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Associates a&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/rpc/RemoteService.html&quot; title=&quot;interface in com.google.gwt.user.client.rpc&quot;&gt;&lt;code&gt;RemoteService&lt;/code&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;with a relative path. This annotation will cause the client-side proxy to automatically invoke the&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/rpc/ServiceDefTarget.html#setServiceEntryPoint(java.lang.String)&quot;&gt;&lt;code&gt;ServiceDefTarget.setServiceEntryPoint(String)&lt;/code&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;method with&lt;/span&gt;&lt;code&gt;&lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/core/client/GWT.html#getModuleBaseURL()&quot;&gt;&lt;code&gt;GWT.getModuleBaseURL()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;+&amp;nbsp;&lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/rpc/RemoteServiceRelativePath.html#value()&quot;&gt;&lt;code&gt;value()&lt;/code&gt;&lt;/a&gt;&lt;/code&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;as its argument. Subsequent calls to&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/rpc/ServiceDefTarget.html#setServiceEntryPoint(java.lang.String)&quot;&gt;&lt;code&gt;ServiceDefTarget.setServiceEntryPoint(String)&lt;/code&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;will override this default path.&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;background-color: white; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;Once this interface you need to proceed defining the asynch interface&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;RegionClientServiceAsync as follows:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbcKnH96i5r3gThNplk1eF00hs4Rc6WjgDbsZZB3wgXuH2DyA0j7ZN64ban5RrrQiQTm_gKEe0EpCTQ6E5t6MTnMjxFeN1VRYWjXl4uB_TzJmfPrh0jb5XKJlt0DM7o4TsPkIE5qZdK2A/s1600/RegionClientServiceAsynch.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;99&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbcKnH96i5r3gThNplk1eF00hs4Rc6WjgDbsZZB3wgXuH2DyA0j7ZN64ban5RrrQiQTm_gKEe0EpCTQ6E5t6MTnMjxFeN1VRYWjXl4uB_TzJmfPrh0jb5XKJlt0DM7o4TsPkIE5qZdK2A/s640/RegionClientServiceAsynch.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;Notice that the method signature is different from the other interface this is because GWT needs to wrap the method argument inside an AsyncCallBack to work with the result in an asynchronous way.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;Finally comes the implementation RegionClientServiceImpl:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbqao2BrEKe-_MPZT8pQqPLwWVM-6goZU0Lvv5EOeVTqdERQi35wOqmdiTIUa5I-cU0aw6ohroqzCF_4OVq4rBX0mILmatzllDc5Elocni5m7cuvkvRm_lwWnVjU1a0YWSvYVDnPUpujU/s1600/RegionClientImpl.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;379&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbqao2BrEKe-_MPZT8pQqPLwWVM-6goZU0Lvv5EOeVTqdERQi35wOqmdiTIUa5I-cU0aw6ohroqzCF_4OVq4rBX0mILmatzllDc5Elocni5m7cuvkvRm_lwWnVjU1a0YWSvYVDnPUpujU/s640/RegionClientImpl.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;As you can notice, this class is a Servlet. That&#39;s why you hate to define it on web.xml:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzmSjih3aoQ1b-kKzDmeNKko6ls9zt5YY_LYwUFg3VBkI050iTMQxnAtpr5UqMrZ-mjx1o0kaldwuP3EHJTCqhIu-9sTJKLzGQMb1g_Yifc-cCRELU7tjSB86bYnN_rAMbXZ9gAuFh4iI/s1600/webxmlservletconfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;115&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzmSjih3aoQ1b-kKzDmeNKko6ls9zt5YY_LYwUFg3VBkI050iTMQxnAtpr5UqMrZ-mjx1o0kaldwuP3EHJTCqhIu-9sTJKLzGQMb1g_Yifc-cCRELU7tjSB86bYnN_rAMbXZ9gAuFh4iI/s400/webxmlservletconfig.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;*Note: The trailing url pattern must match the string defined on&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20px;&quot;&gt;&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;b&gt;@RemoteServiceRelativePath&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;Now to end of this tut I will show how to run this project:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhHG-tD8P826KmYB9TA1C5qJCldXAqg_BT0yva4N4MSlr9xGYBq_zBQV_GpK8xtBCv4DcXyq3ujjjenJCbrXyw6Hn8eqd_bTKG0TdURiBeMtFciFhU82VsMUvq4oQf1fLwfGHnPuKuYEg/s1600/runHR.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhHG-tD8P826KmYB9TA1C5qJCldXAqg_BT0yva4N4MSlr9xGYBq_zBQV_GpK8xtBCv4DcXyq3ujjjenJCbrXyw6Hn8eqd_bTKG0TdURiBeMtFciFhU82VsMUvq4oQf1fLwfGHnPuKuYEg/s400/runHR.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Right click on the desired webpage and then select run as - Web Application option from the context menu.&lt;br /&gt;
This will trigger the starting of &amp;nbsp;Jetty&amp;nbsp;embedded&amp;nbsp;server and will show a link to start the page:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQOBFfUFLlPAkG8ouNvJzu8JYYxEd7YXTi6PzJELsk7PQa9x1ucYzfj7fvTB44nfOFydMps8i99q4pq53UfVk0Vw3liBaje5p29tLNgExJ48SvSZLxY7jbqhwJ7Qi700e1x-MiJjntjC0/s1600/linkToRun.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;113&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQOBFfUFLlPAkG8ouNvJzu8JYYxEd7YXTi6PzJELsk7PQa9x1ucYzfj7fvTB44nfOFydMps8i99q4pq53UfVk0Vw3liBaje5p29tLNgExJ48SvSZLxY7jbqhwJ7Qi700e1x-MiJjntjC0/s400/linkToRun.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: Helvetica, arial, verdana; font-size: 14px; line-height: 20px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
After you double click this link, the system will raise an explorer window with our page:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQ6_M9vpdY2HAXyJ4r7NS44QoPRS_Kk1Prs8KKkKc5u8nffdv9_imqvdh8fkSsx_EBCVsiTTnhdv_IcUlflap5ASt53wmvThHIudTzRdDphekS2s5X-cTEREwcfqOWXw4zLtTxni0HQc/s1600/hrFinish.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQ6_M9vpdY2HAXyJ4r7NS44QoPRS_Kk1Prs8KKkKc5u8nffdv9_imqvdh8fkSsx_EBCVsiTTnhdv_IcUlflap5ASt53wmvThHIudTzRdDphekS2s5X-cTEREwcfqOWXw4zLtTxni0HQc/s640/hrFinish.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we have a fully&amp;nbsp;functional&amp;nbsp;hibernate+spring+gwt application that you can use as a template for any web app you want.</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/1050409503233624334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/1050409503233624334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/1050409503233624334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/1050409503233624334'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2012/08/configuring-web-application-with_14.html' title='Configuring web application with gwt+spring+hibernate (continued)'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDww7Ngw7qKu0bE-1WgHNLPGpR_byeeRayJC9UBgNHtYq3NaGQ8uv6NXfX2Qw2aOCu1NezaGnF_Iv3czagS3Oc-rOwYgPIgeNMKMtSEw_q5VaSJkuScWDjMB_QFdn5PQ2wwNzyoOj9x0/s72-c/regionFields.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-7830629675584090507</id><published>2012-08-09T12:40:00.001-07:00</published><updated>2012-08-09T12:40:39.845-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="configuring gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="configuring hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="configuring spring"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt application"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="hibernate tutorial"/><title type='text'>Configuring web application with gwt+spring+hibernate</title><content type='html'>Building a web application using hibernate, spring and gwt.&lt;br /&gt;
&lt;br /&gt;
This time we will show how to create and cofigure an application that will use hibernate , spring and gwt.&lt;br /&gt;
I will use HR sample database that comes with OracleXE.&lt;br /&gt;
First , you have to create a GWT project (you can follow the steps for that on&amp;nbsp;&lt;a href=&quot;https://developers.google.com/web-toolkit/&quot;&gt;https://developers.google.com/web-toolkit/&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
After you have the project created you need to create a tree of packages like that:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDrClsdCJQwpNeOX0-zz1Lca89ircZdfj1Xxsq8R7O4egR5EmYJmsYW95C709fGUVoBKlvFxK6Md0-aiE52jFSzMsFxaZ0Wdr0OC7MLpkwM_5iJ_Y2J-MPCRF138xRFnXndrE6pAXLPpY/s1600/hrPackages.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDrClsdCJQwpNeOX0-zz1Lca89ircZdfj1Xxsq8R7O4egR5EmYJmsYW95C709fGUVoBKlvFxK6Md0-aiE52jFSzMsFxaZ0Wdr0OC7MLpkwM_5iJ_Y2J-MPCRF138xRFnXndrE6pAXLPpY/s640/hrPackages.png&quot; width=&quot;376&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Open HumanResources.gwt.xml and add the following line :&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDoH24qr0vOjE63qqFLcnNVwO4HuX3TRmzgrp_Yiur2IcDSJwgctcLa6OjnnLHeIdib-1Xswz8ytvMJ6Bnn4F-GnRpmfg0KjEL2XFhgX3ItBYBs7K5KOhjCn0Pu0eysCTqgPfPHj4Fwyw/s1600/gwtConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;68&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDoH24qr0vOjE63qqFLcnNVwO4HuX3TRmzgrp_Yiur2IcDSJwgctcLa6OjnnLHeIdib-1Xswz8ytvMJ6Bnn4F-GnRpmfg0KjEL2XFhgX3ItBYBs7K5KOhjCn0Pu0eysCTqgPfPHj4Fwyw/s200/gwtConfig.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
By doing that you tell gwt to include model package and all dependent packages into gwt compilation&lt;br /&gt;
&lt;br /&gt;
Now we can start configuring spring and hibernate.&lt;br /&gt;
&lt;br /&gt;
to configure spring first you have to add the following lines on web.xml&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNKOVG_zYr3j-OqJ8avVs59rwOSmjTt_0bFbOvsw-5S8oVNxOxNG7rnkarwgjf0Gc0iUV9njKhkuvqFZ7R4OU1JjBT-o8iaeflDjJnNtvzbPuVGChncT4cEw7EHupV3tF6sWPc6J0YAgY/s1600/springConfigwebxml.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;164&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNKOVG_zYr3j-OqJ8avVs59rwOSmjTt_0bFbOvsw-5S8oVNxOxNG7rnkarwgjf0Gc0iUV9njKhkuvqFZ7R4OU1JjBT-o8iaeflDjJnNtvzbPuVGChncT4cEw7EHupV3tF6sWPc6J0YAgY/s640/springConfigwebxml.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This will allow spring context to start doing its business.&lt;br /&gt;
The you will have to create a field called &quot;app-config.xml&quot; in which you will define the settings for spring and hibernate.&lt;br /&gt;
Over this app-config file first configure the properties as follows&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQsjg53KPPA3r3Yxf2yQ7zWfYidgrZ61zOg92FVtGlCwsLos-kKdhUQgSnj-m6Soqli_p0sanoHLecGV9FJh9S7eVl0FpXAI5hpniDUlJ7WltiUNyAxtYNjdLdFoCOi5mcEVEi8eFD2QE/s1600/springPropertyConfigurer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQsjg53KPPA3r3Yxf2yQ7zWfYidgrZ61zOg92FVtGlCwsLos-kKdhUQgSnj-m6Soqli_p0sanoHLecGV9FJh9S7eVl0FpXAI5hpniDUlJ7WltiUNyAxtYNjdLdFoCOi5mcEVEi8eFD2QE/s640/springPropertyConfigurer.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
You will have to create another file called configuration.properties in which you will define the values of the properties that you will use on you xml (this will also apply for included xmls)&lt;br /&gt;
&lt;br /&gt;
Next you need to configure the component scan as follows&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2KelwLkuWO63uIoS4wtWuPg0Jc59rUJd28NDZb6k6mIYR2l0bLqrPMDxU23g0yBcD8rBLFgTz3vjzcpZ0-XZxV7GJ3S8ctQBaudzdzKgHujbv2Z77dlLz72PdAqIp9Z5EL6w-GL-FtCE/s1600/springComponentScan.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2KelwLkuWO63uIoS4wtWuPg0Jc59rUJd28NDZb6k6mIYR2l0bLqrPMDxU23g0yBcD8rBLFgTz3vjzcpZ0-XZxV7GJ3S8ctQBaudzdzKgHujbv2Z77dlLz72PdAqIp9Z5EL6w-GL-FtCE/s640/springComponentScan.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The lines above will tell spring to scan the annotations defined on classes of package com.model.services and com.hr.model.daos&lt;br /&gt;
&lt;br /&gt;
The last step for this file is to include the xml for configuring hibernate:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdF73lWwW0CADpiEa71CSHdnFpVHSt7Wkl-eDW9PBpcYNrH3W5-aLRfoIstCDpWt-nZ63N1usfeAhs1exxEgdfYYez4olsx0_nhSEukzwGEHf86KyzMD3YOqYuSNBbEeTHDlDIC9k8opw/s1600/spirngImportxml.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;49&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdF73lWwW0CADpiEa71CSHdnFpVHSt7Wkl-eDW9PBpcYNrH3W5-aLRfoIstCDpWt-nZ63N1usfeAhs1exxEgdfYYez4olsx0_nhSEukzwGEHf86KyzMD3YOqYuSNBbEeTHDlDIC9k8opw/s320/spirngImportxml.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
By doing that you will tell spring to read also the contents of db-config.xml.&lt;br /&gt;
&lt;br /&gt;
Now is time to configure db-config.xml, this file contains all the configuration that hibernate will use:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSo7LiMKyAp8kg-CVxjtiFE0D1LKsFsaU8uyuvuSf-Udt9rKB7WgotQWPMMlTiSpdBd08ZIqPWOrOMzd0M7zUtj1bPiOs40hoJzdYolU-bvCQe9k-ZQOUCFAcZZOur1LomxNiYPQtCuOg/s1600/hibernateDatasource.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSo7LiMKyAp8kg-CVxjtiFE0D1LKsFsaU8uyuvuSf-Udt9rKB7WgotQWPMMlTiSpdBd08ZIqPWOrOMzd0M7zUtj1bPiOs40hoJzdYolU-bvCQe9k-ZQOUCFAcZZOur1LomxNiYPQtCuOg/s640/hibernateDatasource.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Remember the file called configuration.properties? Well, here is where we will use the properties defined on it.&lt;br /&gt;
After defining the DS we proceed to&amp;nbsp;set-up&amp;nbsp;hibernate session factory&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuedOI-_O-vgGHiofy3ZGqhmQc8MONnjvS0OOjpABiWXtKrhHqTfWFyzcc9I4eu5gkzwt7M0zm22F6aaF3Tk0ujWjZl9zmJkiXGtxVoVE9s0BBwUmTRwUS01J62m79lqTrwc8zybMsK48/s1600/hibernateSession.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuedOI-_O-vgGHiofy3ZGqhmQc8MONnjvS0OOjpABiWXtKrhHqTfWFyzcc9I4eu5gkzwt7M0zm22F6aaF3Tk0ujWjZl9zmJkiXGtxVoVE9s0BBwUmTRwUS01J62m79lqTrwc8zybMsK48/s640/hibernateSession.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here you define the packages to scan. These will tell hibernate where to look for annotated classes in this example hibernate will look on &quot;&lt;b&gt;com.hr.model.beans&quot;.&lt;/b&gt;&lt;br /&gt;
You will also use the values &amp;nbsp;defined on configuration.properties to tell hibernate which dialect to use. The database of the example is oracle in my case I use &quot;&lt;b&gt;org.hibernate.dialect.Oracle10gDialect&lt;/b&gt;&quot;&lt;br /&gt;
Finally we will define the TransaciontManager and add the sessionFactory we&#39;ve created and also tell spring that you will define the transactional behaviour by using annotations:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV0vJS0fv_jsKKMw8rhTEdfD7Y0bOg6L2GRBkHv8znKEcewj0o_qEopRJxYZpDxo2cVHPttDVKkdUDk82V1xZeyKN0l3Kjg4rm9bp5s14p7cEeZiNMNtM45q1c4ShOWzTNRqdFXTXNJu4/s1600/hibernateTManager.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV0vJS0fv_jsKKMw8rhTEdfD7Y0bOg6L2GRBkHv8znKEcewj0o_qEopRJxYZpDxo2cVHPttDVKkdUDk82V1xZeyKN0l3Kjg4rm9bp5s14p7cEeZiNMNtM45q1c4ShOWzTNRqdFXTXNJu4/s640/hibernateTManager.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
That&#39;s it. We finished configuring the&amp;nbsp;project, now we can start coding.&lt;br /&gt;
&lt;br /&gt;
On the next post I will explain step for step the coding for this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/7830629675584090507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/7830629675584090507' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7830629675584090507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7830629675584090507'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2012/08/configuring-web-application-with.html' title='Configuring web application with gwt+spring+hibernate'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDrClsdCJQwpNeOX0-zz1Lca89ircZdfj1Xxsq8R7O4egR5EmYJmsYW95C709fGUVoBKlvFxK6Md0-aiE52jFSzMsFxaZ0Wdr0OC7MLpkwM_5iJ_Y2J-MPCRF138xRFnXndrE6pAXLPpY/s72-c/hrPackages.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-5843373470137174087</id><published>2012-07-30T15:23:00.001-07:00</published><updated>2012-08-09T10:11:43.028-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="synch"/><category scheme="http://www.blogger.com/atom/ns#" term="thread"/><category scheme="http://www.blogger.com/atom/ns#" term="Volatile"/><category scheme="http://www.blogger.com/atom/ns#" term="volatile in java"/><title type='text'>Volatile keyword in JAVA</title><content type='html'>&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;I&#39;ve found an interesting and easy to understand explanation about volatile keyword, it came with an example but it was wrong so I&#39;ve corrected it.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;A volatile variable does not have a copy maintained in the local memory of the thread (on the stack). All changes to the volatile variable (caused by multiple threads) are flushed out to the heap memory (visible from all threads). Hence volatile variable values remain consistent for all threads.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;On the other hand, for other instance variables, each java thread maintains a local copy on the stack. Multiple threads may modify this local copy of the instance variable and hence inconsistent values may be visible for multiple threads.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;For preventing this condition, we synchronize. During synchronization, a lock is first taken on the object monitor. Then the thread reads the state from the main memory and flushes its internal state. Subsequently, the synchronized code block/method code is executed. Once the execution completes, all the changes to the variables of that thread are flushed out to the main memory. Then the object monitor lock is released.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;So, as we can see, volatile is a specialized case of synchronization. The only exceptions are, that it operates on a single field and no locks on the object monitor are required (as it operates on the heap memory and not the thread local stack memory).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace; font-size: 16px; line-height: 24px; text-align: left;&quot;&gt;If you are working with the multi-threaded programming, the volatile keyword will be more useful. When multiple threads using the same variable, each thread will have its own copy of the local cache for that variable. So, when it&#39;s updating the value, it is actually updated in the local cache not in the main variable memory. The other thread which is using the same variable doesn&#39;t know anything about the values changed by the another thread. To avoid this problem, if you declare a variable as volatile, then it will not be stored in the local cache. Whenever thread are updating the values, it is updated to the main memory. So, other threads can access the updated value.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;class ExampleThread extends Thread {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; private volatile int testValue;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; public ExampleThread(String str) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;super(str);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; public void run() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (int i = 0; i &amp;lt; 3; i++) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;try {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(Thread.currentThread().getName() + &quot; : &quot; + i);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (Thread.currentThread().getName().equalsIgnoreCase(&quot;T1&quot;)) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;System.out.println(&quot;Test Value T1: &quot; + testValue);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;testValue = 10;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (Thread.currentThread().getName().equalsIgnoreCase(&quot;T2&quot;)) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;System.out.println(&quot;Test Value T2: &quot; + testValue);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;testValue = 20;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Thread.sleep(1000);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;} catch (InterruptedException exception) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;exception.printStackTrace();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;public class VolatileExample {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; public static void main(String args[]) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ExampleThread exampleThread = new ExampleThread(&quot;Thread 1 &quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Thread t1 = new Thread(exampleThread, &quot;T1&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Thread t2 = new Thread(exampleThread, &quot;T2&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;t1.start();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;t2.start();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Lucida Console&#39;, &#39;courier new&#39;, monospace;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/5843373470137174087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/5843373470137174087' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/5843373470137174087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/5843373470137174087'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2012/07/volatile-keyword-in-java.html' title='Volatile keyword in JAVA'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-7273955418457829944</id><published>2012-07-11T08:16:00.005-07:00</published><updated>2012-07-11T08:18:58.863-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jackson"/><category scheme="http://www.blogger.com/atom/ns#" term="jackson tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><category scheme="http://www.blogger.com/atom/ns#" term="rest tutorial"/><title type='text'></title><content type='html'>Calling a rest service with spring rest + json jackson

Presenting to you step by step a tutorial about the use of some apis that leverage the logic for calling to a rest service and also the json parting and marshalling process&lt;br /&gt;
First Step Importing required libs:
&lt;br /&gt;
&lt;br /&gt;
You will need to import spring for droid there are the files:&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;spring-android-auth-1.0.0.M4.jar&lt;br /&gt;
spring-android-core-1.0.0.M4.jar&lt;br /&gt;
spring-android-rest-template-1.0.0.M4.jar&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need to import jackson lib there is the file:&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;jackson-all-1.9.4.jar&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Step : Declaring variables&lt;br /&gt;
You will need these three variables to do the trick. I will recomend to declare them as fields and instantiate them later on class constructor.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;RestTemplate restTemplate = new RestTemplate();&lt;br /&gt;
ObjectMapper objectMapper = new ObjectMapper();&lt;br /&gt;
JsonFactory  jsonFactory = new JsonFactory();&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Third step: Calling rest service:
&lt;br /&gt;
&lt;br /&gt;
Just call this method of rest template and the api will call the service and will encapsulate all the stream stuff and present you the response as a string file in this example.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;String url = &quot;yourjsonrestserviceurl&quot;);&lt;br /&gt;
String result = restTemplate.getForObject(url, String.class);&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Fourth Step: Creating json parser and marshalling the json result into an object
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;JsonParser jp = jsonFactory.createJsonParser(result);&lt;br /&gt;
MappingIterator&lt;yourbean[]&gt; list = objectMapper.readValues(jp, YourBean[].class);
&lt;/yourbean[]&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally Some recomendations:&lt;br /&gt;
You should get some errors depending of the format of your json. Here are some workarounds:&lt;br /&gt;
&lt;br /&gt;
to map a field with different names:&lt;br /&gt;
Add anotation @JsonProperty(&quot;yourJSONfield&quot;) to the POJO field you want to map.&lt;br /&gt;
To ignore a POJO field on marshalling process:
@JsonIgnore</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/7273955418457829944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/7273955418457829944' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7273955418457829944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7273955418457829944'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2012/07/calling-rest-service-with-spring-rest.html' title=''/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-5801264377968241381</id><published>2008-12-29T07:28:00.000-08:00</published><updated>2009-01-06T14:23:07.674-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="frameworks"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxcent"/><title type='text'>Jaxcent</title><content type='html'>Hace un tiempo, buscando frameworks para java , me tope con Jaxcent.&lt;br /&gt;Jaxcent es un framework gratis, para la programacion en ajax. Lo interesante de este framework es que no necesitas escribir codigo javascript, solo programas en java. Se que existen frameworks como el google toolkit y javafx que tienen esta capacidad, pero Jaxcent me parecio el mas rapido de configurar y utilizar.&lt;br /&gt;Dejo el enlace para que lo bajen y me brinden sus opiniones.&lt;br /&gt;&lt;br /&gt;www.jaxcent.com</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/5801264377968241381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/5801264377968241381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/5801264377968241381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/5801264377968241381'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2008/12/jaxcent.html' title='Jaxcent'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-6479568057499169808</id><published>2008-11-17T07:06:00.000-08:00</published><updated>2008-11-17T07:09:08.638-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="enum"/><title type='text'>Tipo Enum en java 5</title><content type='html'>Encontré un articulo interesante que habla de los tipos enum en java, y bueno aqui está:&lt;br /&gt;&lt;br /&gt;En Java 5 se permite que una variable tenga solo un valor dentro de un conjunto de valores predefinidos, en otras palabras, valores dentro de una lista enumerada. Los tipos enumerados sirven para restringir la selección de valores a algunos previamente definidos, p. ej., si tenemos una aplicación para la venta de café en vasos de diferentes tamaños pero no queremos que los tamaños sean diferentes a CHICO, MEDIANO y GRANDE, podemos crear un tipo enumerado para delimitar dicha selección:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;enum TamanoDeCafe{CHICO,MEDIANO,GRANDE};&lt;br /&gt;&lt;br /&gt;Posteriormente, al elegir un tamaño de café podemos hacerlo de la siguiente manera:&lt;br /&gt;&lt;br /&gt;TamanoDeCafe tdc = TamanoDeCafe.MEDIANO;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;No es necesario que las constantes dentro de los enums estén en mayúsculas pero en las convenciones de código de Sun se pide hacerlo de esta manera. Se debe tomar en cuenta que un tipo enumerado puede ser declarado dentro o fuera de una clase, pero NO dentro de un método. P. ej.:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;enum instrumentos{ &lt;br /&gt;GUITARRA, TROMPETA, BATERIA, BAJO&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;public class Enumerados {&lt;br /&gt;&lt;br /&gt;public Enumerados() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void main (String... args){&lt;br /&gt;instrumentos in = instrumentos.BATERIA; &lt;br /&gt;System.out.println(in);&lt;br /&gt;EnumDentroClase edc = new EnumDentroClase();&lt;br /&gt;edc.tamano = EnumDentroClase.TamanoDeCafe.CHICO;&lt;br /&gt;System.out.println(edc.tamano);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class EnumDentroClase{&lt;br /&gt;&lt;br /&gt;enum TamanoDeCafe {GRANDE,MEDIANO,CHICO};&lt;br /&gt;&lt;br /&gt;TamanoDeCafe tamano;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Nota: el punto y coma (;) al final de la declaración del tipo enumerado es opcional.&lt;br /&gt;&lt;br /&gt;Al ejecutar el código anterior, obtenemos:&lt;br /&gt;&lt;br /&gt;BATERIA&lt;br /&gt;CHICO&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Los tipos enumerados no son enteros o cadenas, cada uno es simplemente una instancia del tipo enumerado del que es declarado. Se puede pensar como una especie (no exactamente) de arreglo de variables estáticas finales. Además de constantes dentro de un tipo enumerado, existen algunas otras cosas que puede tener.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Declarar constructores, métodos y variables dentro de un tipo enumerado::&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Debido a que los tipos enumerados son como una clase de tipo especial en Java, hay muchas cosas que se pueden realizar dentro de un enum, además de declarar constantes, un tipo enumerado puede contener constructores, métodos y variables.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Tomando nuestro ejemplo del tamaño de café, podemos pensar en escenario donde además de saber el tamaño del café necesitemos la cantidad en onzas de cada tamaño, esto podemos hacerlo de la siguiente manera:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;enum TamanoCafe{&lt;br /&gt;&lt;br /&gt;CHICO(5), MEDIANO(8), GRANDE(10);&lt;br /&gt;&lt;br /&gt;private int onzas;&lt;br /&gt;&lt;br /&gt;TamanoCafe(int onzas){&lt;br /&gt;this.onzas = onzas;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public int getOnzas(){&lt;br /&gt;return this.onzas;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Cafe {&lt;br /&gt;TamanoCafe tc;&lt;br /&gt;public Cafe() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void main(String... args){&lt;br /&gt;Cafe c1 = new Cafe();&lt;br /&gt;Cafe c2 = new Cafe();&lt;br /&gt;c1.tc = TamanoCafe.GRANDE;&lt;br /&gt;c2.tc = TamanoCafe.CHICO;&lt;br /&gt;&lt;br /&gt;System.out.println(&quot;Tamaño de café 1(c1): &quot;+c1.tc);&lt;br /&gt;System.out.println(&quot;Tamaño de café 2(c2): &quot;+c2.tc);&lt;br /&gt;&lt;br /&gt;System.out.println(&quot;Onzas 1(c1): &quot;+c1.tc.getOnzas());&lt;br /&gt;System.out.println(&quot;Onzas 2(c2): &quot;+c2.tc.getOnzas());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Al ejecutar el código anterior obtendremos lo siguiente:&lt;br /&gt;&lt;br /&gt;Tamaño de café 1(c1): GRANDE&lt;br /&gt;Tamaño de café 2(c2): CHICO&lt;br /&gt;Onzas 1(c1): 10&lt;br /&gt;Onzas 2(c2): 5&lt;br /&gt;&lt;br /&gt;Algunos puntos importantes sobre los constructores de los tipos enumerados:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;+ No se puede invocar al constructor directamente, este se invoca una vez que se crea el tipo enumerado y es definido por los argumentos utilizados para crearlo.&lt;br /&gt;&lt;br /&gt;+ Se puede definir más de un argumento en un constructor de un tipo enumerado, asimismo, se puede definir más de un constructor para un tipo enumerado siempre y cuando este tenga argumentos diferentes(sobrecargar el constructor).</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/6479568057499169808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/6479568057499169808' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/6479568057499169808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/6479568057499169808'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2008/11/tipo-enum-en-java-5.html' title='Tipo Enum en java 5'/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618693586282052137.post-7677597178795166443</id><published>2008-11-14T09:14:00.001-08:00</published><updated>2012-07-11T09:59:24.858-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="equals in java"/><title type='text'>Diferencias del Metodo equals() y ==</title><content type='html'>Por ejemplo, el tipo de datos int, en Java, es un tipo de dato de los llamados primitivos (más o menos como c++), con lo cuál puedes utilizar los operadores lógicos y aritméticos de la forma habitual. En tu caso puedes utilizar el operador == de la manera normal. Sin embargo, Integer, no es un tipo de dato primitivo. Es una clase!!. Entoces cuando tú tienes un objeto del tipo Integer NO estás manejando su valor, sino un puntero a tu objeto Integer. Porque en Java todo son punteros (menos los tipos de datos primitivos). Así que cuando utilizas el operador == no estás comparando el valor de los integer, sino los punteros (las direcciones que apuntan al objeto). De modo que para objetos estás obligado a utilizar el método equals().</content><link rel='replies' type='application/atom+xml' href='http://pierosteffano.blogspot.com/feeds/7677597178795166443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4618693586282052137/7677597178795166443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7677597178795166443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618693586282052137/posts/default/7677597178795166443'/><link rel='alternate' type='text/html' href='http://pierosteffano.blogspot.com/2008/11/diferencias-del-metodo-equals-y_14.html' title='Diferencias del Metodo equals() y =='/><author><name>piero steffano del aguila macher</name><uri>http://www.blogger.com/profile/01130400604372605967</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>