From cadf7d9cb0fafe053b568b30923308df6a59006c Mon Sep 17 00:00:00 2001 From: tcezard Date: Wed, 27 Mar 2024 11:42:45 +0000 Subject: [PATCH] Use EmbeddedId in ReleaseStatsPerAssemblyV2 --- eva-release/pom.xml | 5 +++- .../models/ReleaseStatsPerAssemblyV2.java | 30 ++++++++----------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/eva-release/pom.xml b/eva-release/pom.xml index 51c2cdf3..a6a942cf 100644 --- a/eva-release/pom.xml +++ b/eva-release/pom.xml @@ -55,7 +55,10 @@ springfox-swagger2 compile - + + io.hypersistence + hypersistence-utils-hibernate-52 + diff --git a/eva-release/src/main/java/uk/ac/ebi/eva/release/models/ReleaseStatsPerAssemblyV2.java b/eva-release/src/main/java/uk/ac/ebi/eva/release/models/ReleaseStatsPerAssemblyV2.java index 69663050..1cc0d2e2 100644 --- a/eva-release/src/main/java/uk/ac/ebi/eva/release/models/ReleaseStatsPerAssemblyV2.java +++ b/eva-release/src/main/java/uk/ac/ebi/eva/release/models/ReleaseStatsPerAssemblyV2.java @@ -15,23 +15,21 @@ */ package uk.ac.ebi.eva.release.models; -import io.hypersistence.utils.hibernate.type.array.IntArrayType; -import io.hypersistence.utils.hibernate.type.array.ListArrayType; import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; import javax.persistence.*; import java.util.Objects; @Entity -@IdClass(ReleaseStatsPerAssemblyV2PK.class) @Table(name = "release_rs_count_per_assembly", schema="eva_stats") public class ReleaseStatsPerAssemblyV2 { - @Id + + @EmbeddedId + ReleaseStatsPerAssemblyV2PK releaseStatsPerAssemblyV2Id; + + @Column(insertable = false, updatable = false) private int releaseVersion; - @Id - private String assemblyAccession; @Type(type = "int-array") @Column( @@ -74,21 +72,19 @@ public void setTaxonomyIds(int[] taxonomyIds) { } public String getAssemblyAccession() { - return assemblyAccession; + return releaseStatsPerAssemblyV2Id.getAssemblyAccession(); } public void setAssemblyAccession(String assemblyAccession) { - this.assemblyAccession = assemblyAccession; + releaseStatsPerAssemblyV2Id.setAssemblyAccession(assemblyAccession); } - - public int getReleaseVersion() { - return releaseVersion; + return releaseStatsPerAssemblyV2Id.getReleaseVersion(); } public void setReleaseVersion(int releaseVersion) { - this.releaseVersion = releaseVersion; + releaseStatsPerAssemblyV2Id.setReleaseVersion(releaseVersion); } @@ -107,7 +103,7 @@ public Long getCurrentRs() { public void setCurrentRs(Long currentRs) { this.currentRs = currentRs; } - + public Long getNewMergedRs() { return newMergedRs; } @@ -185,13 +181,13 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ReleaseStatsPerAssemblyV2 assembly = (ReleaseStatsPerAssemblyV2) o; - return releaseVersion == assembly.releaseVersion && - Objects.equals(assemblyAccession, assembly.assemblyAccession); + return this.getReleaseVersion() == assembly.getReleaseVersion() && + Objects.equals(this.getAssemblyAccession(), assembly.getAssemblyAccession()); } @Override public int hashCode() { - return Objects.hash(assemblyAccession, releaseVersion); + return Objects.hash(this.getAssemblyAccession(), this.getReleaseVersion()); } }