Jean-Francois Leveque

Etat avec problème d'import Hibernate, cf. https://tree.taiga.io/project/jr-utily-grog-v3/task/184

tee creeV3Country.log
create table Country (
countryId int(11) NOT NULL AUTO_INCREMENT,
countryName varchar(100) DEFAULT NULL,
PRIMARY KEY ('countryId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into Country (countryId, countryName)
select ID_PAYS, LIB_PAYS from pays;
show create table Country;
\ No newline at end of file
source normalisePays.sql
source creeV3Country.sql
source creeV3Publisher+Version+Action.sql
\ No newline at end of file
source normalizePays.sql
source populateV3Country.sql
source populateV3Publisher+Version+Action.sql
\ No newline at end of file
......
tee normalisePays.log
CREATE TABLE pays (
ID_PAYS int(11) NOT NULL AUTO_INCREMENT,
LIB_PAYS varchar(100) DEFAULT NULL,
PRIMARY KEY (ID_PAYS)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
insert into pays select * from v2.pays;
CREATE TABLE editeur (
ID_EDITEUR int(11) NOT NULL AUTO_INCREMENT,
NOM_EDITEUR varchar(50) NOT NULL,
ADR_EDITEUR varchar(300) DEFAULT NULL,
CP_EDITEUR varchar(15) DEFAULT NULL,
VILLE varchar(50) DEFAULT NULL,
PAYS varchar(50) DEFAULT NULL,
TEL_EDITEUR varchar(25) DEFAULT NULL,
EMAIL_EDITEUR varchar(50) DEFAULT NULL,
URL_EDITEUR varchar(100) DEFAULT NULL,
STATUT_EDITEUR varchar(50) DEFAULT NULL,
IND_AMATEUR bit(1) DEFAULT NULL,
HISTORIQUE longtext,
ID_JOURNALISABLE int(11) DEFAULT NULL,
ID_LINKABLE int(11) DEFAULT NULL,
PRIMARY KEY (ID_EDITEUR)
) ENGINE=InnoDB AUTO_INCREMENT=3267 DEFAULT CHARSET=utf8;
insert into editeur select * from v2.editeur;
-- PREPARATION TABLE editeur
-- Standardisation des valeurs de PAYS dans editeur
update editeur set PAYS='Allemagne' where PAYS in ('Deutschland');
......
tee populateV3Country.log
insert into Country (countryId, countryName)
select ID_PAYS, LIB_PAYS from pays;
\ No newline at end of file
tee creeV3Publisher+Version+Action.log
tee populateV3Publisher+Version+Action.log
SET foreign_key_checks = 0;
create table Publisher (
publisherId int(11) NOT NULL AUTO_INCREMENT,
validatedVersion_publisherVersionId int(11),
PRIMARY KEY ('publisherId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into Publisher (publisherId, validatedVersion_publisherVersionId)
select ID_EDITEUR, ID_EDITEUR from editeur;
create table PublisherVersion (
publisherVersionId int(11) NOT NULL AUTO_INCREMENT,
publisher_publisherId int(11) NOT NULL,
publisherName varchar(50) NOT NULL,
publisherStreetAddress varchar(300),
publisherPostalCode varchar(15),
publisherPostOfficeBoxNumber varchar(50),
publisherAddressRegion varchar(50),
publisherAddressLocality varchar(50),
publisherAddressCountry_countryId int(11),
publisherTelephone varchar(25),
publisherEmail varchar(50),
publisherURL varchar(100),
publisherHistory longtext,
publisherVersionAuthor_userId int(11),
publisherVersionDatetime DATETIME,
PRIMARY KEY ('publisherVersionId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into PublisherVersion (publisherVersionId, publisher_publisherId,
publisherName, publisherStreetAddress, publisherPostalCode,
publisherPostOfficeBoxNumber, publisherAddressRegion,
......@@ -41,8 +16,8 @@ select ID_EDITEUR, ID_EDITEUR, NOM_EDITEUR, ADR_EDITEUR, CP_EDITEUR, NULL,
HISTORIQUE, ID_UTILISATEUR, DATE_ACTION
from editeur e
left join Country on countryName = e.PAYS
join journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from journal j2
join v2.journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from v2.journal j2
where j2.ID_JOURNALISABLE = e.ID_EDITEUR)
union
select ID_EDITEUR, ID_EDITEUR, NOM_EDITEUR, ADR_EDITEUR, CP_EDITEUR, NULL,
......@@ -50,33 +25,17 @@ select ID_EDITEUR, ID_EDITEUR, NOM_EDITEUR, ADR_EDITEUR, CP_EDITEUR, NULL,
HISTORIQUE, null, null
from editeur e
left join Country on countryName = e.PAYS
where ID_EDITEUR not in (select distinct ID_JOURNALISABLE from journal)
where ID_EDITEUR not in (select distinct ID_JOURNALISABLE from v2.journal)
;
create table PublisherAction (
publisherActionId int(11) NOT NULL AUTO_INCREMENT,
ActionType TINYINT UNSIGNED NOT NULL,
publisherActionAuthor_userId int(11) NOT NULL,
publisherVersion_publisherVersionId int(11) NOT NULL,
publisherActionDatetime DATETIME,
publisher_publisherId int(11) NOT NULL,
PRIMARY KEY ('publisherActionId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into PublisherAction (ActionType, publisherActionAuthor_userId,
publisherVersion_publisherVersionId, publisherActionDatetime,
publisher_publisherId)
select 0, ID_UTILISATEUR, ID_EDITEUR, DATE_ACTION, ID_EDITEUR
from editeur e
join journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from journal j2
join v2.journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from v2.journal j2
where j2.ID_JOURNALISABLE = e.ID_EDITEUR)
;
SET foreign_key_checks = 1;
\ No newline at end of file
show create table Publisher;
show create table PublisherVersion;
show create table PublisherAction;
\ No newline at end of file
......
......@@ -15,7 +15,7 @@ public class JpaConfiguration {
*/
@Produces
@RequestScoped
@PersistenceContext(unitName = "development-pu")
@PersistenceContext(unitName = "migration-pu")
public EntityManager entityManager;
}
......
......@@ -25,8 +25,8 @@
<property name="hibernate.connection.CharSet" value="utf8"/>
<property name="hibernate.connection.characterEncoding" value="utf8"/>
<property name="hibernate.connection.useUnicode" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="javax.persistence.hibernate.hbm2ddl.import_files" value=""/>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="javax.persistence.hibernate.hbm2ddl.import_files" value="nothing.sql"/>
<property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
<!-- DDL control OFF
<property name="hibernate.show_sql" value="true"/>
......@@ -43,7 +43,6 @@
<property name="hibernate.connection.CharSet" value="utf8"/>
<property name="hibernate.connection.characterEncoding" value="utf8"/>
<property name="hibernate.connection.useUnicode" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="javax.persistence.hibernate.hbm2ddl.import_files" value=""/>
<property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
<!-- DDL control OFF
......
......@@ -22,7 +22,8 @@ INSERT INTO Country (countryId, countryName) VALUES
(20, 'Japon'),
(21, 'Corée du Sud'),
(22, 'Pays-Bas'),
(23, 'Hongrie');
(23, 'Hongrie'),
(24, 'Tatooine');
INSERT INTO Account (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible,
criticProvider) VALUES
(1, '1', null, '1f', '1l', '1n', '1@raza.org', TRUE, TRUE, TRUE, TRUE),
......