Skip to content

Commit

Permalink
wip spring/hibernate-6 migration writer API
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Oct 23, 2023
1 parent 7200f70 commit 0b18f2b
Show file tree
Hide file tree
Showing 31 changed files with 246 additions and 300 deletions.
2 changes: 0 additions & 2 deletions dc-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ SPDX-License-Identifier: CC0-1.0
<description>Data Collector Interface for the Open Data Hub</description>

<properties>
<spring.version>6.0.13</spring.version>
<spring.security.version>6.1.4</spring.security.version>
</properties>

Expand All @@ -45,7 +44,6 @@ SPDX-License-Identifier: CC0-1.0
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.projectreactor.netty/reactor-netty -->
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions dto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ SPDX-License-Identifier: GPL-3.0-only
<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<version>4.0.1</version>
<version>4.3.0</version>
</dependency>

<!-- API Model Annotations in DTOs -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<version>2.10.5</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Map;
import java.util.Set;

import javax.persistence.Entity;
import jakarta.persistence.Entity;

import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SPDX-License-Identifier: CC0-1.0
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.12</version>
<version>3.1.4</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
Expand All @@ -30,7 +30,7 @@ SPDX-License-Identifier: CC0-1.0
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>
<log4j2.version>2.17.1</log4j2.version>
<log4j2.version>2.21.0</log4j2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dependency.locations.enabled>false</dependency.locations.enabled>
</properties>
Expand All @@ -53,7 +53,7 @@ SPDX-License-Identifier: CC0-1.0
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.3</version>
<version>7.4</version>
</dependency>

<!-- Testing -->
Expand Down
50 changes: 22 additions & 28 deletions writer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ SPDX-License-Identifier: CC0-1.0

<properties>
<finalName>writer</finalName>
<geotools.version>20.5</geotools.version>
<hibernate.version>5.5.9.Final</hibernate.version>
<geotools.version>30.0</geotools.version>
<hibernate.version>6.3.1.Final</hibernate.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>21.0.1</version>
<version>22.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -57,6 +57,10 @@ SPDX-License-Identifier: CC0-1.0
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand All @@ -79,7 +83,7 @@ SPDX-License-Identifier: CC0-1.0
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jsonSchema</artifactId>
<version>2.10.2</version>
<version>2.15.3</version>
</dependency>

<!-- Data Transport Objects (see dto folder) -->
Expand All @@ -97,17 +101,12 @@ SPDX-License-Identifier: CC0-1.0

<!-- Hibernate: ORM with spatial entity support (Postgis, Geometry, ...) -->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>${hibernate.version}</version>
</dependency>
Expand All @@ -117,21 +116,21 @@ SPDX-License-Identifier: CC0-1.0
for example provenance records.
-->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>${hibernate.version}</version>
</dependency>

<!-- Hibernate: Rangetype support-->
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-55</artifactId>
<version>2.14.0</version>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-utils-hibernate-62</artifactId>
<version>3.6.0</version>
</dependency>

<!-- Hibernate: Connection pooling -->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>${hibernate.version}</version>
</dependency>
Expand All @@ -147,11 +146,16 @@ SPDX-License-Identifier: CC0-1.0
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
<version>4.4</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
Expand All @@ -167,15 +171,6 @@ SPDX-License-Identifier: CC0-1.0
</dependencies>

<repositories>
<repository>
<id>Hibernate Spatial repo</id>
<url>http://www.hibernatespatial.org/repository</url>
</repository>
<!-- add JBOSS repository for easy access to Hibernate libraries -->
<repository>
<id>JBOSS</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>osgeo-alt</id>
<url>https://repo.osgeo.org/repository/release/</url>
Expand Down Expand Up @@ -205,5 +200,4 @@ SPDX-License-Identifier: CC0-1.0
<id>generator</id>
</profile>
</profiles>

</project>
26 changes: 13 additions & 13 deletions writer/src/main/java/it/bz/idm/bdp/dal/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;

import org.hibernate.annotations.ColumnDefault;

Expand Down
25 changes: 10 additions & 15 deletions writer/src/main/java/it/bz/idm/bdp/dal/DataTypeMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@
import java.util.Date;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;

/**
* <p>
Expand All @@ -33,7 +30,6 @@
* @author Patrick Bertolla
*
*/
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
@Entity
@Table(name = "type_metadata")
public class DataTypeMetaData {
Expand All @@ -44,8 +40,7 @@ public class DataTypeMetaData {
@ColumnDefault(value = "nextval('type_metadata_seq')")
protected Long id;

@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
@JdbcTypeCode(SqlTypes.JSON)
private Map<String, Object> json;

@ManyToOne
Expand Down
18 changes: 9 additions & 9 deletions writer/src/main/java/it/bz/idm/bdp/dal/Edge.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

package it.bz.idm.bdp.dal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import org.hibernate.annotations.ColumnDefault;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LineString;
Expand Down
39 changes: 16 additions & 23 deletions writer/src/main/java/it/bz/idm/bdp/dal/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,28 @@
import java.util.List;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import javax.persistence.Column;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.Range;

import io.hypersistence.utils.hibernate.type.range.PostgreSQLRangeType;
import io.hypersistence.utils.hibernate.type.range.Range;
import it.bz.idm.bdp.dal.util.QueryBuilder;
import it.bz.idm.bdp.dto.EventDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;

@Table(
name = "event",
Expand All @@ -44,10 +41,6 @@
}
)
@Entity
@TypeDef(
typeClass = PostgreSQLRangeType.class,
defaultForType = Range.class
)
public class Event {

private static WKTReader wktReader = new WKTReader(Station.geometryFactory);
Expand Down Expand Up @@ -93,6 +86,7 @@ public void setEventSeriesUuid(String eventSeriesId) {

private Date createdOn;

@Type(PostgreSQLRangeType.class)
private Range<LocalDateTime> eventInterval;

@ManyToOne
Expand All @@ -105,7 +99,6 @@ public void setEventSeriesUuid(String eventSeriesId) {
private Provenance provenance;

@Lob
@Type(type = "org.hibernate.type.TextType")
private String description;

public Provenance getProvenance() {
Expand Down
Loading

0 comments on commit 0b18f2b

Please sign in to comment.