diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java index c12b28f0c3cdcc5e6aad280785e9cc5257c93d78..d13a3373899ac7b6bc23add6d7f0c444e3ce71b5 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java @@ -14,6 +14,7 @@ package eu.europa.ec.edelivery.smp.data.model; import eu.europa.ec.edelivery.smp.data.dao.utils.ColumnDescription; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.Audited; import javax.persistence.*; @@ -53,8 +54,8 @@ import javax.persistence.*; public class DBDomain extends BaseEntity { @Id - @SequenceGenerator(name = "domain_generator", sequenceName = "SMP_DOMAIN_SEQ", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "domain_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_DOMAIN_SEQ") + @GenericGenerator(name = "SMP_DOMAIN_SEQ", strategy = "native") @Column(name = "ID") @ColumnDescription(comment = "Unique domain id") Long id; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBRevisionLog.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBRevisionLog.java index ed0cc45e3f6f4db53aa0c8053075be9547570b1c..a69d8b00bbd490a906cf60956068b13ee9798a80 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBRevisionLog.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBRevisionLog.java @@ -2,6 +2,7 @@ package eu.europa.ec.edelivery.smp.data.model; import eu.europa.ec.edelivery.smp.data.dao.SMPRevisionListener; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.RevisionEntity; import org.hibernate.envers.RevisionNumber; import org.hibernate.envers.RevisionTimestamp; @@ -20,10 +21,9 @@ import java.time.LocalDateTime; @RevisionEntity(SMPRevisionListener.class) public class DBRevisionLog { - @Id - @SequenceGenerator(name="revision_generator", sequenceName = "SMP_REVISION_SEQ", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "revision_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_REVISION_SEQ") + @GenericGenerator(name = "SMP_REVISION_SEQ", strategy = "native") @RevisionNumber private long id; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroup.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroup.java index 2f67ecaa6e20a9c68a267e46f249960fc55b3dc3..f277f8dfb9d4c8827fb2b6dabbf6e574a7bb7986 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroup.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroup.java @@ -14,6 +14,7 @@ package eu.europa.ec.edelivery.smp.data.model; import eu.europa.ec.edelivery.smp.data.dao.utils.ColumnDescription; import org.apache.commons.lang3.StringUtils; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.Audited; import javax.persistence.*; @@ -42,10 +43,10 @@ import java.util.*; public class DBServiceGroup extends BaseEntity { @Id - @SequenceGenerator(name = "sg_generator", sequenceName = "SMP_SERVICE_GROUP_SEQ", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sg_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_SERVICE_GROUP_SEQ") + @GenericGenerator(name = "SMP_SERVICE_GROUP_SEQ", strategy = "native") @Column(name = "ID") - @ColumnDescription(comment = "Unique Servicegroup id") + @ColumnDescription(comment = "Unique ServiceGroup id") Long id; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroupDomain.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroupDomain.java index 77274937b1d93829d8f83b8fbed2d4fca63c1c76..e2fb664670736fddcdebe6f964ed6daf57b15259 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroupDomain.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceGroupDomain.java @@ -1,5 +1,6 @@ package eu.europa.ec.edelivery.smp.data.model; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.Audited; import javax.persistence.*; @@ -33,8 +34,8 @@ import java.util.Objects; public class DBServiceGroupDomain extends BaseEntity { @Id - @SequenceGenerator(name = "sgd_generator", sequenceName = "SMP_SERVICE_GROUP_DOMAIN_SEQ", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sgd_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_SERVICE_GROUP_DOMAIN_SEQ") + @GenericGenerator(name = "SMP_SERVICE_GROUP_DOMAIN_SEQ", strategy = "native") @Column(name = "ID") Long id; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceMetadata.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceMetadata.java index 6204096472619ad75c737bfbff185f800db1f837..289fcd5a9ad83a27d7b54f2521e3dd54a5391b78 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceMetadata.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBServiceMetadata.java @@ -14,6 +14,7 @@ package eu.europa.ec.edelivery.smp.data.model; import eu.europa.ec.edelivery.smp.data.dao.utils.ColumnDescription; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.Audited; import javax.persistence.*; @@ -44,8 +45,8 @@ import java.util.Objects; public class DBServiceMetadata extends BaseEntity { @Id - @SequenceGenerator(name = "sgmd_generator", sequenceName = "SMP_SERVICE_METADATA_SEQ",allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sgmd_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_SERVICE_METADATA_SEQ") + @GenericGenerator(name = "SMP_SERVICE_METADATA_SEQ", strategy = "native") @Column(name = "ID") @ColumnDescription(comment = "Shared primary key with master table SMP_SERVICE_METADATA") Long id; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBUser.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBUser.java index 31e4480bc9eef1be28496c924b3baaaab1200308..14594696bae33a76bf7c069e1cc2f623ee746c51 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBUser.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBUser.java @@ -14,6 +14,7 @@ package eu.europa.ec.edelivery.smp.data.model; import eu.europa.ec.edelivery.smp.data.dao.utils.ColumnDescription; import org.apache.commons.lang3.StringUtils; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.envers.Audited; import javax.persistence.*; @@ -52,8 +53,8 @@ import java.util.Objects; public class DBUser extends BaseEntity { @Id - @SequenceGenerator(name = "usr_generator", sequenceName = "SMP_USER_SEQ", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "usr_generator") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SMP_USER_SEQ") + @GenericGenerator(name = "SMP_USER_SEQ", strategy = "native") @Column(name = "ID") @ColumnDescription(comment = "Unique user id") Long id; diff --git a/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql b/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql index cfdd660d6765aac88698bf0e1b5cf522e6161c28..b2cf07e7fb3fbc086cc8cbca5f604e40625d6ee7 100644 --- a/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql +++ b/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql @@ -43,9 +43,6 @@ insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, VALID_FROM, VALID_TO, CREATED_O insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPDATED_ON) values (21, 'blue_gw', '', 'SERVICE_GROUP_ADMIN', 1, NOW(), NOW()); insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, VALID_FROM, VALID_TO, CREATED_ON, LAST_UPDATED_ON) values (21, 'CN=blue_gw,O=eDelivery,C=BE:e07b6b956330a19a', null,null, NOW(), NOW()); -update SMP_USER_SEQ set next_val=100 where next_val=1; - - -- insert domain insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON, SML_CLIENT_CERT_HEADER) values (1, 'domain','','CEF-SMP-002', 'sample_key','sample_key', 1,0, NOW(), NOW(),'sno=1&subject=CN=SMP_TEST-PRE-SET-EXAMPLE, OU=eDelivery, O=DIGITAL, C=BE&validfrom=Dec 6 17:41:42 2016 GMT&validto=Jul 9 23:59:00 2050 GMT&issuer=CN=rootCNTest,OU=B4,O=DIGIT,L=Brussels,ST=BE,C=BE'); @@ -62,6 +59,3 @@ insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KE insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (11, 'domainK','subdomain011', 'CEF-SMP-011','sample_key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP()); insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (12, 'domainL','subdomain012', 'CEF-SMP-012','sample_key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP()); - -insert into SMP_ALERT (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (12, 'domainL','subdomain012', 'CEF-SMP-012','sample_key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP()); - diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql index b1b95b8a3f434c7945fb87c4bc81f68612848d12..6fa387b1f2810e0c03b3fc3d39b884123cad7fd9 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql @@ -2,9 +2,7 @@ insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPD insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPDATED_ON) values (2, 'smp', '$2a$06$FDmjewn/do3C219uysNm9.XG8mIn.ubHnMydAzC8lsv61HsRpOR36', 'SMP_ADMIN', 1, NOW(), NOW()); insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPDATED_ON) values (3, 'user', '$2a$06$FDmjewn/do3C219uysNm9.XG8mIn.ubHnMydAzC8lsv61HsRpOR36', 'SERVICE_GROUP_ADMIN', 1, NOW(), NOW()); -update SMP_USER_SEQ set next_val=4; - -- insert domain insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (1, 'testDomain','test','CEF-SMP-002', 'sample_key', 1,0, NOW(), NOW()); -update SMP_USER_SEQ set next_val=2; + diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl index 19447e569bb86af4126e51cf7d38b1b86c2ed6bc..7c739984eeeb827cbae0340e8c92b1a335a0bb9f 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl @@ -95,16 +95,12 @@ drop table if exists SMP_DOMAIN_AUD; - drop table if exists SMP_DOMAIN_SEQ; - drop table if exists SMP_OWNERSHIP; drop table if exists SMP_OWNERSHIP_AUD; drop table if exists SMP_REV_INFO; - drop table if exists SMP_REVISION_SEQ; - drop table if exists SMP_SERVICE_GROUP; drop table if exists SMP_SERVICE_GROUP_AUD; @@ -113,16 +109,10 @@ drop table if exists SMP_SERVICE_GROUP_DOMAIN_AUD; - drop table if exists SMP_SERVICE_GROUP_DOMAIN_SEQ; - - drop table if exists SMP_SERVICE_GROUP_SEQ; - drop table if exists SMP_SERVICE_METADATA; drop table if exists SMP_SERVICE_METADATA_AUD; - drop table if exists SMP_SERVICE_METADATA_SEQ; - drop table if exists SMP_SERVICE_METADATA_XML; drop table if exists SMP_SERVICE_METADATA_XML_AUD; @@ -134,5 +124,3 @@ drop table if exists SMP_USER; drop table if exists SMP_USER_AUD; - - drop table if exists SMP_USER_SEQ; diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl index f3dca1661c1013ebf7ff065a08c7a4aa0eff6ad4..1cdebaab3fa560ab70aeb96105d0d00b8a5e862d 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl @@ -84,7 +84,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; create table SMP_DOMAIN ( - ID bigint not null comment 'Unique domain id', + ID bigint not null auto_increment comment 'Unique domain id', CREATED_ON datetime not null, LAST_UPDATED_ON datetime not null, DOMAIN_CODE varchar(256) CHARACTER SET utf8 COLLATE utf8_bin not null comment 'Domain code used as http parameter in rest webservices', @@ -117,12 +117,6 @@ primary key (ID, REV) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_DOMAIN_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_DOMAIN_SEQ values ( 1 ); - create table SMP_OWNERSHIP ( FK_SG_ID bigint not null, FK_USER_ID bigint not null, @@ -138,21 +132,15 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; create table SMP_REV_INFO ( - id bigint not null, + id bigint not null auto_increment, REVISION_DATE datetime, timestamp bigint not null, USERNAME varchar(255) CHARACTER SET utf8 COLLATE utf8_bin, primary key (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_REVISION_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_REVISION_SEQ values ( 1 ); - create table SMP_SERVICE_GROUP ( - ID bigint not null comment 'Unique Servicegroup id', + ID bigint not null auto_increment comment 'Unique ServiceGroup id', CREATED_ON datetime not null, LAST_UPDATED_ON datetime not null, PARTICIPANT_IDENTIFIER varchar(256) CHARACTER SET utf8 COLLATE utf8_bin not null, @@ -172,7 +160,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; create table SMP_SERVICE_GROUP_DOMAIN ( - ID bigint not null, + ID bigint not null auto_increment, CREATED_ON datetime not null, LAST_UPDATED_ON datetime not null, SML_REGISTERED bit not null, @@ -193,20 +181,8 @@ primary key (ID, REV) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_SERVICE_GROUP_DOMAIN_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_SERVICE_GROUP_DOMAIN_SEQ values ( 1 ); - - create table SMP_SERVICE_GROUP_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_SERVICE_GROUP_SEQ values ( 1 ); - create table SMP_SERVICE_METADATA ( - ID bigint not null comment 'Shared primary key with master table SMP_SERVICE_METADATA', + ID bigint not null auto_increment comment 'Shared primary key with master table SMP_SERVICE_METADATA', CREATED_ON datetime not null, LAST_UPDATED_ON datetime not null, DOCUMENT_IDENTIFIER varchar(500) CHARACTER SET utf8 COLLATE utf8_bin not null, @@ -227,12 +203,6 @@ primary key (ID, REV) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_SERVICE_METADATA_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_SERVICE_METADATA_SEQ values ( 1 ); - create table SMP_SERVICE_METADATA_XML ( ID bigint not null, CREATED_ON datetime not null, @@ -270,7 +240,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; create table SMP_USER ( - ID bigint not null comment 'Unique user id', + ID bigint not null auto_increment comment 'Unique user id', CREATED_ON datetime not null, LAST_UPDATED_ON datetime not null, ACCESS_TOKEN varchar(256) CHARACTER SET utf8 COLLATE utf8_bin comment 'BCrypted personal access token', @@ -315,12 +285,6 @@ primary key (ID, REV) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_USER_SEQ ( - next_val bigint - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - insert into SMP_USER_SEQ values ( 1 ); - alter table SMP_CERTIFICATE add constraint UK_3x3rvf6hkim9fg16caurkgg6f unique (CERTIFICATE_ID); diff --git a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl index d160ce5e26fe6dcf828071a3cca92cab1f5f0a94..3a4dac348c91be147caabbd10a4a98cd2fe1aed4 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl @@ -240,7 +240,7 @@ create sequence SMP_USER_SEQ start with 1 increment by 1; 'Service group data - Identifier and scheme'; comment on column SMP_SERVICE_GROUP.ID is - 'Unique Servicegroup id'; + 'Unique ServiceGroup id'; create table SMP_SERVICE_GROUP_AUD ( ID number(19,0) not null,