0

I'm getting this error in a SpringBoot project. The query I'm running is working up until the point when I try to save a Consumer entity to the Spring JPA database. Have you any ideas on how to fix this?? I think it might be to do with the way the classes are set up.

ERROR MESSAGE:

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource
[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]:
Invocation of init method failed; nested exception is
javax.persistence.PersistenceException: [PersistenceUnit: default]
Unable to build Hibernate SessionFactory; nested exception is
org.hibernate.MappingException: Could not determine type for:
com.fintechbankapi.Consumer.KYCNote, at table: consumer_kyc_notes, for
columns: [org.hibernate.mapping.Column(kyc_notes)]

CLASSES BELOW - I have included no argument constructor, constructor with arguments and getters and setters in each class.

import java.util.ArrayList;
import java.util.List;

import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;

//Object to store a Consumer's details.
@Entity
public class Consumer {
    //variables
    @Id
    private String user_id;
    @ElementCollection
    private List<String> digital_footprint = new ArrayList<String>();
    @ElementCollection
    private List<String> contact_id = new ArrayList<String>();
    @ElementCollection
    private List<Contact> contacts = new ArrayList<Contact>();
    @Embedded
    private KYC kyc;
    @ElementCollection
    private List<KYCNote> kyc_notes = new ArrayList<KYCNote>();
    private String address_id;
    @ElementCollection
    private List<Address> addresses = new ArrayList<Address>();
}
public class KYCNote {
    //variables
    private String code;
    private String detail;
}
@Embeddable
public class KYC {
    //variables
    @Column(name="status")
    private String status;
    //An array containing information required to be verified. Will only be 
    //present if kyc.status = "review".
    @Column(name="idv_required")
    @ElementCollection
    List<String> idv_required = new ArrayList<String>();
}
public class Contact {
    //variables
    private String id;
}
public class Address {
    //variables
        private String id;
}

Any help appreciated. Thanks.

Bashir
  • 2,057
  • 5
  • 19
  • 44
  • Check this it might help : https://stackoverflow.com/questions/40058001/error-creating-bean-with-name-entitymanagerfactory-defined-in-class-path-resou – Reeta Wani Apr 22 '20 at 08:20
  • Thanks. I need to annotate the KYCNote, Contact and Address classes as @Embeddable – user13378921 Apr 22 '20 at 09:24

1 Answers1

-1

Have you tried adding the following to your application.properties file?

"spring.jpa.hibernate.use-new-id-generator-mappings= false" ...

brian
  • 51
  • 6
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 27 '22 at 17:27