Reputation: 334
I have a class with embeddable annotation and, when I try to pass an instance to an entity, I get an exception:
org.hibernate.InstantiationException: No default constructor for entity: : entity.D3
enum Figure {
SQUARE, TRIANGLE
};
@Embeddable
public class D3 {
float z;
@Enumerated(EnumType.STRING)
Figure figure;
public D3(float z, Figure f) {
this.z = z;
this.figure = f;
}
}
Upvotes: 1
Views: 3450
Reputation: 54781
It's looking for a default constructor (i.e. parameterless), in addition to any you have defined:
@Embeddable
public class D3 {
float z;
@Enumerated(EnumType.STRING)
Figure figure;
public D3() { //I've added this
}
public D3(float z, Figure f) {
this.z = z;
this.figure = f;
}
}
Upvotes: 1