hibernate
I have an entity: Factories
@Entity
public class Factories extends BaseEntity {
@Id
@SequenceGenerator(name = "factories_id_seq", sequenceName = "factories_id_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "factories_id_seq")
private Integer id;
@ElementCollection
private Set<String> emails = new HashSet<String>();
//get set...
}
In thymeleaf to add email to factories,
<table id="emailsTable" class="table table-striped table-hover responsive">
<thead>
<tr>
<th th:text="#{value}">Value</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="email, stat : *{emails}">
<td><input type="text" class="form-control" th:placeholder="#{email.placeholder}" placeholder="Name" th:field="*{emails[__${stat.index}__]}" /></td>
<td class="align-middle"><button type="button" class="btn btn-default pull-right delete"><i class="fas fa-trash-alt"></i></button></td>
</tr>
</tbody>
</table>
When I try to save, I get
org.springframework.beans.InvalidPropertyException: Invalid property 'emails[0]' of bean class [com.lcm.model.Factories]: Property referenced in indexed property path 'emails[0]' is neither an array nor a List nor a Map; returned value was [[]]