Using utf8mb4 :)
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 19 Jan 2017 13:09:01 +0000 (14:09 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 19 Jan 2017 13:09:01 +0000 (14:09 +0100)
It is available since MySQL 5.5.3

http://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html

22 files changed:
MyBatis/MyBatis-Spring-ReuseBatchExecutor/README.txt
MyBatis/MyBatis-Spring-ReuseBatchExecutor/src/main/resources/liquibase/ddlChangelog.xml
MyBatis/MyBatis-Spring/README.txt
MyBatis/MyBatis-Spring/src/main/resources/liquibase/ddlChangelog.xml
MyBatis/MyBatis/createdatabase.sh
SpringJava/DeadLocksSQL/src/main/database/example.sql
SpringJava/Gradle/spring-jpa-bom/pom.xml [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/V1__Initial_Setup.sql
SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/liquibase/ddlChangelog.xml
SpringJava/Gradle/spring-jpa-services/build.gradle [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/pom.xml [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionRevisionService.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdService.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionRevisionServiceImpl.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdServiceImpl.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/RevisionServiceImpl.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudServiceImpl.java [new file with mode: 0644]
SpringJava/Gradle/spring-jpa-services/src/main/resources/spring-configuration/configuration.xml [new file with mode: 0644]

index 2272363..83356ce 100644 (file)
@@ -8,11 +8,11 @@ mvn dependency:resolve -Dclassifier=javadoc
 
 
 # I am using the mybatis-generator maven plugin. So, I need always a database (it would be better to use the Eclipse plugin)
-mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8"
+mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8mb4"
 
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
 
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id SERIAL, laguage_id BIGINT NOT NULL, ad_id BIGINT(20) UNSIGNED NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id SERIAL, laguage_id BIGINT NOT NULL, ad_id BIGINT(20) UNSIGNED NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
 
 # Run mvn clean install (mybatis-generator plugin creates autogenerated code from tables)
 mvn clean install
@@ -21,7 +21,7 @@ mvn clean install
 mysql -uroot -proot -A -e "drop database mybatis_example"
 
 # Liquibase requires (AFAIK) of an existing schema
-mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8"
+mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8mb4"
 
 # Run TestMain.java :)
 
index 8aef71d..9835794 100644 (file)
@@ -21,7 +21,7 @@
              it is inherited from schema to tables and rows) anyhow this is just an example of what you can do.
                -->
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1424631556445-2">
@@ -51,7 +51,7 @@
              it is inherited from schema to tables and rows) anyhow this is just an example of what you can do.
                -->
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1424631556445-3">
index 2272363..83356ce 100644 (file)
@@ -8,11 +8,11 @@ mvn dependency:resolve -Dclassifier=javadoc
 
 
 # I am using the mybatis-generator maven plugin. So, I need always a database (it would be better to use the Eclipse plugin)
-mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8"
+mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8mb4"
 
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
 
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id SERIAL, laguage_id BIGINT NOT NULL, ad_id BIGINT(20) UNSIGNED NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id SERIAL, laguage_id BIGINT NOT NULL, ad_id BIGINT(20) UNSIGNED NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
 
 # Run mvn clean install (mybatis-generator plugin creates autogenerated code from tables)
 mvn clean install
@@ -21,7 +21,7 @@ mvn clean install
 mysql -uroot -proot -A -e "drop database mybatis_example"
 
 # Liquibase requires (AFAIK) of an existing schema
-mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8"
+mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8mb4"
 
 # Run TestMain.java :)
 
index 8aef71d..9835794 100644 (file)
@@ -21,7 +21,7 @@
              it is inherited from schema to tables and rows) anyhow this is just an example of what you can do.
                -->
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1424631556445-2">
@@ -51,7 +51,7 @@
              it is inherited from schema to tables and rows) anyhow this is just an example of what you can do.
                -->
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1424631556445-3">
index ef2bb57..aad1310 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/bash
-mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8"
+mysql -uroot -proot -e "CREATE DATABASE mybatis_example DEFAULT CHARACTER SET utf8mb4"
 
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
 
 # Por alguna extraña razon no pude poner el id de esta tabla como serial y no tiene ahora este id autoincrement
 # Daba un error raro diciendo que no podia haber 2 claves con autoincrement en la misma tabla. Pero sí se puede...
 # debo estar haciendo algo mal... :(
-mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id BIGINT(20) UNSIGNED NOT NULL, laguage_id BIGINT NOT NULL, ad_id SERIAL NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci"
+mysql -uroot -proot -e "USE mybatis_example; CREATE TABLE ad_description (id BIGINT(20) UNSIGNED NOT NULL, laguage_id BIGINT NOT NULL, ad_id SERIAL NOT NULL, ad_name VARCHAR(255) NOT NULL, ad_description LONGTEXT, ad_mobile_text VARCHAR(500) NOT NULL, ad_link VARCHAR(3000) NOT NULL, PRIMARY KEY (id), INDEX(ad_id), FOREIGN KEY (ad_id) REFERENCES ad (id) ON DELETE CASCADE) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci"
index 498cfb6..07119db 100644 (file)
@@ -7,7 +7,7 @@
 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
 /*!40103 SET TIME_ZONE='+00:00' */;
 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
 
 DROP TABLE IF EXISTS `children`;
 /*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
+/*!40101 SET character_set_client = utf8mb4 */;
 CREATE TABLE `children` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-  `name` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
+  `name` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL,
   `parent_id` bigint(20) unsigned NOT NULL,
   PRIMARY KEY (`id`),
   KEY `parent_id` (`parent_id`),
   CONSTRAINT `children_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parents` (`id`) ON DELETE CASCADE
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -48,12 +48,12 @@ UNLOCK TABLES;
 
 DROP TABLE IF EXISTS `parents`;
 /*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
+/*!40101 SET character_set_client = utf8mb4 */;
 CREATE TABLE `parents` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-  `name` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
