recipients; "> recipients; "> recipients; ">
@Column(name = "recipients", columnDefinition = "text[]", nullable = false)
private List<String> recipients;

This won’t work out-of-the-box with plain JPA, unless you tell Hibernate how to map it.We will give you the three possible solutions.


✅ Option A: @ElementCollection (portable, join table)

This works across all databases and stores recipients in a separate table:

@ElementCollection
@CollectionTable(
    name = "email_configs_recipients",
    joinColumns = @JoinColumn(name = "email_config_id")
)
@Column(name = "recipient", nullable = false)
private List<String> recipients;

👉 Will create a table email_config_recipients with:


✅ Option B: PostgreSQL Array

If you’re using Postgres and want a single column:

@Column(name = "recipients", columnDefinition = "text[]", nullable = false)
@JdbcTypeCode(SqlTypes.ARRAY)
private List<String> recipients;


✅ Option C: JSON (Postgres jsonb)

If you want max flexibility and don’t need to query individual emails:

@Column(name = "recipients", columnDefinition = "jsonb", nullable = false)
@JdbcTypeCode(SqlTypes.JSON)
private List<String> recipients;