From 1d0d2372ea4eaac202a7ba169cacb3f37e040db3 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 27 Oct 2022 09:42:18 +0200 Subject: [PATCH] use simple @GeneratedValue and some code cleanup --- .../RestResponseEntityExceptionHandler.java | 2 +- .../bankaccount/HsOfficeBankAccountEntity.java | 3 +-- .../HsOfficeCoopSharesTransactionEntity.java | 10 ++++------ .../office/debitor/HsOfficeDebitorEntity.java | 6 +++--- .../membership/HsOfficeMembershipEntity.java | 17 +++++++++-------- .../partner/HsOfficePartnerDetailsEntity.java | 6 ++---- .../office/partner/HsOfficePartnerEntity.java | 12 +++++------- .../hs/office/person/HsOfficePersonEntity.java | 6 ++---- .../HsOfficeRelationshipEntity.java | 8 +++----- .../sepamandate/HsOfficeSepaMandateEntity.java | 10 ++++------ .../hsadminng/test/cust/TestCustomerEntity.java | 7 +++---- .../hsadminng/test/pac/TestPackageEntity.java | 4 +--- 12 files changed, 38 insertions(+), 53 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/errors/RestResponseEntityExceptionHandler.java b/src/main/java/net/hostsharing/hsadminng/errors/RestResponseEntityExceptionHandler.java index 15cb817c..fdeee405 100644 --- a/src/main/java/net/hostsharing/hsadminng/errors/RestResponseEntityExceptionHandler.java +++ b/src/main/java/net/hostsharing/hsadminng/errors/RestResponseEntityExceptionHandler.java @@ -86,7 +86,7 @@ public class RestResponseEntityExceptionHandler Optional.ofNullable(response.getBody()).map(Object::toString).orElse(firstMessageLine(exc))); } - //@ExceptionHandler({ MethodArgumentNotValidException.class }) + @Override @SuppressWarnings("unchecked,rawtypes") protected ResponseEntity handleMethodArgumentNotValid( MethodArgumentNotValidException exc, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java index 27d49a6e..da0be7fe 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java @@ -32,8 +32,7 @@ public class HsOfficeBankAccountEntity implements Stringifyable { .withProp(Fields.bic, HsOfficeBankAccountEntity::getBic); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; private String holder; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java index b4d53ee3..c05d0a47 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java @@ -2,11 +2,10 @@ package net.hostsharing.hsadminng.hs.office.coopshares; import com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType; import lombok.*; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; import net.hostsharing.hsadminng.errors.DisplayName; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; -import org.hibernate.annotations.GenericGenerator; +import net.hostsharing.hsadminng.stringify.Stringify; +import net.hostsharing.hsadminng.stringify.Stringifyable; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; @@ -40,8 +39,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @ManyToOne @@ -50,7 +48,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable { @Column(name = "transactiontype") @Enumerated(EnumType.STRING) - @Type( type = "pgsql_enum" ) + @Type(type = "pgsql_enum") private HsOfficeCoopSharesTransactionType transactionType; @Column(name = "valuedate") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 22d9e4aa..ae827649 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -2,11 +2,11 @@ package net.hostsharing.hsadminng.hs.office.debitor; import lombok.*; import net.hostsharing.hsadminng.errors.DisplayName; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.stringify.Stringify; +import net.hostsharing.hsadminng.stringify.Stringifyable; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; @@ -32,7 +32,7 @@ public class HsOfficeDebitorEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") + @GeneratedValue @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") private UUID uuid; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java index ce26e843..d887e358 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java @@ -9,11 +9,12 @@ import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; import net.hostsharing.hsadminng.stringify.Stringify; import net.hostsharing.hsadminng.stringify.Stringifyable; -import org.hibernate.annotations.*; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; import javax.persistence.*; -import javax.persistence.Entity; -import javax.persistence.Table; import java.time.LocalDate; import java.util.UUID; @@ -48,8 +49,7 @@ public class HsOfficeMembershipEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @ManyToOne @@ -81,9 +81,10 @@ public class HsOfficeMembershipEntity implements Stringifyable { } public Range getValidity() { - if ( validity == null ) { - validity = Range.infinite(LocalDate.class); - }; + if (validity == null) { + validity = Range.infinite(LocalDate.class); + } + ; return validity; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java index 1e9a0bdd..131fd735 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java @@ -1,10 +1,9 @@ package net.hostsharing.hsadminng.hs.office.partner; import lombok.*; +import net.hostsharing.hsadminng.errors.DisplayName; import net.hostsharing.hsadminng.stringify.Stringify; import net.hostsharing.hsadminng.stringify.Stringifyable; -import net.hostsharing.hsadminng.errors.DisplayName; -import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import java.time.LocalDate; @@ -34,8 +33,7 @@ public class HsOfficePartnerDetailsEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; private @Column(name = "registrationoffice") String registrationOffice; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java index 1c2372b5..b4ddfcd7 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java @@ -2,11 +2,10 @@ package net.hostsharing.hsadminng.hs.office.partner; import lombok.*; import net.hostsharing.hsadminng.errors.DisplayName; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; -import org.hibernate.annotations.GenericGenerator; +import net.hostsharing.hsadminng.stringify.Stringify; +import net.hostsharing.hsadminng.stringify.Stringifyable; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; @@ -32,8 +31,7 @@ public class HsOfficePartnerEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @ManyToOne @@ -44,9 +42,9 @@ public class HsOfficePartnerEntity implements Stringifyable { @JoinColumn(name = "contactuuid", nullable = false) private HsOfficeContactEntity contact; - @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DETACH}, optional = true) + @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DETACH }, optional = true) @JoinColumn(name = "detailsuuid", nullable = true) - @NotFound(action= NotFoundAction.IGNORE) + @NotFound(action = NotFoundAction.IGNORE) private HsOfficePartnerDetailsEntity details; @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java index 5bcda8c3..bb55bde0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java @@ -7,7 +7,6 @@ import net.hostsharing.hsadminng.errors.DisplayName; import net.hostsharing.hsadminng.stringify.Stringify; import net.hostsharing.hsadminng.stringify.Stringifyable; import org.apache.commons.lang3.StringUtils; -import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; @@ -38,13 +37,12 @@ public class HsOfficePersonEntity implements Stringifyable { .withProp(Fields.givenName, HsOfficePersonEntity::getGivenName); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @Column(name = "persontype") @Enumerated(EnumType.STRING) - @Type( type = "pgsql_enum" ) + @Type(type = "pgsql_enum") private HsOfficePersonType personType; @Column(name = "tradename") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipEntity.java index 71bebadd..89b2926c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipEntity.java @@ -3,10 +3,9 @@ package net.hostsharing.hsadminng.hs.office.relationship; import com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType; import lombok.*; import lombok.experimental.FieldNameConstants; -import net.hostsharing.hsadminng.stringify.Stringify; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; -import org.hibernate.annotations.GenericGenerator; +import net.hostsharing.hsadminng.stringify.Stringify; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; @@ -36,8 +35,7 @@ public class HsOfficeRelationshipEntity { .withProp(Fields.contact, HsOfficeRelationshipEntity::getContact); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @ManyToOne @@ -54,7 +52,7 @@ public class HsOfficeRelationshipEntity { @Column(name = "reltype") @Enumerated(EnumType.STRING) - @Type( type = "pgsql_enum" ) + @Type(type = "pgsql_enum") private HsOfficeRelationshipType relType; @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java index 84572f2a..a4120d8e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java @@ -4,11 +4,10 @@ import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType; import com.vladmihalcea.hibernate.type.range.Range; import lombok.*; import net.hostsharing.hsadminng.errors.DisplayName; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity; import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; -import org.hibernate.annotations.GenericGenerator; +import net.hostsharing.hsadminng.stringify.Stringify; +import net.hostsharing.hsadminng.stringify.Stringifyable; import org.hibernate.annotations.TypeDef; import javax.persistence.*; @@ -39,8 +38,7 @@ public class HsOfficeSepaMandateEntity implements Stringifyable { .quotedValues(false); @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @ManyToOne @@ -53,7 +51,7 @@ public class HsOfficeSepaMandateEntity implements Stringifyable { private @Column(name = "reference") String reference; - @Column(name="validity", columnDefinition = "daterange") + @Column(name = "validity", columnDefinition = "daterange") private Range validity; @Override diff --git a/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntity.java b/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntity.java index 2b985d5b..8c11ea58 100644 --- a/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntity.java @@ -4,7 +4,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import java.util.UUID; @@ -16,14 +15,14 @@ import java.util.UUID; @NoArgsConstructor @AllArgsConstructor public class TestCustomerEntity { + @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; private String prefix; private int reference; - @Column(name="adminusername") + @Column(name = "adminusername") private String adminUserName; } diff --git a/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java index 81b848f1..0576ca38 100644 --- a/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java @@ -5,7 +5,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import net.hostsharing.hsadminng.test.cust.TestCustomerEntity; -import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import java.util.UUID; @@ -19,8 +18,7 @@ import java.util.UUID; public class TestPackageEntity { @Id - @GeneratedValue(generator = "UUID") - @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + @GeneratedValue private UUID uuid; @Version