I have EcranChamp entity
@Entity @IdClass(EcranChampId.class) public class EcranChamp { @Id @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ecran") Ecran ecran; @Id @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "champ") Champ champ; ... And EcranChampId
@Embeddable public class EcranChampId implements Serializable { private Champ champ; private Ecran ecran; ... Every time i am trying to save an EcranChamp element i have this following error
2018-09-25 12:15:42.889 WARN 14216 --- [nio-8092-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to convert request element: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.Long' to required type 'com.kepler.portailclient.domain.model.Ecran' for property 'ecran'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.Long' to required type 'com.kepler.portailclient.domain.model.Ecran' for property 'ecran': no matching editors or conversion strategy found 2018-09-25 12:15:42.889 WARN 14216 --- [nio-8092-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.Long' to required type 'com.kepler.portailclient.domain.model.Ecran' for property 'ecran'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.Long' to required type 'com.kepler.portailclient.domain.model.Ecran' for property 'ecran': no matching editors or conversion strategy found
EcranChampIdusing the@IdClassannotation. So you must make the@Idfield of typeEcramChampId. Adding two fields with@Idwith typesEcranandChampdoes not work.