You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/17 10:02:26 UTC

[incubator-servicecomb-saga] branch SCB-249_apl_compliance created (now 2ff73d1)

This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a change to branch SCB-249_apl_compliance
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git.


      at 2ff73d1  SCB-249 replaced mysql with postgres to comply with APL2 in original saga

This branch includes the following new commits:

     new a6aab6b  SCB-249 replaced hibernate with eclipselink to comply with APL2
     new a70fe34  SCB-249 replaced mysql with postgres to comply with APL2
     new 2ff73d1  SCB-249 replaced mysql with postgres to comply with APL2 in original saga

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].

[incubator-servicecomb-saga] 03/03: SCB-249 replaced mysql with postgres to comply with APL2 in original saga

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch SCB-249_apl_compliance
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 2ff73d17d49df769dd7c91ee6eadcf05c2a58261
Author: seanyinx <se...@huawei.com>
AuthorDate: Wed Jan 17 17:57:44 2018 +0800

    SCB-249 replaced mysql with postgres to comply with APL2 in original saga
    
    Signed-off-by: seanyinx <se...@huawei.com>
---
 README.md                                          |  4 +-
 alpha/alpha-server/pom.xml                         | 14 +----
 docker-compose.yaml                                | 21 ++++---
 integration-tests/pack-tests/pom.xml               | 20 +++----
 .../pack/tests/EclipseLinkJpaConfiguration.java    | 52 ----------------
 .../pack/tests/GreetingApplication.java            |  2 +
 omega/omega-spring-tx/pom.xml                      |  4 +-
 .../saga/omega/transaction/spring/User.java        |  5 +-
 .../omega-spring-tx/src/test/resources/schema.sql  |  6 ++
 pom.xml                                            |  6 ++
 .../conditional-transaction-demo-tests/pom.xml     | 21 ++++---
 .../docker-compose.yaml                            | 21 ++++---
 .../demo-tests/pom.xml                             | 21 ++++---
 .../docker-compose.yaml                            | 21 ++++---
 saga-persistence/pom.xml                           | 36 +++++++++++
 saga-persistence/saga-persistence-jpa/pom.xml      | 69 ++++++++++++++++++++++
 .../jpa}/EclipseLinkJpaConfiguration.java          |  4 +-
 .../src/main/resources/META-INF/spring.factories   | 23 +-------
 saga-spring/pom.xml                                | 13 ++--
 .../servicecomb/saga/spring/SagaEventEntity.java   |  5 +-
 .../servicecomb/saga/spring/SagaEventRepo.java     |  6 +-
 saga-spring/src/main/resources/application.yaml    | 13 +---
 saga-spring/src/main/resources/schema-mysql.sql    |  9 ---
 .../src/main/resources/schema-postgresql.sql       |  9 +++
 saga-spring/src/test/resources/data.sql            | 12 ++--
 25 files changed, 222 insertions(+), 195 deletions(-)

diff --git a/README.md b/README.md
index 1b2c4f3..9a7249f 100755
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ You will need:
 1. [Oracle JDK 1.8+][jdk]
 2. [Maven 3.x][maven]
 3. [Docker][docker]
-4. [MySQL][mysql]
+4. [PostgreSQL][postgres]
 5. [Service Center(optional)][service_center]
 6. [Docker compose(optional)][docker_compose]
 7. [Docker machine(optional)][docker_machine]
@@ -29,7 +29,7 @@ You will need:
 [jdk]: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
 [maven]: https://maven.apache.org/install.html
 [docker]: https://www.docker.com/get-docker
-[mysql]: https://dev.mysql.com/downloads/
+[postgres]: https://www.postgresql.org/download/
 [service_center]: https://github.com/apache/incubator-servicecomb-service-center
 [docker_compose]: https://docs.docker.com/compose/install/
 [docker_machine]: https://docs.docker.com/machine/install-machine/
diff --git a/alpha/alpha-server/pom.xml b/alpha/alpha-server/pom.xml
index 856d86c..ae894b8 100644
--- a/alpha/alpha-server/pom.xml
+++ b/alpha/alpha-server/pom.xml
@@ -67,18 +67,8 @@
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-data-jpa</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.hibernate</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.persistence</groupId>
-      <artifactId>org.eclipse.persistence.jpa</artifactId>
+      <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>saga-persistence-jpa</artifactId>
     </dependency>
     <dependency>
       <groupId>org.postgresql</groupId>
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 8d3037b..1afc3fb 100755
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -24,18 +24,17 @@ services:
       ports:
         - "30100:30100"
 
-  mysql:
-    image: "mysql/mysql-server:5.7"
-    hostname: mysql
+  postgres:
+    image: "postgres"
+    hostname: postgres
     environment:
-      - MYSQL_ROOT_PASSWORD=password
-      - MYSQL_DATABASE=saga
-      - MYSQL_USER=saga
-      - MYSQL_PASSWORD=password
+      - POSTGRES_DB=saga
+      - POSTGRES_USER=saga
+      - POSTGRES_PASSWORD=password
     ports:
-      - "3306:3306"
+      - "5432:5432"
     healthcheck:
-        test: ["CMD-SHELL", "nc -z localhost 3306 &> /dev/null; echo $$?"]
+        test: ["CMD-SHELL", "nc -z localhost 5432 &> /dev/null; echo $$?"]
         interval: 30s
         timeout: 10s
         retries: 5
@@ -44,12 +43,12 @@ services:
     image: "saga-spring:0.0.2-SNAPSHOT"
     hostname: saga
     links:
-      - "mysql:mysql.servicecomb.io"
+      - "postgres:postgres.servicecomb.io"
       - "service-center:sc.servicecomb.io"
     environment:
       - JAVA_OPTS=-Dspring.profiles.active=prd,servicecomb -Dcse.service.registry.address=http://sc.servicecomb.io:30100
     ports:
       - "8083:8080"
     depends_on:
-      mysql:
+      postgres:
         condition: service_healthy
diff --git a/integration-tests/pack-tests/pom.xml b/integration-tests/pack-tests/pom.xml
index f7b1d01..5c31c79 100644
--- a/integration-tests/pack-tests/pom.xml
+++ b/integration-tests/pack-tests/pom.xml
@@ -45,6 +45,10 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>pack-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.saga</groupId>
       <artifactId>alpha-core</artifactId>
     </dependency>
     <dependency>
@@ -81,17 +85,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-data-jpa</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.hibernate</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>javax.persistence</groupId>
       <artifactId>javax.persistence-api</artifactId>
       <scope>test</scope>
@@ -102,8 +95,9 @@
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.persistence</groupId>
-      <artifactId>org.eclipse.persistence.jpa</artifactId>
+      <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>saga-persistence-jpa</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java
deleted file mode 100644
index 75d1a8c..0000000
--- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.saga.integration.pack.tests;
-
-import java.util.Collections;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
-import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
-import org.springframework.transaction.jta.JtaTransactionManager;
-
-@Configuration
-@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha")
-class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
-  EclipseLinkJpaConfiguration(DataSource dataSource,
-      JpaProperties properties,
-      ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
-    super(dataSource, properties, jtaTransactionManagerProvider);
-  }
-
-  @Override
-  protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
-    return new EclipseLinkJpaVendorAdapter();
-  }
-
-  @Override
-  protected Map<String, Object> getVendorProperties() {
-    return Collections.singletonMap("eclipselink.weaving", "false");
-  }
-}
diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java
index 9d1b23a..c49829c 100644
--- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java
+++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java
@@ -23,10 +23,12 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import org.apache.servicecomb.saga.omega.spring.EnableOmega;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.context.annotation.Bean;
 
 @EnableOmega
 @SpringBootApplication
