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.


❌ Problem: Illegal Mapping of List<String> in @Column

JPA (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.


✅ Solutions

You have a few proper approaches depending on your use case:


🔹 Option 1: Use @ElementCollection

If 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.


🔹 Option 2: Serialize to a Single Column (e.g., comma-separated or JSON)

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: