Thanks for sharing. Based on what you've shown, there’s a critical issue in both MaterialResource and EquipmentResource, and likely in other *Resource classes following the same pattern.
List<String> in @ColumnJPA (Jakarta Persistence API) does not support mapping List<String> directly using @Column. When you write:
java
CopyEdit
@Column(name = "attachment_paths")
private List<String> attachmentPaths;
This will throw a MappingException at runtime or silently fail to persist as expected. JPA expects @Column fields to be scalars (e.g., String, int, boolean, UUID, etc.), not collections.
You have a few proper approaches depending on your use case:
@ElementCollectionIf you want to store the list of attachment URLs or titles as a separate table related to your owning entity:
java
CopyEdit
@ElementCollection
@CollectionTable(name = "material_attachment_paths", joinColumns = @JoinColumn(name = "material_id"))
@Column(name = "attachment_path")
private List<String> attachmentPaths;
@ElementCollection
@CollectionTable(name = "material_attachment_titles", joinColumns = @JoinColumn(name = "material_id"))
@Column(name = "attachment_title")
private List<String> attachmentPathTitles;
Do the same for EquipmentResource, VehicleResource, etc.
💡 Best Practice: Add @OrderColumn(name = "idx") to preserve the order if needed.
If you want to store it in a single column (less normalized), convert the list to a single String. For example:
java
CopyEdit
@Column(name = "attachment_paths")
@Convert(converter = ListToStringConverter.class)
private List<String> attachmentPaths;
And define the converter: