elastic search and JPA in a single project

Viewed 37

//1-> elasticsearch Repository

@NoRepositoryBean
public class BaseElasticRepository<TemplateEntity extends BaseModel, Id>
extends SimpleElasticsearchRepository<TemplateEntity, Id>
implements ElasticsearchRepository<TemplateEntity, Id>, IBaseRepository<TemplateEntity, Id> {
       

 public BaseElasticRepository(ElasticsearchEntityInformation<TemplateEntity, Id> metadata,
                ElasticsearchOperations operations) {
            super(metadata, operations);
        }

@Override
public List<TemplateEntity> simpleSearch(String searchQuery, Pageable pageable) {

    return null;
}

@Override
public <TemplateDto> List<TemplateDto> advanceSearch(ConstraintExpression constraintExpression,
        Class<TemplateDto> dtoType) {
    return null;
}

}

//2-> JPA Repository

@NoRepositoryBean
public class BaseRdbmsRepository<TemplateEntity extends BaseModel, Id> extends SimpleJpaRepository<TemplateEntity, Id>
        implements IBaseRepository<TemplateEntity, Id> {

private EntityManager entityManager;

Class<TemplateEntity> domainClass;

@Autowired
public BaseRdbmsRepository(Class<TemplateEntity> domainClass, EntityManager entityManager) {
    super(domainClass, entityManager);
    this.domainClass = domainClass;
    this.entityManager = entityManager;
}

@Override
public List<TemplateEntity> simpleSearch(String searchQuery, Pageable pageable) {
    // TODO Auto-generated method stub
    return null;
}


@Override
public <TemplateDto> List<TemplateDto> advanceSearch(ConstraintExpression expression, Class<TemplateDto> dtoType) {

    return null;

}

}

simpleSearch and advanceSearch comming from IBaseRepository i got this error--> Consider defining a bean of type 'org.springframework.data.elasticsearch.repository.support.ElasticsearchEntityInformation' in your configuration.

now rest call identify to which repository use at run time automatically

0 Answers
Related