Exception in thread "main" org.hibernate.AnnotationException: - Use of @OneToMany or @ManyToMany targeting an unmapped class:
The problem is in this block:
@Column(name = "addresses")
@OneToMany(mappedBy = "client", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<AddressDataSet> addresses = new ArrayList<>();
You either use @Column
or a@One/ManyToOne/Many
relation. You cannot use both. The first one is for mapping primitive data types. The other one is for entities relations. Remove @Column
and you should be good to go.
Update
You added Client
as annotated class, but not AddressDataSet
. Add it just under the addAnnotatedClass(Client.class)
:
var metadata = new MetadataSources(serviceRegistry)
.addAnnotatedClass(Client.class)
.addAnnotatedClass(AddressDataSet.class)
.getMetadataBuilder()
.build();