No property findAll found for type Benefit!
alesisjoan opened this issue · 10 comments
Exception is thrown: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type Benefit!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'benefitRepository'
this is my code:
BenefitRepository
public interface BenefitRepository extends DataTablesRepository<Benefit, Long>{}
BenefitServiceImpl
@OverRide
public DataTablesOutput getAll(DataTablesInput input) {
return repo.findAll(input);
}
Hi! I'm afraid I'll need a bit more context to debug that 👼
Did you follow the instructions here? More specifically that line:
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class)
Could you share your Benefit (and BenefitRepository) classes please?
OK, inserting @EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class) to the WebAppConfig.java solved my issue.
You can close the issue, but now i have anoter error.
With Ajax call not matching the controller method.
Here is my Controller:
@Controller
@RequestMapping(value = "/Benefit")
public class BenefitController {
@Autowired
BenefitDataTableRepo benefitDataTableRepo;
@JsonView(DataTablesOutput.View.class)
@RequestMapping(value = "/datatable2", method = RequestMethod.GET)
public @ResponseBody DataTablesOutput<Benefit> getBenefits2(@Valid DataTablesInput input){
return benefitDataTableRepo.findAll(input);
}
}
here is my repo:
public interface BenefitDataTableRepo extends DataTablesRepository<Benefit, Long> {
}
here is js function:
var table = $('#table_benefits').DataTable({
'ajax' : '/datatable2',
'serverSide' : true,
columns : [ {
data : 'benefitOid'
}, {
data : 'parameter'
}, {
data : 'type'
}, {
data : 'checked'
} ]
});
});
here is my entity:
@Entity
public class Benefit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long benefitOid;
@NotNull
private String parameter;
private boolean checked = false;
}
I see you have two @RequestMapping
. Shouldn't the url be /Benefit/datatable2
then?
I see you have two @RequestMapping. Shouldn't the url be /Benefit/datatable2 then?
Yep, i realized that after my comment was sent
Url changed to /Benefit/datatable2 but still not working.
@alesisjoan did you solve your issue? can you debug the request in devtools?
Closing, please reopen if needed.
Hi! I'm afraid I'll need a bit more context to debug that 👼
Did you follow the instructions here? More specifically that line:
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class)
Could you share your Benefit (and BenefitRepository) classes please?
Very usefull, thanks very much!
Hi there,
Facing the same issue, please help me out,
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customreProfileRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type DataTablesOutput!
Below is my code
- This is my separate configuration class because I have an already existing class which is invoking base package
@Configuration
@EnableMongoRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class,
basePackages = { "com.base.repo.customer" })
public class DataTableConfig {
}
- A repo class
@Repository
public interface CustomerProfileRepo extends DataTablesRepository<CustomerProfile, String>{
}
- Controller class
@RequestMapping(value ="/customer/list", method = RequestMethod.GET)
public DataTablesOutput<CustomerProfile> list(@Valid DataTablesInput input) {
return customerProfileRepo.findAll(input);
}
@anuragdhiman Hi! Would you be able to reproduce your issue by forking this repo? If you are actually able to reproduce, could you please open a new issue with all necessary details? Thanks!
@darrachequesne Thanks for sharing this. Sure I will try the same and get back!