Always when i try to get list of entities from JPA Repository i got exception like this
org.springframework.orm.jpa.JpaSystemException: No default constructor for entity: : pl.hycom.hyper.hyebok.model.ServiceEntity$Id; nested exception is org.hibernate.InstantiationException: No default constructor for entity: : pl.hycom.hyper.hyebok.model.ServiceEntity$Id
What is missing in my entity. I have both non-args constructor and all-args constructor in Embeddable class and outer class. I can't find a solution for this issue.
My entity below
@Entity
@Table(name = "he_service")
public class ServiceEntity implements Serializable {
@EmbeddedId
private Id id ;
private String name;
public ServiceEntity() {
}
public ServiceEntity(Id id, String name) {
this.id = id;
this.name = name;
}
@Embeddable
class Id implements Serializable {
public Id() {
}
public Id(String serviceId, String clientId) {
this.serviceId = serviceId;
this.clientId = clientId;
}
@Column(name = "serviceId")
private String serviceId;
@Column(name = "clientId")
private String clientId;
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
}
Repository method there
@Query(value= "SELECT s FROM ServiceEntity s " +
"WHERE s.id.clientId = :clientId")
List<ServiceEntity> findByClientId(@Param("clientId") String clientId);