+  `name` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
diff --git a/SpringJava/Gradle/spring-jpa-bom/pom.xml b/SpringJava/Gradle/spring-jpa-bom/pom.xml
new file mode 100644 (file)
index 0000000..780b4d2
--- /dev/null
@@ -0,0 +1,654 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+       <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>de.spring.jpa</groupId>
+        <artifactId>spring-jpa</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+       <artifactId>spring-jpa-bom</artifactId>
+       <packaging>pom</packaging>
+       <name>SPRING JPA BOM</name>
+       <url>http://gumartinm.name</url>
+       <description>
+        Spring JPA BOM example.
+    </description>
+       <organization>
+               <name>Gustavo Martin Morcuende</name>
+               <url>https://www.gumartinm.name</url>
+       </organization>
+       <scm>
+               <developerConnection>scm:git:https://git.gumartinm.name/JavaForFun</developerConnection>
+               <url>https://git.gumartinm.name/JavaForFun</url>
+       </scm>
+
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <spring.version>4.3.0.RELEASE</spring.version>
+        <querydsl.version>4.1.3</querydsl.version>
+                 <maven.javadoc.version>2.10.4</maven.javadoc.version>
+                 <maven.source.version>3.0.1</maven.source.version>
+
+        <!-- Be careful these two paths must match the ones configured in SONARQUBE JaCoCo plugin -->
+        <jacoco.it.execution.data.file>${project.basedir}/target/jacoco-it.exec</jacoco.it.execution.data.file>
+        <jacoco.ut.execution.data.file>${project.basedir}/target/jacoco.exec</jacoco.ut.execution.data.file>
+
+        <skip.unit.tests>false</skip.unit.tests>
+        <skip.integration.tests>true</skip.integration.tests>
+       </properties>
+
+       <profiles>
+        <profile>
+            <id>development</id>
+            <properties>
+                <environment.profile>development</environment.profile>
+                <environment.name>Desarrollo local</environment.name>
+            </properties>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+        <profile>
+            <id>integration</id>
+            <properties>
+                <environment.profile>integration</environment.profile>
+                <environment.name>Integration</environment.name>
+                <skip.integration.tests>false</skip.integration.tests>
+            </properties>
+        </profile>
+               <profile>
+                       <id>production</id>
+                       <properties>
+                               <environment.profile>production</environment.profile>
+                <environment.name>Production</environment.name>
+                <skip.integration.tests>false</skip.integration.tests>
+                       </properties>
+               </profile>
+       </profiles>
+
+       <dependencies>
+               <!--
+                       1/3 Required dependency for log4j 2 with slf4j: binding between log4j 
+                       2 and slf4j
+               -->
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-slf4j-impl</artifactId>
+                       <version>2.6.1</version>
+               </dependency>
+               <!--
+                       2/3 Required dependency for log4j 2 with slf4j: log4j 2 maven plugin 
+                       (it is the log4j 2 implementation)
+               -->
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-core</artifactId>
+                       <version>2.6.1</version>
+               </dependency>
+               <!--
+                       3/3 Required dependency for getting rid of commons logging. This is 
+                       the BRIDGE (no binding) between Jakarta Commons Logging (used by Spring) 
+                       and whatever I am using for logging (in this case I am using log4j 2) See: 
+                       http://www.slf4j.org/legacy.html We need exclusions in every dependency using 
+                       Jakarta Commons Logging (see Spring dependencies below) 
+               -->
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>jcl-over-slf4j</artifactId>
+                       <version>1.7.21</version>
+               </dependency>
+               
+               
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-context</artifactId>
+                       <version>${spring.version}</version>
+                       <!--
+                               Required dependency for getting rid of commons logging and use my 
+                               own logging library (in my case I decided to use log4j 2 under slf4j)
+                       -->
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>commons-logging</groupId>
+                                       <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               
+               <dependency>
+                       <groupId>javax.inject</groupId>
+                       <artifactId>javax.inject</artifactId>
+                       <version>1</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>cglib</groupId>
+                       <artifactId>cglib</artifactId>
+                       <version>2.2.2</version>
+               </dependency>
+               
+               <!-- Unitary and integration tests -->
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <version>2.0.43-beta</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <dependencyManagement>
+               <dependencies>
+                       
+                       <!-- REST API -->
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-webmvc</artifactId>
+                               <version>${spring.version}</version>
+                               <exclusions>
+                                       <exclusion>
+                                               <groupId>commons-logging</groupId>
+                                               <artifactId>commons-logging</artifactId>
+                                       </exclusion>
+                               </exclusions>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-oxm</artifactId>
+                               <version>${spring.version}</version>
+                               <exclusions>
+                                       <exclusion>
+                                               <groupId>commons-logging</groupId>
+                                               <artifactId>commons-logging</artifactId>
+                                       </exclusion>
+                               </exclusions>
+                       </dependency>
+                       
+                       
+                       <!-- Required by spring-webmvc -->
+                       <dependency>
+                               <groupId>javax.servlet</groupId>
+                               <artifactId>javax.servlet-api</artifactId>
+                               <version>4.0.0-b01</version>
+                               <scope>provided</scope>
+                       </dependency>
+
+                       <!--
+                               Jackson JSON Processor, required by spring-webmvc. See messageConverters 
+                               in rest-config.xml
+                       -->
+                       <dependency>
+                               <groupId>com.fasterxml.jackson.core</groupId>
+                               <artifactId>jackson-databind</artifactId>
+                               <version>2.8.1</version>
+                       </dependency>
+
+
+               <!-- Required JPA dependencies with hibernate -->
+               <dependency>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-orm</artifactId>
+               <version>${spring.version}</version>
+               <exclusions>
+                               <exclusion>
+                                       <groupId>commons-logging</groupId>
+                                       <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               
+               <dependency>
+                       <groupId>org.springframework.data</groupId>
+                       <artifactId>spring-data-jpa</artifactId>
+                       <version>1.10.2.RELEASE</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-beans</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-jdbc</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-orm</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-core</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-aop</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.springframework</groupId>
+                                       <artifactId>spring-context</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>commons-logging</groupId>
+                                       <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.hibernate</groupId>
+                       <artifactId>hibernate-entitymanager</artifactId>
+                       <version>5.2.1.Final</version>
+               </dependency>
+
+               <!-- Auditory using Hibernate Envers -->
+               <dependency>
+                   <groupId>org.hibernate</groupId>
+                   <artifactId>hibernate-envers</artifactId>
+                   <version>5.2.1.Final</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.data</groupId>
+                       <artifactId>spring-data-envers</artifactId>
+                       <version>1.0.2.RELEASE</version>
+               </dependency>
+
+               <!--
+                       Jackson JSON Processor, required by spring-webmvc. See messageConverters
+                       in rest-config.xml
+               
+                       Non required dependency. It is already declared in jackson-datatype-jsr310
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>2.8.1</version>
+               </dependency>
+               -->
+               <!-- 
+                       Jackson dependency required for serializing and deserializing LocalDateTime,
+                       LocalDate, etc, etc objects.
+                -->
+               <dependency>
+               <groupId>com.fasterxml.jackson.datatype</groupId>
+               <artifactId>jackson-datatype-jsr310</artifactId>
+               <version>2.8.1</version>
+               </dependency>
+               <!-- 
+                       Jackson dependency required for serializing and deserializing org.joda.time.DateTime objects.
+                       See: org.springframework.data.history.Revision getRevisionDate
+                -->
+               <dependency>
+               <groupId>com.fasterxml.jackson.datatype</groupId>
+               <artifactId>jackson-datatype-joda</artifactId>
+               <version>2.8.1</version>
+               </dependency>
+
+
+                       <!--
+                               Required by spring-context for using JSR-303. See LocalValidatorFactoryBean 
+                               in rest-config.xml
+                       -->
+                       <dependency>
+                               <groupId>javax.validation</groupId>
+                               <artifactId>validation-api</artifactId>
+                               <version>1.1.0.Final</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.hibernate</groupId>
+                               <artifactId>hibernate-validator</artifactId>
+                               <version>5.2.4.Final</version>
+                       </dependency>
+
+
+                       <!-- Using Querydsl -->
+                       <dependency>
+                               <groupId>com.querydsl</groupId>
+                               <artifactId>querydsl-apt</artifactId>
+                               <version>${querydsl.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>com.querydsl</groupId>
+                               <artifactId>querydsl-jpa</artifactId>
+                               <version>${querydsl.version}</version>
+                       </dependency>
+
+                       <!-- Loading data base in run time -->
+                       <dependency>
+                               <groupId>org.liquibase</groupId>
+                               <artifactId>liquibase-core</artifactId>
+                               <version>3.5.1</version>
+                       </dependency>
+
+                       <!-- Unitary and integration tests -->
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-test</artifactId>
+                               <version>${spring.version}</version>
+                               <scope>test</scope>
+                               <!--
+                                       Required dependency for getting rid of commons logging and use my
+                                       own logging library (in my case I decided to use log4j 2 under slf4j)
+                               -->
+                               <exclusions>
+                                       <exclusion>
+                                               <groupId>commons-logging</groupId>
+                                               <artifactId>commons-logging</artifactId>
+                                       </exclusion>
+                               </exclusions>
+                       </dependency>
+                       <dependency>
+               <groupId>com.h2database</groupId>
+               <artifactId>h2</artifactId>
+               <version>1.4.192</version>
+               <scope>test</scope>
+               </dependency>
+               </dependencies>
+       </dependencyManagement>
+       <build>
+
+               <pluginManagement>
+                       <plugins>
+                               <!-- Using Querydsl -->
+                               <plugin>
+                                 <groupId>com.mysema.maven</groupId>
+                                 <artifactId>apt-maven-plugin</artifactId>
+                                 <version>1.0.4</version>
+                               </plugin>
+                               <!-- Required in order to work with m2e plugin for Eclipse  -->
+                       <plugin>
+                           <groupId>org.codehaus.mojo</groupId>
+                           <artifactId>build-helper-maven-plugin</artifactId>
+                           <version>1.11</version>
+                       </plugin>
+              <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-site-plugin</artifactId>
+                  <version>3.5.1</version>
+                  <dependencies>
+                      <dependency><!-- add support for ssh/scp -->
+                          <groupId>org.apache.maven.wagon</groupId>
+                          <artifactId>wagon-ssh</artifactId>
+                          <version>2.10</version>
+                      </dependency>
+                  </dependencies>
+              </plugin>
+                       </plugins>
+               </pluginManagement>
+
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.3</version>
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-resources-plugin</artifactId>
+                               <version>2.7</version>
+                               <configuration>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+            <plugin>
+                <artifactId>maven-site-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-descriptor</id>
+                        <goals>
+                            <goal>attach-descriptor</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <version>2.6</version>
+                               <configuration>
+                                       <archive>
+                                               <manifestEntries>
+                                                       <Specification-Title>${project.description}</Specification-Title>
+                                                       <Specification-Version>${project.version}</Specification-Version>
+                                                       <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+                                                       <Implementation-Title>${project.description}</Implementation-Title>
+                                                       <Implementation-Version>${project.version}</Implementation-Version>
+                                                       <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+                                               </manifestEntries>
+                                       </archive>
+                               </configuration>
+                       </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>${maven.javadoc.version}</version>
+                <configuration>
+                    <quiet>true</quiet>
+                    <docencoding>${project.build.sourceEncoding}</docencoding>
+                    <charset>${project.build.sourceEncoding}</charset>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                    <additionalparam>-Xdoclint:none</additionalparam>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>${maven.source.version}</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.7.7.201606060606</version>
+                <executions>
+                    <!-- Prepares the property pointing to the JaCoCo runtime agent which 
+                        is passed as VM argument when Maven the Surefire plugin is executed. -->
+                    <execution>
+                        <id>pre-unit-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            <!-- Sets the path to the file which contains the execution data. -->
+                            <destFile>${jacoco.ut.execution.data.file}</destFile>
+                            <!-- Sets the name of the property containing the settings for JaCoCo 
+                                runtime agent. -->
+                            <propertyName>surefireArgLine</propertyName>
+                        </configuration>
+                    </execution>
+                    <!-- Ensures that the code coverage report for unit tests is created 
+                        after unit tests have been run. -->
+                    <execution>
+                        <id>post-unit-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                        <configuration>
+                            <!-- Sets the path to the file which contains the execution data. -->
+                            <dataFile>${jacoco.ut.execution.data.file}</dataFile>
+                            <!-- Sets the output directory for the code coverage report. -->
+                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+                        </configuration>
+                    </execution>
+                    <!-- Prepares the property pointing to the JaCoCo runtime agent which 
+                        is passed as VM argument when Maven the Failsafe plugin is executed. -->
+                    <execution>
+                        <id>pre-integration-test</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            <!-- Sets the path to the file which contains the execution data. -->
+                            <destFile>${jacoco.it.execution.data.file}</destFile>
+                            <!-- Sets the name of the property containing the settings for JaCoCo 
+                                runtime agent. -->
+                            <propertyName>failsafeArgLine</propertyName>
+                        </configuration>
+                    </execution>
+                    <!-- Ensures that the code coverage report for integration tests after 
+                        integration tests have been run. -->
+                    <execution>
+                        <id>post-integration-test</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                        <configuration>
+                            <!-- Sets the path to the file which contains the execution data. -->
+                            <dataFile>${jacoco.it.execution.data.file}</dataFile>
+                            <!-- Sets the output directory for the code coverage report. -->
+                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.eclipse.m2e</groupId>
+                <artifactId>lifecycle-mapping</artifactId>
+                <version>1.0.0</version>
+                <configuration>
+                    <lifecycleMappingMetadata>
+                        <pluginExecutions>
+                            <pluginExecution>
+                                <pluginExecutionFilter>
+                                    <groupId>org.jacoco</groupId>
+                                    <artifactId>jacoco-maven-plugin</artifactId>
+                                    <versionRange>[0.5,)
+                                    </versionRange>
+                                    <goals>
+                                        <goal>prepare-agent</goal>
+                                    </goals>
+                                </pluginExecutionFilter>
+                                <action>
+                                    <!-- m2e doesn't know what to do with jacoco, let's ignore it or 
+                                        annoying error markers appear see http://wiki.eclipse.org/M2E_plugin_execution_not_covered -->
+                                    <ignore />
+                                </action>
+                            </pluginExecution>
+                        </pluginExecutions>
+                    </lifecycleMappingMetadata>
+                </configuration>
+            </plugin>
+
+            <!-- Used for unit tests -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.19.1</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-junit47</artifactId>
+                        <version>2.19.1</version>
+                    </dependency>
+                </dependencies>
+                <configuration>
+                    <!-- Sets the VM argument line used when unit tests are run. -->
+                    <argLine>-Dfile.encoding=${project.build.sourceEncoding}
+                        ${surefireArgLine}</argLine>
+                    <!-- Skips unit tests if the value of skip.unit.tests property is true -->
+                    <skipTests>${skip.unit.tests}</skipTests>
+                    <!-- Excludes integration tests when unit tests are run. -->
+                    <excludes>
+                        <exclude>**/*IT.java</exclude>
+                        <exclude>**/*IntegrationTest.java</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+
+            <!-- Used for integration tests -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-failsafe-plugin</artifactId>
+                <version>2.19.1</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>integration-test</goal>
+                                                       <goal>verify</goal>
+                                               </goals>
+                        <configuration>
+                            <!-- Sets the VM argument line used when integration tests are run. -->
+                            <argLine>${failsafeArgLine}</argLine>
+
+                            <!-- Skips integration tests if the value of skip.integration.tests 
+                                property is true -->
+                            <skipTests>${skip.integration.tests}</skipTests>
+                            <includes>
+                                <include>**/*IT.java</include>
+                                <include>**/*IntegrationTest.java</include>
+                            </includes>
+                        </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+                <version>2.9</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>${maven.javadoc.version}</version>
+                <reportSets>
+                    <reportSet>
+                        <id>html</id>
+                        <configuration>
+
+                            <doctitle>API for ${project.name} ${project.version}</doctitle>
+                            <windowtitle>API for ${project.name} ${project.version}</windowtitle>
+                        </configuration>
+                        <reports>
+                            <report>javadoc</report>
+                            <report>aggregate</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-report-plugin</artifactId>
+                <version>2.19.1</version>
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>report-only</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jxr-plugin</artifactId>
+                <version>2.5</version>
+            </plugin>
+        </plugins>
+    </reporting>
+
+</project>
index 97d1948..712c05a 100644 (file)
@@ -20,9 +20,9 @@ CREATE TABLE AD (
        AD_GPS BLOB,
        AD_MOBILE_IMAGE VARCHAR(255),
        CREATED_AT TIMESTAMP DEFAULT NOW() NOT NULL,
-       UPDATED_AT TIMESTAMP DEFAULT '1970-01-01 00:00:01' NOT NULL,
+       UPDATED_AT TIMESTAMP DEFAULT '1971-01-01 00:00:01' NOT NULL,
        CONSTRAINT PK_AD PRIMARY KEY (ID)
-       );
+       ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE AD_AUDITED (
@@ -41,7 +41,7 @@ CREATE TABLE AD_AUDITED (
        createdAt_MODIFIED BOOLEAN(1),
        UPDATED_AT TIMESTAMP,
        updatedAt_MODIFIED BOOLEAN(1),
-       adDescriptions_MODIFIED BOOLEAN(1));
+       adDescriptions_MODIFIED BOOLEAN(1)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE AD_DESCRIPTION (
@@ -53,7 +53,7 @@ CREATE TABLE AD_DESCRIPTION (
        AD_MOBILE_TEXT VARCHAR(500) NOT NULL,
        AD_LINK VARCHAR(3000) NOT NULL,
        CONSTRAINT PK_AD_DESCRIPTION PRIMARY KEY (ID)
-       );
+       ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 
@@ -69,7 +69,7 @@ CREATE TABLE AD_DESCRIPTION_AUDITED (
        AD_NAME VARCHAR(255),
        LANGUAGE_ID BIGINT,
        AD_ID BIGINT
-       );
+       ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 
@@ -78,7 +78,7 @@ CREATE TABLE CUSTOM_REVISION (
        REVISION_DATE TIMESTAMP NOT NULL,
        USERNAME VARCHAR(255),
        CONSTRAINT PK_CUSTOM_REVISION PRIMARY KEY (ID)
-       );
+       ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
        
@@ -94,33 +94,33 @@ CREATE TABLE AD (
   COMPANY_ID bigint(20) DEFAULT NULL,
   COMPANY_CATEG_ID bigint(20) DEFAULT NULL,
   AD_GPS blob,
-  AD_MOBILE_IMAGE varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+  AD_MOBILE_IMAGE varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   CREATED_AT timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  UPDATED_AT timestamp NOT NULL DEFAULT '1970-01-01 00:00:01',
+  UPDATED_AT timestamp NOT NULL DEFAULT '1971-01-01 00:00:01',
   PRIMARY KEY (ID)
-);
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE AD_DESCRIPTION (
   ID bigint(20) NOT NULL AUTO_INCREMENT,
   LANGUAGE_ID bigint(20) NOT NULL,
   AD_ID bigint(20) DEFAULT NULL,
-  AD_NAME varchar(255) COLLATE utf8_unicode_ci NOT NULL,
-  AD_DESCRIPTION longtext COLLATE utf8_unicode_ci,
-  AD_MOBILE_TEXT varchar(500) COLLATE utf8_unicode_ci NOT NULL,
-  AD_LINK varchar(3000) COLLATE utf8_unicode_ci NOT NULL,
+  AD_NAME varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
+  AD_DESCRIPTION longtext COLLATE utf8mb4_unicode_ci,
+  AD_MOBILE_TEXT varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL,
+  AD_LINK varchar(3000) COLLATE utf8mb4_unicode_ci NOT NULL,
   PRIMARY KEY (ID),
   KEY IND_01_AD_DESCRIPTION (AD_ID),
   CONSTRAINT FK_01_AD_DESCRIPTION FOREIGN KEY (AD_ID) REFERENCES AD (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE CUSTOM_REVISION (
   ID bigint(20) NOT NULL AUTO_INCREMENT,
   REVISION_DATE timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  USERNAME varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+  USERNAME varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   PRIMARY KEY (ID)
-);
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE AD_AUDITED (
@@ -129,7 +129,7 @@ CREATE TABLE AD_AUDITED (
   REVISION_TYPE tinyint(3) DEFAULT NULL,
   REVISION_END bigint(20) DEFAULT NULL,
   REVISION_END_TIMESTAMP datetime DEFAULT NULL,
-  AD_MOBILE_IMAGE varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+  AD_MOBILE_IMAGE varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   adMobileImage_MODIFIED bit(1) DEFAULT NULL,
   COMPANY_CATEG_ID bigint(20) DEFAULT NULL,
   companyCategId_MODIFIED bit(1) DEFAULT NULL,
@@ -145,7 +145,7 @@ CREATE TABLE AD_AUDITED (
   KEY IND_02_AD_AUDITED (REVISION_END),
   CONSTRAINT FK_01_AD_AUDITED FOREIGN KEY (REVISION) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
   CONSTRAINT FK_02_AD_AUDITED FOREIGN KEY (REVISION_END) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
 -- CREATE TABLE "MYBATIS_EXAMPLE"."AD_AUDITED" ("ID" BIGINT NOT NULL, "REVISION" BIGINT NOT NULL, "REVISION_TYPE" TINYINT(3), "REVISION_END" BIGINT, "REVISION_END_TIMESTAMP" TIMESTAMP, "AD_MOBILE_IMAGE" VARCHAR(255), "adMobileImage_MODIFIED" BOOLEAN(1), "COMPANY_CATEG_ID" BIGINT, "companyCategId_MODIFIED" BOOLEAN(1), "COMPANY_ID" BIGINT, "companyId_MODIFIED" BOOLEAN(1), "CREATED_AT" TIMESTAMP, "createdAt_MODIFIED" BOOLEAN(1), "UPDATED_AT" TIMESTAMP, "updatedAt_MODIFIED" BOOLEAN(1), "adDescriptions_MODIFIED" BOOLEAN(1))
@@ -159,10 +159,10 @@ CREATE TABLE AD_DESCRIPTION_AUDITED (
   REVISION_TYPE tinyint(3) DEFAULT NULL,
   REVISION_END bigint(20) DEFAULT NULL,
   REVISION_END_TIMESTAMP datetime DEFAULT NULL,
-  AD_DESCRIPTION varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
-  AD_LINK varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
-  AD_MOBILE_TEXT varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
-  AD_NAME varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+  AD_DESCRIPTION varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+  AD_LINK varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+  AD_MOBILE_TEXT varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+  AD_NAME varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   LANGUAGE_ID bigint(20) DEFAULT NULL,
   AD_ID bigint(20) DEFAULT NULL,
   PRIMARY KEY (ID,REVISION),
@@ -170,7 +170,7 @@ CREATE TABLE AD_DESCRIPTION_AUDITED (
   KEY IND_02_AD_DESCRIPTION_AUDITED (REVISION_END),
   CONSTRAINT FK_01_AD_DESCRIPTION_AUDITED FOREIGN KEY (REVISION) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
   CONSTRAINT FK_02_AD_DESCRIPTION_AUDITED FOREIGN KEY (REVISION_END) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 
index 5c53eb9..dc82bf1 100644 (file)
@@ -6,19 +6,19 @@
 
     <changeSet author="gustavo test" id="1" labels="VERSIONA">
         <sql>
-            CREATE TABLE VERSIONA (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci
+            CREATE TABLE VERSIONA (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci
         </sql>
     </changeSet>
 
     <changeSet author="gustavo test" id="2" labels="VERSIONB">
         <sql>
-            CREATE TABLE VERSIONB (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci
+            CREATE TABLE VERSIONB (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci
         </sql>
     </changeSet>
 
     <changeSet author="gustavo test" id="3" labels="VERSIONC">
         <sql>
-            CREATE TABLE VERSIONC (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8, COLLATE=utf8_unicode_ci
+            CREATE TABLE VERSIONC (id SERIAL, company_id BIGINT, company_categ_id BIGINT, ad_gps BLOB, ad_mobile_image varchar(255), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=utf8mb4_unicode_ci
         </sql>
     </changeSet>
     -->
@@ -40,7 +40,7 @@
             </column>
         </createTable>
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1469119656864-2" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
@@ -67,7 +67,7 @@
             <column name="adDescriptions_MODIFIED" type="BIT(1)"/>
         </createTable>
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1469119656864-3" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
@@ -91,7 +91,7 @@
             </column>
         </createTable>
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1469119656864-4" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
             <column name="AD_ID" type="BIGINT"/>
         </createTable>
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1469119656864-5" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
             <column name="USERNAME" type="VARCHAR(255)"/>
         </createTable>
         <modifySql dbms="mysql">
-            <append value="ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci"/>
+            <append value="ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci"/>
         </modifySql>
     </changeSet>
     <changeSet author="gustavo (generated)" id="1469119656864-6" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
diff --git a/SpringJava/Gradle/spring-jpa-services/build.gradle b/SpringJava/Gradle/spring-jpa-services/build.gradle
new file mode 100644 (file)
index 0000000..ab4ecf8
--- /dev/null
@@ -0,0 +1,9 @@
+dependencies {
+
+    compile(project(":spring-jpa-persistence"))
+    
+    testCompile('org.springframework:spring-test:4.3.0.RELEASE') {
+        exclude group: 'commons-logging', module: 'commons-logging'
+    }
+
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/pom.xml b/SpringJava/Gradle/spring-jpa-services/pom.xml
new file mode 100644 (file)
index 0000000..06bbfaa
--- /dev/null
@@ -0,0 +1,31 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>de.spring.jpa</groupId>
+        <artifactId>spring-jpa-bom</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>spring-jpa-services</artifactId>
+    <name>SPRING JPA SERVICES</name>
+       <url>https://gumartinm.name/</url>
+       <description>JPA Spring Framework. Services.</description>
+
+
+       <dependencies>
+               <dependency>
+                               <groupId>de.spring.jpa</groupId>
+                               <artifactId>spring-jpa-persistence</artifactId>
+                               <version>1.0-SNAPSHOT</version>
+               </dependency>
+       
+               <!-- Unitary and integration tests -->
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-test</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionRevisionService.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionRevisionService.java
new file mode 100644 (file)
index 0000000..498068c
--- /dev/null
@@ -0,0 +1,8 @@
+package de.spring.example.services;
+
+import de.spring.example.persistence.domain.AdDescription;
+
+public interface AdDescriptionRevisionService
+       extends RevisionService<AdDescription, Long, Integer> {
+       
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java
new file mode 100644 (file)
index 0000000..0a3dc1e
--- /dev/null
@@ -0,0 +1,22 @@
+package de.spring.example.services;
+
+import org.resthub.common.service.CrudService;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.history.Revision;
+
+import de.spring.example.persistence.domain.AdDescription;
+
+public interface AdDescriptionService extends CrudService<AdDescription, Long> {
+
+       public Page<AdDescription> queryDslExample(Pageable pageRequest);
+       
+       /**
+        * Returns a {@link Page} of revisions for the entity with the given id.
+        * 
+        * @param id must not be {@literal null}.
+        * @param pageable page request.
+        * @return a new {@link Page} with the content of the current one mapped by the given {@link Pageable}.
+        */
+       Page<Revision<Integer, AdDescription>> findRevisions(Long id, Pageable pageable);
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdService.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/AdService.java
new file mode 100644 (file)
index 0000000..c491be8
--- /dev/null
@@ -0,0 +1,12 @@
+package de.spring.example.services;
+
+import org.resthub.common.service.CrudService;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import de.spring.example.persistence.domain.Ad;
+
+public interface AdService extends CrudService<Ad, Long> {
+       
+       public Page<Ad> queryCriteriaExample(Pageable pageRequest);
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java
new file mode 100644 (file)
index 0000000..4e184fc
--- /dev/null
@@ -0,0 +1,19 @@
+package de.spring.example.services;
+
+import java.io.Serializable;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.history.Revision;
+
+public interface RevisionService<T, ID extends Serializable, N extends Number & Comparable<N>> {
+
+       /**
+        * Returns a {@link Page} of revisions for the entity with the given id.
+        * 
+        * @param id must not be {@literal null}.
+        * @param pageable page request.
+        * @return a new {@link Page} with the content of the current one mapped by the given {@link Pageable}.
+        */
+       Page<Revision<N, T>> findRevisions(ID id, Pageable pageable);
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionRevisionServiceImpl.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionRevisionServiceImpl.java
new file mode 100644 (file)
index 0000000..8aec9e3
--- /dev/null
@@ -0,0 +1,20 @@
+package de.spring.example.services.impl;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import de.spring.example.persistence.domain.AdDescription;
+import de.spring.example.persistence.repository.AdDescriptionRepository;
+import de.spring.example.services.AdDescriptionRevisionService;
+
+@Named("adDescriptionRevisionService")
+public class AdDescriptionRevisionServiceImpl
+       extends RevisionServiceImpl<AdDescription, Long, Integer, AdDescriptionRepository>
+       implements AdDescriptionRevisionService {
+
+       @Override
+       @Inject
+    public void setRepository(AdDescriptionRepository repository) {
+        this.repository = repository;
+    }
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java
new file mode 100644 (file)
index 0000000..39c1bcc
--- /dev/null
@@ -0,0 +1,60 @@
+package de.spring.example.services.impl;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.resthub.common.service.CrudServiceImpl;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.history.Revision;
+
+import com.querydsl.core.types.dsl.BooleanExpression;
+
+import de.spring.example.persistence.domain.AdDescription;
+import de.spring.example.persistence.domain.QAdDescription;
+import de.spring.example.persistence.repository.AdDescriptionRepository;
+import de.spring.example.services.AdDescriptionService;
+
+@Named("adDescriptionService")
+public class AdDescriptionServiceImpl
+       extends CrudServiceImpl<AdDescription, Long, AdDescriptionRepository>
+       implements AdDescriptionService {
+
+       @Override
+       @Inject
+    public void setRepository(AdDescriptionRepository repository) {
+        this.repository = repository;
+    }
+
+       // Extending CrudServiceImpl when we need some business logic. Otherwise we would be using
+       // the JPA repositories and nothing else :)
+       
+       // In this case there is any business logic, but this is just an example.
+       
+       
+       /**
+        * Using Querydsl. Giving some business logic to this service :)
+        * 
+        * Querydsl: fluent interface done easy. There is no effort because it is already implemented.
+        * 
+        * Criteria using Specifications requires some effort.
+        * 
+        * See: de.spring.example.services.impl.AdServiceImpl
+        */
+       @Override
+       public Page<AdDescription> queryDslExample(Pageable pageRequest) {
+               final QAdDescription adDescription = QAdDescription.adDescription1;
+               final BooleanExpression adDescriptionHasAdLink = adDescription.adLink.contains("gumartinm");
+               final BooleanExpression adDescriptionHasDescription = adDescription.adDescription.contains("babucha");
+               /**
+                * https://github.com/spring-projects/spring-data-envers/pull/45
+                * return repository.findAll(adDescriptionHasAdLink.and(adDescriptionHasDescription), pageRequest);
+                */
+               return null;
+       }
+
+       @Override
+       public Page<Revision<Integer, AdDescription>> findRevisions(Long id, Pageable pageable) {
+               return this.repository.findRevisions(id, pageable);
+       }
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdServiceImpl.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdServiceImpl.java
new file mode 100644 (file)
index 0000000..05c416e
--- /dev/null
@@ -0,0 +1,43 @@
+package de.spring.example.services.impl;
+
+import static org.springframework.data.jpa.domain.Specifications.where;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.resthub.common.service.CrudServiceImpl;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import de.spring.example.persistence.domain.Ad;
+import de.spring.example.persistence.domain.specifications.AdSpectifications;
+import de.spring.example.persistence.repository.AdRepository;
+import de.spring.example.services.AdService;
+
+@Named("adService")
+public class AdServiceImpl
+       extends CrudServiceImpl<Ad, Long, AdRepository>
+       implements AdService {
+       
+       @Override
+       @Inject
+    public void setRepository(AdRepository repository) {
+        this.repository = repository;
+    }
+
+       /**
+        * Criteria using Specifications.
+        * 
+        * It is more complicated than when using Querydsl because I have to implement the
+        * Specifications. Querydsl is doing everything for me.
+        * 
+        * See: de.spring.example.services.impl.AdDescriptionServiceImpl
+        */
+       @Override
+       public Page<Ad> queryCriteriaExample(Pageable pageRequest) {
+               return repository.findAll(
+                               where(AdSpectifications.createdToday()).and(AdSpectifications.mobileImage("picasso")),
+                               pageRequest);           
+       }
+
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/RevisionServiceImpl.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/de/spring/example/services/impl/RevisionServiceImpl.java
new file mode 100644 (file)
index 0000000..6e587c3
--- /dev/null
@@ -0,0 +1,38 @@
+package de.spring.example.services.impl;
+
+import java.io.Serializable;
+
+import javax.inject.Named;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.history.Revision;
+import org.springframework.data.repository.history.RevisionRepository;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+
+import de.spring.example.services.RevisionService;
+
+@Named("revisionService")
+public class RevisionServiceImpl<T, ID extends Serializable, N extends Number & Comparable<N>, R extends RevisionRepository<T, ID, N>>
+       implements RevisionService<T, ID, N> {
+
+    protected R repository;
+
+    /**
+     * @param repository the repository to set
+     */
+    public void setRepository(R repository) {
+        this.repository = repository;
+    }
+    
+       @Override
+       @Transactional
+       public Page<Revision<N, T>> findRevisions(ID id, Pageable pageable) {
+               Assert.notNull(pageable, "page request can't be null");
+               Assert.notNull(id, "Resource ID can't be null");
+               
+               return this.repository.findRevisions(id, pageable);
+       }
+
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java
new file mode 100644 (file)
index 0000000..7f482e6
--- /dev/null
@@ -0,0 +1,94 @@
+package org.resthub.common.service;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * CRUD Service interface.
+ *
+ * @param <T>  Your resource POJO to manage, maybe an entity or DTO class
+ * @param <ID> Resource id type, usually Long or String
+ */
+public interface CrudService<T, ID extends Serializable> {
+
+    /**
+     * Create new resource.
+     *
+     * @param resource Resource to create
+     * @return new resource
+     */
+    T create(T resource);
+
+    /**
+     * Update existing resource.
+     *
+     * @param resource Resource to update
+     * @return resource updated
+     */
+    T update(T resource);
+
+    /**
+     * Delete existing resource.
+     *
+     * @param resource Resource to delete
+     */
+    void delete(T resource);
+
+    /**
+     * Delete existing resource.
+     *
+     * @param id Resource id
+     */
+    void delete(ID id);
+
+    /**
+     * Delete all existing resource. Do not use cascade remove (not a choice -&gt; JPA specs)
+     */
+    void deleteAll();
+
+    /**
+     * Delete all existing resource, including linked entities with cascade delete
+     */
+    void deleteAllWithCascade();
+
+    /**
+     * Find resource by id.
+     *
+     * @param id Resource id
+     * @return resource
+     */
+    T findById(ID id);
+
+    /**
+     * Find resources by their ids.
+     *
+     * @param ids Resource ids
+     * @return a list of retrieved resources, empty if no resource found
+     */
+    Iterable<T> findByIds(Set<ID> ids);
+
+    /**
+     * Find all resources.
+     *
+     * @return a list of all resources.
+     */
+    Iterable<T> findAll();
+
+    /**
+     * Find all resources (pageable).
+     *
+     * @param pageRequest page request.
+        * @return a new {@link Page} with the content of the current one mapped by the given {@link Pageable}.
+     */
+    Page<T> findAll(Pageable pageRequest);
+
+    /**
+     * Count all resources.
+     *
+     * @return number of resources
+     */
+    Long count();
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudServiceImpl.java b/SpringJava/Gradle/spring-jpa-services/src/main/java/org/resthub/common/service/CrudServiceImpl.java
new file mode 100644 (file)
index 0000000..b623bf3
--- /dev/null
@@ -0,0 +1,138 @@
+package org.resthub.common.service;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * CRUD service that uses a {@link org.springframework.data.repository.PagingAndSortingRepository} Spring Data repository implementation
+ *
+ * You should extend it and inject your Repository bean by overriding {@link #setRepository(org.springframework.data.repository.PagingAndSortingRepository)}
+ *
+ * @param <T> Your resource class to manage, usually an entity class
+ * @param <ID> Resource id type, usually Long or String
+ * @param <R> The repository class
+ */
+@Transactional(readOnly = true)
+public class CrudServiceImpl<T, ID extends Serializable, R extends PagingAndSortingRepository<T, ID>> implements
+        CrudService<T, ID> {
+
+    protected R repository;
+
+    /**
+     * @param repository the repository to set
+     */
+    public void setRepository(R repository) {
+        this.repository = repository;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public T create(T resource) {
+        Assert.notNull(resource, "Resource can't be null");
+        return repository.save(resource);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public T update(T resource) {
+        Assert.notNull(resource, "Resource can't be null");
+        return repository.save(resource);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public void delete(T resource) {
+        Assert.notNull(resource, "Resource can't be null");
+        repository.delete(resource);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public void delete(ID id) {
+        Assert.notNull(id, "Resource ID can't be null");
+        repository.delete(id);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public void deleteAll() {
+        repository.deleteAll();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public void deleteAllWithCascade() {
+        Iterable<T> list = repository.findAll();
+        for (T entity : list) {
+            repository.delete(entity);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public T findById(ID id) {
+        Assert.notNull(id, "Resource ID can't be null");
+        return repository.findOne(id);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Iterable<T> findByIds(Set<ID> ids) {
+        Assert.notNull(ids, "Resource ids can't be null");
+        return repository.findAll(ids);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Iterable<T> findAll() {
+        return repository.findAll();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional
+    public Page<T> findAll(Pageable pageRequest) {
+        Assert.notNull(pageRequest, "page request can't be null");
+        return repository.findAll(pageRequest);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Long count() {
+        return repository.count();
+    }
+}
diff --git a/SpringJava/Gradle/spring-jpa-services/src/main/resources/spring-configuration/configuration.xml b/SpringJava/Gradle/spring-jpa-services/src/main/resources/spring-configuration/configuration.xml
new file mode 100644 (file)
index 0000000..82009fb
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+               http://www.springframework.org/schema/beans
+               http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context.xsd">
+       
+       <context:annotation-config />
+       
+       <context:component-scan base-package="de.spring.example.services, org.resthub.common.service"/>
+       
+</beans>
\ No newline at end of file