I'm confused with below errors i tried many stack overflow suggestions it did not worked.
And I am getting this error.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productService': Unsatisfied dependency expressed through field 'ProductRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProductRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.entities.product
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.entities.product
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1694) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.entities.product
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:74) ~[spring-data-jpa-2.0.11.RELEASE.jar:2.0.11.RELEASE]
Product Service class:
@Autowired
DataSource database;
@Autowired
ProductRepository productRepository;
@Transactional
public product getAccounts(String account) {
Product prd = productRepository.selectAccounts(accountId);
return prd;
}
Product Repository:
@Repository
public interface productRepository extends JpaRepository<product, String> {
@Query(value="SELECT Demo FROM Test WHERE ACC_ID=?1,nativeQuery=true)
product selectAccounts(@Param("accountId") String accountId );
}
Entity
/*@Entity(name="Product")
@Table(name="test", schema=demo")*/
@Embeddable
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="ACCOUNT_ID")
private String accountId;
I looked through a lot of similar questions, but it did not helped.Please help me to solve the above exception.