Skip to content

NM-27: Port CatalogItem entity to JPA#11

Open
devin-ai-integration[bot] wants to merge 1 commit into
devin/1779383558-nm26-catalog-brand-type-entitiesfrom
devin/1779475951-nm27-catalog-item-entity
Open

NM-27: Port CatalogItem entity to JPA#11
devin-ai-integration[bot] wants to merge 1 commit into
devin/1779383558-nm26-catalog-brand-type-entitiesfrom
devin/1779475951-nm27-catalog-item-entity

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Ports the CatalogItem entity from eShopLegacyMVC/Models/CatalogItem.cs to a JPA entity at eShopModernizedSpringSolution/src/main/java/com/eshop/modernized/model/CatalogItem.java.

Property mappings from .NET → Java:

.NET Java Notes
Id (int) @Id Integer No @GeneratedValue — HiLo handled externally
Name ([Required]) @NotBlank @Size(max=50) String
Description String
Price (decimal, [Range], [RegularExpression]) @NotNull @DecimalMin("0") @DecimalMax("1000000") @Digits(integer=16, fraction=2) BigDecimal @Column(precision=18, scale=2)
PictureFileName String Default "dummy.png" in constructor
PictureUri @Transient String Not persisted
CatalogTypeId / CatalogType @ManyToOne @JoinColumn FK with read-only ID field
CatalogBrandId / CatalogBrand @ManyToOne @JoinColumn FK with read-only ID field
AvailableStock ([Range(0,10000000)]) @Min(0) @Max(10000000) int
RestockThreshold ([Range(0,10000000)]) @Min(0) @Max(10000000) int
MaxStockThreshold ([Range(0,10000000)]) @Min(0) @Max(10000000) int
OnReorder (bool) boolean

Validation mapping: [Required]@NotBlank/@NotNull, [Range(0,1000000)]@DecimalMin/@DecimalMax, [RegularExpression]@Digits (since @Pattern only applies to CharSequence, @Digits(integer=16, fraction=2) enforces the same max-2-decimal-places constraint).

Review & Testing Checklist for Human

  • Verify all validation annotations match the .NET DataAnnotations semantics (especially @Digits replacing @Pattern for BigDecimal price)
  • Confirm @ManyToOne relationships to CatalogBrand and CatalogType are correctly mapped with @JoinColumn
  • Verify the entity compiles: cd eShopModernizedSpringSolution && ./mvnw compile

Notes

  • GenerationType.NONE does not exist in JPA; omitting @GeneratedValue entirely is the standard way to indicate externally-managed IDs
  • @Pattern cannot be applied to BigDecimal in Bean Validation — used @Digits(integer=16, fraction=2) as the idiomatic Java equivalent of the C# regex ^\d+(\.\d{0,2})*$
  • FK ID fields (catalogTypeId, catalogBrandId) are mapped as read-only (insertable=false, updatable=false) alongside the @ManyToOne relationships, with setter methods that sync both

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/63d968161a234c72b753581a3664dcd6

Map all properties from eShopLegacyMVC CatalogItem.cs:
- @id without @GeneratedValue (HiLo handled externally)
- Price as BigDecimal with @column(precision=18, scale=2)
- @DecimalMin/@DecimalMax for Price range validation
- @digits(integer=16, fraction=2) for decimal precision (replaces .NET RegularExpression)
- @notblank @SiZe(max=50) on Name
- @manytoone @joincolumn for CatalogBrand and CatalogType
- @transient for PictureUri
- @Min/@max for stock threshold fields
- Default pictureFileName = "dummy.png" in constructor
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants