I want to create a hibernate table which can store a list of values. I am doing something like:
@Column(name = "userHobbies")
@ElementCollection(targetClass = String.class)
@CollectionTable(schema = "school", name = "hobby", joinColumns = @JoinColumn(name = "id"))
private List<String> userHobbies= null;
In the table User I do not see a column "userHobbies". A table hobby is created though which is empty. Can anyone suggest something regarding how to tackle such cases, please?
EDIT:
Code to insert new records to User with hobbies:
ArrayList<String> hobbies= new ArrayList<String>();
hobbies.add(football);
hobbies.add(soccer);
User user = new User();
user.setName("ben");
user.setEmail("[email protected]");
user.setUserHobbies(hobbies);
getDAO().makePersistent(user);
Except the userHobbies all other fields are saved correctly.