Reputation: 51
In an Entity class, I have a field as: @Column(name = "alias", length = 255) private List<String> akaList;
When it's run, I have an error:
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.List, at table: customer, for columns: [org.hibernate.mapping.Column(alias)]
What could be the reason?
Upvotes: 0
Views: 314
Reputation: 7905
Add the following annotation: @ElementCollection(fetch = FetchType.EAGER)
in addition to @Column
. Usually you address this kind of relationships with @OneToMany
association. The element collection might seem easier to use than an entity with @OneToMany
association. But it has one major drawback: The elements of the collection have no id and Hibernate can’t address them individually.
@ElementCollection(fetch = FetchType.EAGER)
@Column(name = "alias", length = 255)
private List<String> akaList;
Upvotes: 1