Home > Blockchain >  nested exception is org.hibernate.MappingException: Could not determine type for: Com.test.model.Cli
nested exception is org.hibernate.MappingException: Could not determine type for: Com.test.model.Cli

Time:01-13

I'm using Hibernate in my spring project. But It doesn't work for One-To-One relationships. It gives me the below error.

Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: com.example.TransfertNational.model.Client, at table: ComptePaiement, for columns: [org.hibernate.mapping.Column(client)]

I have ran some searches in the internet, but it doesn't work for me.

the Client Entity :

@Data @Entity
@AllArgsConstructor @NoArgsConstructor @ToString
public class Client {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String typeTransfert;
    private String typePiece;
    private String cin;

    private String sexe;
    private String prenom;
    private String typePieceIdentite;
    private String paysEmission;
    private String numPI;
    private String validitePI;
    private String dateNaissance;
    private String profession;
    private String nationalite;
    private String paysAdresse;
    private String adresseLegale;
    private String ville;
    private String gsm;
    private String email;
    @OneToMany(fetch = FetchType.LAZY,
            cascade = CascadeType.ALL)
    private Set<Beneficiaire> beneficiares;
    @OneToOne(fetch = FetchType.LAZY,
            cascade = CascadeType.ALL)
    private ComptePaiement comptePaiement;
}

the ComptePaiement Entity :

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ComptePaiement {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String solde;
    private String rip;
    private Client client;
}

CodePudding user response:

Answer from comments:

You are probably missing @JoinColumn on Client or ComptePaiement and mappedBy in @OneToOne annotation, depending which will hold reference id in database.

  •  Tags:  
  • Related