I am trying to save multiple strings into one column into MySQL DB. Using Spring Data JPA with Hibernate.
I have my PersonserviceImpl as
@Override
public void createnewPerson(AppPerson appPerson) {
List<AppPersonproperty> personProperties = personpropertyRepository
.findByPersonid(appPerson.getAppPersontype().getId());
for (AppPersonproperty app : personProperties) {
System.out.println(app.getPersonpropertyname());
entity.setPersonpropertyname(app.getPersonpropertyname());
}
personRepository.save(entity);
}
Only the last value gets save from Person's previous names.
Sysout:
SpiderMan
Spidey
Expected value in the column:
SpiderManSpidey
Actual value in the column:
Spidey
What am I doing wrong here?