+@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha")
 public class GreetingApplication {
   public static void main(String[] args) {
     SpringApplication.run(GreetingApplication.class, args);
diff --git a/omega/omega-spring-tx/pom.xml b/omega/omega-spring-tx/pom.xml
index 539335b..ec2ab6a 100644
--- a/omega/omega-spring-tx/pom.xml
+++ b/omega/omega-spring-tx/pom.xml
@@ -75,8 +75,8 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-data-jpa</artifactId>
+      <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>saga-persistence-jpa</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java
index 9b7f474..c5c3d84 100644
--- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java
+++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java
@@ -21,13 +21,14 @@ import java.util.Objects;
 
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
 import javax.persistence.Id;
 
 @Entity
 public class User {
   @Id
-  @GeneratedValue
-  private long id;
+  @GeneratedValue(strategy = GenerationType.IDENTITY)
+  private Long id;
 
   private String username;
   private String email;
diff --git a/omega/omega-spring-tx/src/test/resources/schema.sql b/omega/omega-spring-tx/src/test/resources/schema.sql
new file mode 100644
index 0000000..cbc4330
--- /dev/null
+++ b/omega/omega-spring-tx/src/test/resources/schema.sql
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS `User` (
+  `id` bigint NOT NULL AUTO_INCREMENT,
+  `username` varchar(36) NOT NULL,
+  `email` varchar(36) NOT NULL,
+  PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8;
diff --git a/pom.xml b/pom.xml
index 417e0ee..42b0a63 100755
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
     <module>pack-contracts</module>
     <module>pack-common</module>
     <module>integration-tests</module>
+    <module>saga-persistence</module>
   </modules>
 
   <properties>
@@ -210,6 +211,11 @@
         <version>0.0.3-SNAPSHOT</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.servicecomb.saga</groupId>
+        <artifactId>saga-persistence-jpa</artifactId>
+        <version>0.0.3-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
         <version>2.4</version>
diff --git a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml b/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml
index 5a7dc9d..6b07471 100644
--- a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml
+++ b/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml
@@ -64,26 +64,25 @@
         <configuration>
           <images>
             <image>
-              <name>mysql/mysql-server:5.7</name>
-              <alias>mysql</alias>
+              <name>postgres</name>
+              <alias>postgres</alias>
               <run>
                 <env>
-                  <MYSQL_ROOT_PASSWORD>password</MYSQL_ROOT_PASSWORD>
-                  <MYSQL_DATABASE>saga</MYSQL_DATABASE>
-                  <MYSQL_USER>saga</MYSQL_USER>
-                  <MYSQL_PASSWORD>password</MYSQL_PASSWORD>
+                  <POSTGRES_DB>saga</POSTGRES_DB>
+                  <POSTGRES_USER>saga</POSTGRES_USER>
+                  <POSTGRES_PASSWORD>password</POSTGRES_PASSWORD>
                 </env>
                 <wait>
-                  <log>Starting MySQL 5.7</log>
+                  <log>database system is ready to accept connections</log>
                   <tcp>
                     <ports>
-                      <port>3306</port>
+                      <port>5432</port>
                     </ports>
                   </tcp>
                   <time>60000</time>
                 </wait>
                 <ports>
-                  <port>mysql.port:3306</port>
+                  <port>postgres.port:5432</port>
                 </ports>
               </run>
             </image>
@@ -181,7 +180,7 @@
                   </JAVA_OPTS>
                 </env>
                 <links>
-                  <link>mysql:mysql.servicecomb.io</link>
+                  <link>postgres:postgres.servicecomb.io</link>
                   <link>payment:payment.servicecomb.io</link>
                   <link>membership:membership.servicecomb.io</link>
                   <link>inventory:inventory.servicecomb.io</link>
@@ -200,7 +199,7 @@
                   <port>saga.port:8080</port>
                 </ports>
                 <dependsOn>
-                  <dependsOn>mysql</dependsOn>
+                  <dependsOn>postgres</dependsOn>
                 </dependsOn>
               </run>
             </image>
diff --git a/saga-demo/conditional-transaction-demo/docker-compose.yaml b/saga-demo/conditional-transaction-demo/docker-compose.yaml
index 11e20d5..45c72c3 100755
--- a/saga-demo/conditional-transaction-demo/docker-compose.yaml
+++ b/saga-demo/conditional-transaction-demo/docker-compose.yaml
@@ -18,18 +18,17 @@
 version: '2.1'
 
 services:
-  mysql:
-    image: "mysql/mysql-server:5.7"
-    hostname: mysql
+  postgres:
+    image: "postgres"
+    hostname: postgres
     environment:
-      - MYSQL_ROOT_PASSWORD=password
-      - MYSQL_DATABASE=saga
-      - MYSQL_USER=saga
-      - MYSQL_PASSWORD=password
+      - POSTGRES_DB=saga
+      - POSTGRES_USER=saga
+      - POSTGRES_PASSWORD=password
     ports:
-      - "3306:3306"
+      - "5432:5432"
     healthcheck:
-        test: ["CMD-SHELL", "nc -z localhost 3306 &> /dev/null; echo $$?"]
+        test: ["CMD-SHELL", "nc -z localhost 5432 &> /dev/null; echo $$?"]
         interval: 30s
         timeout: 10s
         retries: 5
@@ -62,7 +61,7 @@ services:
     image: "saga-spring:0.0.3-SNAPSHOT"
     hostname: saga
     links:
-      - "mysql:mysql.servicecomb.io"
+      - "postgres:postgres.servicecomb.io"
       - "payment:payment.servicecomb.io"
       - "membership:membership.servicecomb.io"
       - "inventory:inventory.servicecomb.io"
@@ -72,5 +71,5 @@ services:
     ports:
       - "8083:8080"
     depends_on:
-      mysql:
+      postgres:
         condition: service_healthy
diff --git a/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml b/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml
index 59b60ed..81594b4 100644
--- a/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml
+++ b/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml
@@ -82,26 +82,25 @@
               </run>
             </image>
             <image>
-              <name>mysql/mysql-server:5.7</name>
-              <alias>mysql</alias>
+              <name>postgres</name>
+              <alias>postgres</alias>
               <run>
                 <env>
-                  <MYSQL_ROOT_PASSWORD>password</MYSQL_ROOT_PASSWORD>
-                  <MYSQL_DATABASE>saga</MYSQL_DATABASE>
-                  <MYSQL_USER>saga</MYSQL_USER>
-                  <MYSQL_PASSWORD>password</MYSQL_PASSWORD>
+                  <POSTGRES_DB>saga</POSTGRES_DB>
+                  <POSTGRES_USER>saga</POSTGRES_USER>
+                  <POSTGRES_PASSWORD>password</POSTGRES_PASSWORD>
                 </env>
                 <wait>
-                  <log>Starting MySQL 5.7</log>
+                  <log>database system is ready to accept connections</log>
                   <tcp>
                     <ports>
-                      <port>3306</port>
+                      <port>5432</port>
                     </ports>
                   </tcp>
                   <time>60000</time>
                 </wait>
                 <ports>
-                  <port>mysql.port:3306</port>
+                  <port>postgres.port:5432</port>
                 </ports>
               </run>
             </image>
@@ -213,7 +212,7 @@
                 </env>
                 <links>
                   <link>service-center:sc.servicecomb.io</link>
-                  <link>mysql:mysql.servicecomb.io</link>
+                  <link>postgres:postgres.servicecomb.io</link>
                   <link>car:car.servicecomb.io</link>
                   <link>flight:flight.servicecomb.io</link>
                   <link>hotel:hotel.servicecomb.io</link>
@@ -232,7 +231,7 @@
                   <port>saga.port:8080</port>
                 </ports>
                 <dependsOn>
-                  <dependsOn>mysql</dependsOn>
+                  <dependsOn>postgres</dependsOn>
                 </dependsOn>
               </run>
             </image>
diff --git a/saga-demo/dependency-free-transaction-demo/docker-compose.yaml b/saga-demo/dependency-free-transaction-demo/docker-compose.yaml
index 523a322..3ad2cc7 100755
--- a/saga-demo/dependency-free-transaction-demo/docker-compose.yaml
+++ b/saga-demo/dependency-free-transaction-demo/docker-compose.yaml
@@ -24,18 +24,17 @@ services:
     ports:
       - "30100:30100"
 
-  mysql:
-    image: "mysql/mysql-server:5.7"
-    hostname: mysql
+  postgres:
+    image: "postgres"
+    hostname: postgres
     environment:
-      - MYSQL_ROOT_PASSWORD=password
-      - MYSQL_DATABASE=saga
-      - MYSQL_USER=saga
-      - MYSQL_PASSWORD=password
+      - POSTGRES_DB=saga
+      - POSTGRES_USER=saga
+      - POSTGRES_PASSWORD=password
     ports:
-      - "3306:3306"
+      - "5432:5432"
     healthcheck:
-        test: ["CMD-SHELL", "nc -z localhost 3306 &> /dev/null; echo $$?"]
+        test: ["CMD-SHELL", "nc -z localhost 5432 &> /dev/null; echo $$?"]
         interval: 30s
         timeout: 10s
         retries: 5
@@ -76,7 +75,7 @@ services:
     image: "saga-spring:0.0.3-SNAPSHOT"
     hostname: saga
     links:
-      - "mysql:mysql.servicecomb.io"
+      - "postgres:postgres.servicecomb.io"
       - "service-center:sc.servicecomb.io"
       - "car-rental-service:car.servicecomb.io"
       - "flight-booking-service:flight.servicecomb.io"
@@ -87,7 +86,7 @@ services:
     ports:
       - "8080:8080"
     depends_on:
-      mysql:
+      postgres:
         condition: service_healthy
 
   web:
diff --git a/saga-persistence/pom.xml b/saga-persistence/pom.xml
new file mode 100644
index 0000000..5f7bc20
--- /dev/null
+++ b/saga-persistence/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>saga</artifactId>
+    <groupId>org.apache.servicecomb.saga</groupId>
+    <version>0.0.3-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>saga-persistence</artifactId>
+  <packaging>pom</packaging>
+  <modules>
+    <module>saga-persistence-jpa</module>
+  </modules>
+
+
+</project>
diff --git a/saga-persistence/saga-persistence-jpa/pom.xml b/saga-persistence/saga-persistence-jpa/pom.xml
new file mode 100644
index 0000000..3373aec
--- /dev/null
+++ b/saga-persistence/saga-persistence-jpa/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>saga-persistence</artifactId>
+    <groupId>org.apache.servicecomb.saga</groupId>
+    <version>0.0.3-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>saga-persistence-jpa</artifactId>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-dependencies</artifactId>
+        <version>${spring.boot.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-jpa</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.hibernate</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.ethlo.persistence.tools</groupId>
+        <artifactId>eclipselink-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java b/saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java
similarity index 93%
rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java
rename to saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java
index 4061c49..1ad7879 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java
+++ b/saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.saga.alpha.server;
+package org.apache.servicecomb.saga.persistence.jpa;
 
 import java.util.Collections;
 import java.util.Map;
@@ -31,7 +31,7 @@ import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
 import org.springframework.transaction.jta.JtaTransactionManager;
 
 @Configuration
-class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
+public class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
   EclipseLinkJpaConfiguration(DataSource dataSource,
       JpaProperties properties,
       ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
diff --git a/saga-spring/src/main/resources/application.yaml b/saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories
similarity index 69%
copy from saga-spring/src/main/resources/application.yaml
copy to saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories
index fb71738..1d6b850 100644
--- a/saga-spring/src/main/resources/application.yaml
+++ b/saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories
@@ -14,24 +14,5 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-spring:
-  profiles: prd
-  datasource:
-    username: saga
-    password: password
-    driver-class-name: com.mysql.jdbc.Driver
-    url: jdbc:mysql://mysql.servicecomb.io:3306/saga?useSSL=false
-    platform: mysql
-    continue-on-error: true
-  jpa:
-    properties:
-      hibernate:
-        dialect: org.hibernate.dialect.MySQL5Dialect
-    hibernate:
-      ddl-auto: none
-
-saga:
-  thread:
-    count: 32
-  retry:
-    delay: 3000
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  org.apache.servicecomb.saga.persistence.jpa.EclipseLinkJpaConfiguration
diff --git a/saga-spring/pom.xml b/saga-spring/pom.xml
index 48be07b..b96b2a9 100755
--- a/saga-spring/pom.xml
+++ b/saga-spring/pom.xml
@@ -103,12 +103,17 @@
       <artifactId>spring-boot-starter-actuator</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-data-jpa</artifactId>
+      <groupId>javax.persistence</groupId>
+      <artifactId>javax.persistence-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>saga-persistence-jpa</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>io.kamon</groupId>
diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java
index 420655a..6be3501 100644
--- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java
+++ b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java
@@ -21,13 +21,14 @@ import java.util.Date;
 
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
 import javax.persistence.Id;
 
 @Entity
 public class SagaEventEntity {
   @Id
-  @GeneratedValue
-  private long id;
+  @GeneratedValue(strategy = GenerationType.IDENTITY)
+  private Long id;
   private String sagaId;
   private Date creationTime;
   private String type;
diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java
index 45cfe8c..1f1132b 100644
--- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java
+++ b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java
@@ -28,9 +28,9 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 interface SagaEventRepo extends PagingAndSortingRepository<SagaEventEntity, Long> {
 
   // TODO: 8/21/2017 replace with hql?
-  @Query(value = "SELECT * FROM saga_event_entity "
-      + "WHERE saga_id NOT IN ("
-      + "  SELECT DISTINCT saga_id FROM saga_event_entity"
+  @Query(value = "SELECT * FROM SagaEventEntity "
+      + "WHERE sagaId NOT IN ("
+      + "  SELECT DISTINCT sagaId FROM SagaEventEntity"
       + "  WHERE type = 'SagaEndedEvent'"
       + ")", nativeQuery = true)
   List<SagaEventEntity> findIncompleteSagaEventsGroupBySagaId();
diff --git a/saga-spring/src/main/resources/application.yaml b/saga-spring/src/main/resources/application.yaml
index fb71738..6ed0d9d 100644
--- a/saga-spring/src/main/resources/application.yaml
+++ b/saga-spring/src/main/resources/application.yaml
@@ -19,16 +19,9 @@ spring:
   datasource:
     username: saga
     password: password
-    driver-class-name: com.mysql.jdbc.Driver
-    url: jdbc:mysql://mysql.servicecomb.io:3306/saga?useSSL=false
-    platform: mysql
-    continue-on-error: true
-  jpa:
-    properties:
-      hibernate:
-        dialect: org.hibernate.dialect.MySQL5Dialect
-    hibernate:
-      ddl-auto: none
+    url: jdbc:postgresql://postgres.servicecomb.io:5432/saga?useSSL=false
+    platform: postgresql
+#    continue-on-error: true
 
 saga:
   thread:
diff --git a/saga-spring/src/main/resources/schema-mysql.sql b/saga-spring/src/main/resources/schema-mysql.sql
deleted file mode 100644
index cf713ad..0000000
--- a/saga-spring/src/main/resources/schema-mysql.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE IF NOT EXISTS `saga_event_entity` (
-  `id` bigint NOT NULL AUTO_INCREMENT,
-  `saga_id` varchar(36) NOT NULL,
-  `creation_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
-  `type` varchar(50) NOT NULL,
-  `content_json` JSON NOT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `running_sagas_index` (`saga_id`, `type`)
-) DEFAULT CHARSET=utf8;
diff --git a/saga-spring/src/main/resources/schema-postgresql.sql b/saga-spring/src/main/resources/schema-postgresql.sql
new file mode 100644
index 0000000..3900fd3
--- /dev/null
+++ b/saga-spring/src/main/resources/schema-postgresql.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS SagaEventEntity (
+  id BIGSERIAL PRIMARY KEY,
+  sagaId varchar(36) NOT NULL,
+  creationTime timestamp(6) NOT NULL DEFAULT CURRENT_DATE,
+  type varchar(50) NOT NULL,
+  contentJson JSON NOT NULL
+);
+
+CREATE INDEX IF NOT EXISTS running_sagas_index ON SagaEventEntity (sagaId, type);
diff --git a/saga-spring/src/test/resources/data.sql b/saga-spring/src/test/resources/data.sql
index 6ace806..d0db33e 100644
--- a/saga-spring/src/test/resources/data.sql
+++ b/saga-spring/src/test/resources/data.sql
@@ -1,12 +1,12 @@
-DROP TABLE IF EXISTS saga_event_entity;
+DROP TABLE IF EXISTS SagaEventEntity;
 
-CREATE TABLE `saga_event_entity` (
+CREATE TABLE `SagaEventEntity` (
   `id` bigint NOT NULL AUTO_INCREMENT,
-  `saga_id` varchar(36) NOT NULL,
-  `creation_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  `sagaId` varchar(36) NOT NULL,
+  `creationTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `type` varchar(50) NOT NULL,
-  `content_json` clob NOT NULL DEFAULT '{}',
+  `contentJson` clob NOT NULL DEFAULT '{}',
   PRIMARY KEY (`id`)
 ) DEFAULT CHARSET=utf8;
 
- CREATE INDEX running_sagas_index ON saga_event_entity(saga_id, type);
+ CREATE INDEX running_sagas_index ON sagaEventEntity(sagaId, type);

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.

[incubator-servicecomb-saga] 01/03: SCB-249 replaced hibernate with eclipselink to comply with APL2

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch SCB-249_apl_compliance
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit a6aab6b04b079b7f65a5d4ddb12b473d006f47e8
Author: seanyinx <se...@huawei.com>
AuthorDate: Wed Jan 17 15:53:14 2018 +0800

    SCB-249 replaced hibernate with eclipselink to comply with APL2
    
    Signed-off-by: seanyinx <se...@huawei.com>
---
 alpha/alpha-core/pom.xml                           |  4 +
 .../servicecomb/saga/alpha/core/TxEvent.java       | 10 +++
 alpha/alpha-server/pom.xml                         | 14 ++++
 .../servicecomb/saga/alpha/server/AlphaConfig.java |  2 +
 .../alpha/server/JpaBaseConfigurationImpl.java     | 50 +++++++++++
 .../saga/alpha/server/SpringTxEventRepository.java |  4 +-
 .../saga/alpha/server/TxEventEnvelope.java         | 96 ----------------------
 .../alpha/server/TxEventEnvelopeRepository.java    | 38 +++++----
 .../saga/alpha/server/AlphaIntegrationTest.java    |  6 +-
 alpha/alpha-server/src/test/resources/schema.sql   | 13 +++
 pom.xml                                            | 31 +++++++
 11 files changed, 150 insertions(+), 118 deletions(-)

diff --git a/alpha/alpha-core/pom.xml b/alpha/alpha-core/pom.xml
index 4a6c1b0..aa74718 100644
--- a/alpha/alpha-core/pom.xml
+++ b/alpha/alpha-core/pom.xml
@@ -38,6 +38,10 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>javax.persistence</groupId>
+      <artifactId>javax.persistence-api</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>junit</groupId>
diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java
index ebea44c..37a29f1 100644
--- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java
+++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java
@@ -19,7 +19,17 @@ package org.apache.servicecomb.saga.alpha.core;
 
 import java.util.Date;
 
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
 public class TxEvent {
+  @Id
+  @GeneratedValue(strategy = GenerationType.IDENTITY)
+  private Long surrogateId;
+
   private String serviceName;
   private String instanceId;
   private Date creationTime;
diff --git a/alpha/alpha-server/pom.xml b/alpha/alpha-server/pom.xml
index 304f6c8..6335c91 100644
--- a/alpha/alpha-server/pom.xml
+++ b/alpha/alpha-server/pom.xml
@@ -65,6 +65,16 @@
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-data-jpa</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.hibernate</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
     </dependency>
     <dependency>
       <groupId>mysql</groupId>
@@ -115,6 +125,10 @@
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>com.ethlo.persistence.tools</groupId>
+        <artifactId>eclipselink-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
index f970ecb..bb4ba89 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
@@ -31,9 +31,11 @@ import org.apache.servicecomb.saga.alpha.core.PushBackOmegaCallback;
 import org.apache.servicecomb.saga.alpha.core.TxConsistentService;
 import org.apache.servicecomb.saga.alpha.core.TxEventRepository;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha")
 @Configuration
 class AlphaConfig {
   private final BlockingQueue<Runnable> pendingCompensations = new LinkedBlockingQueue<>();
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
new file mode 100644
index 0000000..0bf0fad
--- /dev/null
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.saga.alpha.server;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
+import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
+import org.springframework.transaction.jta.JtaTransactionManager;
+
+@Configuration
+class JpaBaseConfigurationImpl extends JpaBaseConfiguration {
+  JpaBaseConfigurationImpl(DataSource dataSource,
+      JpaProperties properties,
+      ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
+    super(dataSource, properties, jtaTransactionManagerProvider);
+  }
+
+  @Override
+  protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
+    return new EclipseLinkJpaVendorAdapter();
+  }
+
+  @Override
+  protected Map<String, Object> getVendorProperties() {
+    return Collections.singletonMap("eclipselink.weaving", "false");
+  }
+}
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
index 00d10d2..f0743e9 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
@@ -31,7 +31,7 @@ class SpringTxEventRepository implements TxEventRepository {
 
   @Override
   public void save(TxEvent event) {
-    eventRepo.save(new TxEventEnvelope(event));
+    eventRepo.save(event);
   }
 
   @Override
@@ -41,7 +41,7 @@ class SpringTxEventRepository implements TxEventRepository {
 
   @Override
   public TxEvent findFirstTransaction(String globalTxId, String localTxId, String type) {
-    return eventRepo.findFirstByEventGlobalTxIdAndEventLocalTxIdAndEventType(globalTxId, localTxId, type).event();
+    return eventRepo.findFirstByGlobalTxIdAndLocalTxIdAndType(globalTxId, localTxId, type);
   }
 
   @Override
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelope.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelope.java
deleted file mode 100644
index f4b4c66..0000000
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelope.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.saga.alpha.server;
-
-import java.util.Date;
-
-import javax.persistence.Embedded;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-import org.apache.servicecomb.saga.alpha.core.TxEvent;
-
-@Entity
-class TxEventEnvelope {
-  @Id
-  @GeneratedValue
-  private long surrogateId;
-
-  @Embedded
-  private TxEvent event;
-
-  private TxEventEnvelope() {
-  }
-
-  TxEventEnvelope(TxEvent event) {
-    this.event = event;
-  }
-
-  public TxEventEnvelope(
-      String serviceName,
-      String instanceId,
-      String globalTxId,
-      String localTxId,
-      String parentTxId,
-      String type,
-      String compensationMethod,
-      byte[] payloads) {
-    this.event = new TxEvent(serviceName, instanceId, new Date(), globalTxId, localTxId, parentTxId, type, compensationMethod, payloads);
-  }
-
-  String serviceName() {
-    return event.serviceName();
-  }
-
-  String instanceId() {
-    return event.instanceId();
-  }
-
-  public long creationTime() {
-    return event.creationTime().getTime();
-  }
-
-  String globalTxId() {
-    return event.globalTxId();
-  }
-
-  String localTxId() {
-    return event.localTxId();
-  }
-
-  String parentTxId() {
-    return event.parentTxId();
-  }
-
-  String type() {
-    return event.type();
-  }
-
-  String compensationMethod() {
-    return event.compensationMethod();
-  }
-
-  byte[] payloads() {
-    return event.payloads();
-  }
-
-  TxEvent event() {
-    return event;
-  }
-}
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java
index 1e1859c..bdf82f1 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java
@@ -23,29 +23,33 @@ import org.apache.servicecomb.saga.alpha.core.TxEvent;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
 
-interface TxEventEnvelopeRepository extends CrudRepository<TxEventEnvelope, Long> {
-  List<TxEventEnvelope> findByEventGlobalTxId(String globalTxId);
+interface TxEventEnvelopeRepository extends CrudRepository<TxEvent, Long> {
+  List<TxEvent> findByGlobalTxId(String globalTxId);
 
   @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent("
-      + "t.event.serviceName, t.event.instanceId, t.event.globalTxId, t.event.localTxId, t.event.parentTxId, t.event.type, t.event.compensationMethod, t.event.payloads"
-      + ") FROM TxEventEnvelope t "
-      + "WHERE t.event.globalTxId = ?1 AND t.event.type = ?2")
+      + "t.serviceName, t.instanceId, t.globalTxId, t.localTxId, t.parentTxId, t.type, t.compensationMethod, t.payloads"
+      + ") FROM TxEvent t "
+      + "WHERE t.globalTxId = ?1 AND t.type = ?2")
   List<TxEvent> findByEventGlobalTxIdAndEventType(String globalTxId, String type);
 
-  TxEventEnvelope findFirstByEventGlobalTxIdAndEventLocalTxIdAndEventType(String globalTxId, String localTxId, String type);
+  TxEvent findFirstByGlobalTxIdAndLocalTxIdAndType(String globalTxId, String localTxId, String type);
 
   @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent("
-      + "t.event.serviceName, t.event.instanceId, t.event.globalTxId, t.event.localTxId, t.event.parentTxId, t.event.type, t.event.compensationMethod, t.event.payloads"
-      + ") FROM TxEventEnvelope t "
-      + "WHERE t.event.globalTxId = ?1 AND t.event.type = 'TxStartedEvent' AND EXISTS ( "
-      + "  FROM TxEventEnvelope t1 "
-      + "  WHERE t1.event.globalTxId = ?1 "
-      + "  AND t1.event.localTxId = t.event.localTxId "
-      + "  AND t1.event.type = 'TxEndedEvent'"
+      + "t.serviceName, t.instanceId, t.globalTxId, t.localTxId, t.parentTxId, t.type, t.compensationMethod, t.payloads"
+      + ") FROM TxEvent t "
+      + "WHERE t.globalTxId = ?1 AND t.type = 'TxStartedEvent'"
+      + "AND EXISTS ("
+      + "  SELECT t1.globalTxId"
+      + "  FROM TxEvent t1 "
+      + "  WHERE t1.globalTxId = ?1 "
+      + "  AND t1.localTxId = t.localTxId "
+      + "  AND t1.type = 'TxEndedEvent'"
       + ") AND NOT EXISTS ( "
-      + "  FROM TxEventEnvelope t2 "
-      + "  WHERE t2.event.globalTxId = ?1 "
-      + "  AND t2.event.localTxId = t.event.localTxId "
-      + "  AND t2.event.type = 'TxCompensatedEvent')")
+      + "  SELECT t2.globalTxId"
+      + "  FROM TxEvent t2 "
+      + "  WHERE t2.globalTxId = ?1 "
+      + "  AND t2.localTxId = t.localTxId "
+      + "  AND t2.type = 'TxCompensatedEvent')"
+ )
   List<TxEvent> findStartedEventsWithMatchingEndedButNotCompensatedEvents(String globalTxId);
 }
diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
index 0048311..6d4f91f 100644
--- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
+++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
@@ -120,11 +120,11 @@ public class AlphaIntegrationTest {
     asyncStub.onConnected(serviceConfig, compensateResponseObserver);
     blockingStub.onTxEvent(someGrpcEvent(TxStartedEvent));
     // use the asynchronous stub need to wait for some time
-    await().atMost(1, SECONDS).until(() -> !eventRepo.findByEventGlobalTxId(globalTxId).isEmpty());
+    await().atMost(1, SECONDS).until(() -> !eventRepo.findByGlobalTxId(globalTxId).isEmpty());
 
     assertThat(receivedCommands.isEmpty(), is(true));
 
-    TxEventEnvelope envelope = eventRepo.findByEventGlobalTxId(globalTxId).get(0);
+    TxEvent envelope = eventRepo.findByGlobalTxId(globalTxId).get(0);
 
     assertThat(envelope.serviceName(), is(serviceName));
     assertThat(envelope.instanceId(), is(instanceId));
@@ -235,7 +235,7 @@ public class AlphaIntegrationTest {
     asyncStub.onConnected(serviceConfig, compensateResponseObserver);
     blockingStub.onTxEvent(someGrpcEvent(TxStartedEvent));
     blockingStub.onTxEvent(someGrpcEvent(TxEndedEvent));
-    await().atMost(1, SECONDS).until(() -> !eventRepo.findByEventGlobalTxId(globalTxId).isEmpty());
+    await().atMost(1, SECONDS).until(() -> !eventRepo.findByGlobalTxId(globalTxId).isEmpty());
 
     blockingStub.onTxEvent(someGrpcEvent(TxAbortedEvent));
     await().atMost(1, SECONDS).until(() -> !receivedCommands.isEmpty());
diff --git a/alpha/alpha-server/src/test/resources/schema.sql b/alpha/alpha-server/src/test/resources/schema.sql
new file mode 100644
index 0000000..08945a7
--- /dev/null
+++ b/alpha/alpha-server/src/test/resources/schema.sql
@@ -0,0 +1,13 @@
+CREATE TABLE IF NOT EXISTS `TxEvent` (
+  `surrogateId` bigint NOT NULL AUTO_INCREMENT,
+  `serviceName` varchar(36) NOT NULL,
+  `instanceId` varchar(36) NOT NULL,
+  `creationTime` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
+  `globalTxId` varchar(36) NOT NULL,
+  `localTxId` varchar(36) NOT NULL,
+  `parentTxId` varchar(36) DEFAULT NULL,
+  `type` varchar(50) NOT NULL,
+  `compensationMethod` varchar(256) NOT NULL,
+  `payloads` varbinary(10240),
+  PRIMARY KEY (`surrogateId`)
+) DEFAULT CHARSET=utf8;
diff --git a/pom.xml b/pom.xml
index 9338b2f..417e0ee 100755
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,7 @@
     <grpc.version>1.8.0</grpc.version>
     <kryo.version>4.0.1</kryo.version>
     <javax.transaction.version>1.2</javax.transaction.version>
+    <eclipse.link.version>2.7.1</eclipse.link.version>
   </properties>
 
   <name>ServiceComb Saga</name>
@@ -353,6 +354,16 @@
         <artifactId>javax.transaction-api</artifactId>
         <version>${javax.transaction.version}</version>
       </dependency>
+      <dependency>
+        <groupId>javax.persistence</groupId>
+        <artifactId>javax.persistence-api</artifactId>
+        <version>2.2</version>
+      </dependency>
+      <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
+      <version>${eclipse.link.version}</version>
+    </dependency>
 
       <!-- test dependencies -->
       <dependency>
@@ -586,6 +597,26 @@
             </execution>
           </executions>
         </plugin>
+        <plugin>
+          <groupId>com.ethlo.persistence.tools</groupId>
+          <artifactId>eclipselink-maven-plugin</artifactId>
+          <version>2.7.0</version>
+          <executions>
+            <execution>
+              <phase>process-classes</phase>
+              <goals>
+                <goal>weave</goal>
+              </goals>
+            </execution>
+          </executions>
+          <dependencies>
+            <dependency>
+              <groupId>org.eclipse.persistence</groupId>
+              <artifactId>org.eclipse.persistence.jpa</artifactId>
+              <version>${eclipse.link.version}</version>
+            </dependency>
+          </dependencies>
+        </plugin>
       </plugins>
     </pluginManagement>
     <!-- enable the rat check by default -->

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.

[incubator-servicecomb-saga] 02/03: SCB-249 replaced mysql with postgres to comply with APL2

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch SCB-249_apl_compliance
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit a70fe34826ece7b2a245e09c9c3d46f7d4932f12
Author: seanyinx <se...@huawei.com>
AuthorDate: Wed Jan 17 17:02:21 2018 +0800

    SCB-249 replaced mysql with postgres to comply with APL2
    
    Signed-off-by: seanyinx <se...@huawei.com>
---
 alpha/alpha-server/pom.xml                         |  9 ++-
 ...nImpl.java => EclipseLinkJpaConfiguration.java} |  4 +-
 .../src/main/resources/application.yaml            | 13 +---
 .../src/main/resources/schema-mysql.sql            | 14 ----
 .../src/main/resources/schema-postgresql.sql       | 14 ++++
 integration-tests/pack-tests/pom.xml               | 50 +++++++++----
 .../pack/tests/EclipseLinkJpaConfiguration.java    |  8 +-
 .../saga/integration/pack/tests/PackIT.java        | 52 ++++++-------
 .../integration/pack/tests/TxEventEnvelope.java    | 87 ----------------------
 .../pack/tests/TxEventEnvelopeRepository.java      |  7 +-
 .../pack-tests/src/test/resources/application.yaml |  8 +-
 11 files changed, 98 insertions(+), 168 deletions(-)

diff --git a/alpha/alpha-server/pom.xml b/alpha/alpha-server/pom.xml
index 6335c91..856d86c 100644
--- a/alpha/alpha-server/pom.xml
+++ b/alpha/alpha-server/pom.xml
@@ -59,6 +59,10 @@
       <artifactId>alpha-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>pack-common</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
@@ -77,8 +81,9 @@
       <artifactId>org.eclipse.persistence.jpa</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>runtime</scope>
     </dependency>
 
     <dependency>
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java
similarity index 94%
copy from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
copy to alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java
index 0bf0fad..4061c49 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/EclipseLinkJpaConfiguration.java
@@ -31,8 +31,8 @@ import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
 import org.springframework.transaction.jta.JtaTransactionManager;
 
 @Configuration
-class JpaBaseConfigurationImpl extends JpaBaseConfiguration {
-  JpaBaseConfigurationImpl(DataSource dataSource,
+class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
+  EclipseLinkJpaConfiguration(DataSource dataSource,
       JpaProperties properties,
       ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
     super(dataSource, properties, jtaTransactionManagerProvider);
diff --git a/alpha/alpha-server/src/main/resources/application.yaml b/alpha/alpha-server/src/main/resources/application.yaml
index 9b166c8..cf3c896 100644
--- a/alpha/alpha-server/src/main/resources/application.yaml
+++ b/alpha/alpha-server/src/main/resources/application.yaml
@@ -19,13 +19,6 @@ spring:
   datasource:
     username: saga
     password: password
-    driver-class-name: com.mysql.jdbc.Driver
-    url: jdbc:mysql://mysql.servicecomb.io:3306/saga?useSSL=false
-    platform: mysql
-    continue-on-error: true
-  jpa:
-    properties:
-      hibernate:
-        dialect: org.hibernate.dialect.MySQL5Dialect
-    hibernate:
-      ddl-auto: none
+    url: jdbc:postgresql://postgresql.servicecomb.io:5432/saga?useSSL=false
+    platform: postgresql
+#    continue-on-error: true
diff --git a/alpha/alpha-server/src/main/resources/schema-mysql.sql b/alpha/alpha-server/src/main/resources/schema-mysql.sql
deleted file mode 100644
index bd98c2a..0000000
--- a/alpha/alpha-server/src/main/resources/schema-mysql.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-CREATE TABLE IF NOT EXISTS `tx_event_envelope` (
-  `surrogate_id` bigint NOT NULL AUTO_INCREMENT,
-  `service_name` varchar(16) NOT NULL,
-  `instance_id` varchar(36) NOT NULL,
-  `creation_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
-  `global_tx_id` varchar(36) NOT NULL,
-  `local_tx_id` varchar(36) NOT NULL,
-  `parent_tx_id` varchar(36) DEFAULT NULL,
-  `type` varchar(50) NOT NULL,
-  `compensation_method` varchar(256) NOT NULL,
-  `payloads` varbinary(10240),
-  PRIMARY KEY (`surrogate_id`),
-  INDEX `running_sagas_index` (`global_tx_id`, `local_tx_id`, `type`)
-) DEFAULT CHARSET=utf8;
diff --git a/alpha/alpha-server/src/main/resources/schema-postgresql.sql b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
new file mode 100644
index 0000000..e84a9c3
--- /dev/null
+++ b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
@@ -0,0 +1,14 @@
+CREATE TABLE IF NOT EXISTS TxEvent (
+  surrogateId BIGSERIAL PRIMARY KEY,
+  serviceName varchar(16) NOT NULL,
+  instanceId varchar(36) NOT NULL,
+  creationTime timestamp(6) NOT NULL DEFAULT CURRENT_DATE,
+  globalTxId varchar(36) NOT NULL,
+  localTxId varchar(36) NOT NULL,
+  parentTxId varchar(36) DEFAULT NULL,
+  type varchar(50) NOT NULL,
+  compensationMethod varchar(256) NOT NULL,
+  payloads bytea
+);
+
+CREATE INDEX IF NOT EXISTS running_sagas_index ON TxEvent (globalTxId, localTxId, type);
diff --git a/integration-tests/pack-tests/pom.xml b/integration-tests/pack-tests/pom.xml
index b493851..f7b1d01 100644
--- a/integration-tests/pack-tests/pom.xml
+++ b/integration-tests/pack-tests/pom.xml
@@ -45,6 +45,10 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.saga</groupId>
+      <artifactId>alpha-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.saga</groupId>
       <artifactId>omega-spring-starter</artifactId>
     </dependency>
     <dependency>
@@ -79,14 +83,29 @@
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-data-jpa</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.hibernate</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>javax.persistence</groupId>
+      <artifactId>javax.persistence-api</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-test</artifactId>
       <scope>test</scope>
@@ -114,26 +133,25 @@
             <configuration>
               <images>
                 <image>
-                  <name>mysql/mysql-server:5.7</name>
-                  <alias>mysql</alias>
+                  <name>postgres</name>
+                  <alias>postgres</alias>
                   <run>
                     <env>
-                      <MYSQL_ROOT_PASSWORD>password</MYSQL_ROOT_PASSWORD>
-                      <MYSQL_DATABASE>saga</MYSQL_DATABASE>
-                      <MYSQL_USER>saga</MYSQL_USER>
-                      <MYSQL_PASSWORD>password</MYSQL_PASSWORD>
+                      <POSTGRES_DB>saga</POSTGRES_DB>
+                      <POSTGRES_USER>saga</POSTGRES_USER>
+                      <POSTGRES_PASSWORD>password</POSTGRES_PASSWORD>
                     </env>
                     <wait>
-                      <log>Starting MySQL 5.7</log>
+                      <log>database system is ready to accept connections</log>
                       <tcp>
                         <ports>
-                          <port>3306</port>
+                          <port>5432</port>
                         </ports>
                       </tcp>
                       <time>60000</time>
                     </wait>
                     <ports>
-                      <port>mysql.port:3306</port>
+                      <port>postgres.port:5432</port>
                     </ports>
                   </run>
                 </image>
@@ -147,7 +165,7 @@
                       </JAVA_OPTS>
                     </env>
                     <links>
-                      <link>mysql:mysql.servicecomb.io</link>
+                      <link>postgres:postgresql.servicecomb.io</link>
                     </links>
                     <wait>
                       <log>Started [a-zA-Z]+ in [0-9.]+ seconds</log>
@@ -162,7 +180,7 @@
                       <port>alpha.port:8080</port>
                     </ports>
                     <dependsOn>
-                      <dependsOn>mysql</dependsOn>
+                      <dependsOn>postgres</dependsOn>
                     </dependsOn>
                   </run>
                 </image>
@@ -214,7 +232,7 @@
                   ${docker.hostname}:${alpha.port}
                 </alpha.cluster.address>
                 <spring.datasource.url>
-                  jdbc:mysql://${docker.hostname}:${mysql.port}/saga?useSSL=false
+                  jdbc:postgresql://${docker.hostname}:${postgres.port}/saga?useSSL=false
                 </spring.datasource.url>
               </systemPropertyVariables>
               <argLine>${jacoco.failsafe.argLine}</argLine>
@@ -228,6 +246,10 @@
               </execution>
             </executions>
           </plugin>
+          <plugin>
+            <groupId>com.ethlo.persistence.tools</groupId>
+            <artifactId>eclipselink-maven-plugin</artifactId>
+          </plugin>
         </plugins>
       </build>
     </profile>
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java
similarity index 85%
rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java
index 0bf0fad..75d1a8c 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/JpaBaseConfigurationImpl.java
+++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/EclipseLinkJpaConfiguration.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.saga.alpha.server;
+package org.apache.servicecomb.saga.integration.pack.tests;
 
 import java.util.Collections;
 import java.util.Map;
@@ -23,6 +23,7 @@ import java.util.Map;
 import javax.sql.DataSource;
 
 import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
 import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
 import org.springframework.context.annotation.Configuration;
@@ -31,8 +32,9 @@ import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
 import org.springframework.transaction.jta.JtaTransactionManager;
 
 @Configuration
-class JpaBaseConfigurationImpl extends JpaBaseConfiguration {
-  JpaBaseConfigurationImpl(DataSource dataSource,
+@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha")
+class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
+  EclipseLinkJpaConfiguration(DataSource dataSource,
       JpaProperties properties,
       ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
     super(dataSource, properties, jtaTransactionManagerProvider);
diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java
index 0a340db..b3045e3 100644
--- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java
+++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java
@@ -30,8 +30,8 @@ import static org.springframework.http.HttpStatus.OK;
 
 import java.util.List;
 import java.util.Queue;
-import java.util.UUID;
 
+import org.apache.servicecomb.saga.alpha.core.TxEvent;
 import org.apache.servicecomb.saga.omega.context.OmegaContext;
 import org.junit.After;
 import org.junit.Test;
@@ -79,46 +79,46 @@ public class PackIT {
     assertThat(distinctGlobalTxIds.size(), is(1));
 
     String globalTxId = distinctGlobalTxIds.get(0);
-    List<TxEventEnvelope> envelopes = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
+    List<TxEvent> events = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
 
-    assertThat(envelopes.size(), is(6));
+    assertThat(events.size(), is(6));
 
-    TxEventEnvelope sagaStartedEvent = envelopes.get(0);
+    TxEvent sagaStartedEvent = events.get(0);
     assertThat(sagaStartedEvent.type(), is("SagaStartedEvent"));
     assertThat(sagaStartedEvent.localTxId(), is(globalTxId));
     assertThat(sagaStartedEvent.parentTxId(), is(nullValue()));
     assertThat(sagaStartedEvent.serviceName(), is(serviceName));
     assertThat(sagaStartedEvent.instanceId(), is(notNullValue()));
 
-    TxEventEnvelope txStartedEvent1 = envelopes.get(1);
+    TxEvent txStartedEvent1 = events.get(1);
     assertThat(txStartedEvent1.type(), is("TxStartedEvent"));
     assertThat(txStartedEvent1.localTxId(), is(notNullValue()));
     assertThat(txStartedEvent1.parentTxId(), is(globalTxId));
     assertThat(txStartedEvent1.serviceName(), is(serviceName));
     assertThat(txStartedEvent1.instanceId(), is(sagaStartedEvent.instanceId()));
 
-    TxEventEnvelope txEndedEvent1 = envelopes.get(2);
+    TxEvent txEndedEvent1 = events.get(2);
     assertThat(txEndedEvent1.type(), is("TxEndedEvent"));
     assertThat(txEndedEvent1.localTxId(), is(txStartedEvent1.localTxId()));
     assertThat(txEndedEvent1.parentTxId(), is(globalTxId));
     assertThat(txEndedEvent1.serviceName(), is(serviceName));
     assertThat(txEndedEvent1.instanceId(), is(txStartedEvent1.instanceId()));
 
-    TxEventEnvelope txStartedEvent2 = envelopes.get(3);
+    TxEvent txStartedEvent2 = events.get(3);
     assertThat(txStartedEvent2.type(), is("TxStartedEvent"));
     assertThat(txStartedEvent2.localTxId(), is(notNullValue()));
     assertThat(txStartedEvent2.parentTxId(), is(globalTxId));
     assertThat(txStartedEvent2.serviceName(), is(serviceName));
     assertThat(txStartedEvent2.instanceId(), is(notNullValue()));
 
-    TxEventEnvelope txEndedEvent2 = envelopes.get(4);
+    TxEvent txEndedEvent2 = events.get(4);
     assertThat(txEndedEvent2.type(), is("TxEndedEvent"));
     assertThat(txEndedEvent2.localTxId(), is(txStartedEvent2.localTxId()));
     assertThat(txEndedEvent2.parentTxId(), is(globalTxId));
     assertThat(txEndedEvent2.serviceName(), is(serviceName));
     assertThat(txEndedEvent2.instanceId(), is(txStartedEvent2.instanceId()));
 
-    TxEventEnvelope sagaEndedEvent = envelopes.get(5);
+    TxEvent sagaEndedEvent = events.get(5);
     assertThat(sagaEndedEvent.type(), is("SagaEndedEvent"));
     assertThat(sagaEndedEvent.localTxId(), is(globalTxId));
     assertThat(sagaEndedEvent.parentTxId(), is(nullValue()));
@@ -142,20 +142,20 @@ public class PackIT {
     assertThat(distinctGlobalTxIds.size(), is(1));
 
     String globalTxId = distinctGlobalTxIds.get(0);
-    List<TxEventEnvelope> envelopes = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
-    assertThat(envelopes.size(), is(7));
+    List<TxEvent> events = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
+    assertThat(events.size(), is(7));
 
-    TxEventEnvelope sagaStartedEvent = envelopes.get(0);
+    TxEvent sagaStartedEvent = events.get(0);
     assertThat(sagaStartedEvent.type(), is("SagaStartedEvent"));
 
-    TxEventEnvelope txStartedEvent1 = envelopes.get(1);
+    TxEvent txStartedEvent1 = events.get(1);
     assertThat(txStartedEvent1.type(), is("TxStartedEvent"));
-    assertThat(envelopes.get(2).type(), is("TxEndedEvent"));
+    assertThat(events.get(2).type(), is("TxEndedEvent"));
 
-    TxEventEnvelope txStartedEvent2 = envelopes.get(3);
+    TxEvent txStartedEvent2 = events.get(3);
     assertThat(txStartedEvent2.type(), is("TxStartedEvent"));
 
-    TxEventEnvelope txAbortedEvent = envelopes.get(4);
+    TxEvent txAbortedEvent = events.get(4);
     assertThat(txAbortedEvent.type(), is("TxAbortedEvent"));
     assertThat(txAbortedEvent.localTxId(), is(txStartedEvent2.localTxId()));
     assertThat(txAbortedEvent.parentTxId(), is(globalTxId));
@@ -163,14 +163,14 @@ public class PackIT {
     assertThat(txAbortedEvent.instanceId(), is(txStartedEvent2.instanceId()));
 
     // TODO: 2018/1/9 compensation shall be done in reverse order
-    TxEventEnvelope txCompensatedEvent1 = envelopes.get(5);
+    TxEvent txCompensatedEvent1 = events.get(5);
     assertThat(txCompensatedEvent1.type(), is("TxCompensatedEvent"));
     assertThat(txCompensatedEvent1.localTxId(), is(txStartedEvent1.localTxId()));
     assertThat(txCompensatedEvent1.parentTxId(), is(globalTxId));
     assertThat(txCompensatedEvent1.serviceName(), is(serviceName));
     assertThat(txCompensatedEvent1.instanceId(), is(txStartedEvent1.instanceId()));
 
-    assertThat(envelopes.get(6).type(), is("SagaEndedEvent"));
+    assertThat(events.get(6).type(), is("SagaEndedEvent"));
 
     assertThat(compensatedMessages, contains("Goodbye, " + TRESPASSER));
   }
@@ -188,34 +188,34 @@ public class PackIT {
     assertThat(distinctGlobalTxIds.size(), is(1));
 
     String globalTxId = distinctGlobalTxIds.get(0);
-    List<TxEventEnvelope> envelopes = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
+    List<TxEvent> events = repository.findByGlobalTxIdOrderByCreationTime(globalTxId);
 
-    assertThat(envelopes.size(), is(6));
+    assertThat(events.size(), is(6));
 
-    TxEventEnvelope sagaStartedEvent = envelopes.get(0);
+    TxEvent sagaStartedEvent = events.get(0);
     assertThat(sagaStartedEvent.type(), is("SagaStartedEvent"));
 
-    TxEventEnvelope txStartedEvent1 = envelopes.get(1);
+    TxEvent txStartedEvent1 = events.get(1);
     assertThat(txStartedEvent1.type(), is("TxStartedEvent"));
     assertThat(txStartedEvent1.localTxId(), is(notNullValue()));
     assertThat(txStartedEvent1.parentTxId(), is(globalTxId));
 
-    TxEventEnvelope txStartedEvent2 = envelopes.get(2);
+    TxEvent txStartedEvent2 = events.get(2);
     assertThat(txStartedEvent2.type(), is("TxStartedEvent"));
     assertThat(txStartedEvent2.localTxId(), is(notNullValue()));
     assertThat(txStartedEvent2.parentTxId(), is(txStartedEvent1.localTxId()));
 
-    TxEventEnvelope txEndedEvent2 = envelopes.get(3);
+    TxEvent txEndedEvent2 = events.get(3);
     assertThat(txEndedEvent2.type(), is("TxEndedEvent"));
     assertThat(txEndedEvent2.localTxId(), is(txStartedEvent2.localTxId()));
     assertThat(txEndedEvent2.parentTxId(), is(txStartedEvent1.localTxId()));
 
-    TxEventEnvelope txEndedEvent1 = envelopes.get(4);
+    TxEvent txEndedEvent1 = events.get(4);
     assertThat(txEndedEvent1.type(), is("TxEndedEvent"));
     assertThat(txEndedEvent1.localTxId(), is(txStartedEvent1.localTxId()));
     assertThat(txEndedEvent1.parentTxId(), is(globalTxId));
 
-    TxEventEnvelope sagaEndedEvent = envelopes.get(5);
+    TxEvent sagaEndedEvent = events.get(5);
     assertThat(sagaEndedEvent.type(), is("SagaEndedEvent"));
 
     assertThat(compensatedMessages.isEmpty(), is(true));
diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelope.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelope.java
deleted file mode 100644
index 0087dd7..0000000
--- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelope.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.saga.integration.pack.tests;
-
-import java.util.Arrays;
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-@Entity
-class TxEventEnvelope {
-  @Id
-  @GeneratedValue
-  private long surrogateId;
-
-  private String serviceName;
-  private String instanceId;
-  private Date creationTime;
-  private String globalTxId;
-  private String localTxId;
-  private String parentTxId;
-  private String type;
-  private byte[] payloads;
-
-  private TxEventEnvelope() {
-  }
-
-  String serviceName() {
-    return serviceName;
-  }
-
-  String instanceId() {
-    return instanceId;
-  }
-
-  String globalTxId() {
-    return globalTxId;
-  }
-
-  String localTxId() {
-    return localTxId;
-  }
-
-  String parentTxId() {
-    return parentTxId;
-  }
-
-  String type() {
-    return type;
-  }
-
-  public byte[] payloads() {
-    return payloads;
-  }
-
-  @Override
-  public String toString() {
-    return "TxEventEnvelope{" +
-        "surrogateId=" + surrogateId +
-        ", serviceName='" + serviceName + '\'' +
-        ", instanceId='" + instanceId + '\'' +
-        ", creationTime=" + creationTime +
-        ", globalTxId='" + globalTxId + '\'' +
-        ", localTxId='" + localTxId + '\'' +
-        ", parentTxId='" + parentTxId + '\'' +
-        ", type='" + type + '\'' +
-        ", payloads=" + Arrays.toString(payloads) +
-        '}';
-  }
-}
diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java
index 5400d7c..77bcb8f 100644
--- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java
+++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java
@@ -19,12 +19,13 @@ package org.apache.servicecomb.saga.integration.pack.tests;
 
 import java.util.List;
 
+import org.apache.servicecomb.saga.alpha.core.TxEvent;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
 
-interface TxEventEnvelopeRepository extends CrudRepository<TxEventEnvelope, Long> {
-  List<TxEventEnvelope> findByGlobalTxIdOrderByCreationTime(String globalTxId);
+interface TxEventEnvelopeRepository extends CrudRepository<TxEvent, Long> {
+  List<TxEvent> findByGlobalTxIdOrderByCreationTime(String globalTxId);
 
-  @Query("SELECT DISTINCT(e.globalTxId) from TxEventEnvelope e")
+  @Query("SELECT DISTINCT(e.globalTxId) from TxEvent e")
   List<String> findDistinctGlobalTxId();
 }
diff --git a/integration-tests/pack-tests/src/test/resources/application.yaml b/integration-tests/pack-tests/src/test/resources/application.yaml
index a7ed531..34b72c3 100644
--- a/integration-tests/pack-tests/src/test/resources/application.yaml
+++ b/integration-tests/pack-tests/src/test/resources/application.yaml
@@ -18,10 +18,4 @@ spring:
   datasource:
     username: saga
     password: password
-    driver-class-name: com.mysql.jdbc.Driver
-  jpa:
-    properties:
-      hibernate:
-        dialect: org.hibernate.dialect.MySQL5Dialect
-    hibernate:
-      ddl-auto: none
+    driver-class-name: org.postgresql.Driver

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.