From e9eff35331605bd0e5fb70af6edd5ae406e37efc Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 21 May 2026 17:13:56 +0000 Subject: [PATCH] NM-26: Port CatalogBrand and CatalogType entities to JPA Create model/CatalogBrand.java and model/CatalogType.java with: - @Entity and @Table annotations matching EF6 table names - @Id with GenerationType.IDENTITY - @NotNull and @Size(max=100) matching EF6 Required + MaxLength(100) - @Column constraints mirroring the fluent config in CatalogDBContext.cs - Business-key equals/hashCode per Java best practices --- .../eshop/modernized/model/CatalogBrand.java | 66 +++++++++++++++++++ .../eshop/modernized/model/CatalogType.java | 66 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogBrand.java create mode 100644 eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogType.java diff --git a/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogBrand.java b/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogBrand.java new file mode 100644 index 00000000..c401e669 --- /dev/null +++ b/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogBrand.java @@ -0,0 +1,66 @@ +package com.eshop.modernized.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.util.Objects; + +@Entity +@Table(name = "CatalogBrand") +public class CatalogBrand { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @NotNull + @Size(max = 100) + @Column(nullable = false, length = 100) + private String brand; + + protected CatalogBrand() { + } + + public CatalogBrand(String brand) { + this.brand = brand; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CatalogBrand other)) return false; + return Objects.equals(brand, other.brand); + } + + @Override + public int hashCode() { + return Objects.hash(brand); + } + + @Override + public String toString() { + return brand; + } +} diff --git a/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogType.java b/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogType.java new file mode 100644 index 00000000..31b1b083 --- /dev/null +++ b/eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogType.java @@ -0,0 +1,66 @@ +package com.eshop.modernized.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.util.Objects; + +@Entity +@Table(name = "CatalogType") +public class CatalogType { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @NotNull + @Size(max = 100) + @Column(nullable = false, length = 100) + private String type; + + protected CatalogType() { + } + + public CatalogType(String type) { + this.type = type; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CatalogType other)) return false; + return Objects.equals(type, other.type); + } + + @Override + public int hashCode() { + return Objects.hash(type); + } + + @Override + public String toString() { + return type; + } +}