Skip to content

Commit

Permalink
Test that JPA repositories work when called in an init method
Browse files Browse the repository at this point in the history
  • Loading branch information
derkoe authored and wilkinsona committed Sep 21, 2023
1 parent f33012f commit c9123c6
Showing 1 changed file with 20 additions and 0 deletions.
@@ -0,0 +1,20 @@
package com.example.data.jpa;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

@Service
public class AppInitializer implements InitializingBean {

private AuthorRepository authorRepository;

public AppInitializer(AuthorRepository authorRepository) {
this.authorRepository = authorRepository;
}

@Override
public void afterPropertiesSet() throws Exception {
authorRepository.findByNameContainingIgnoreCase("name");
}

}

0 comments on commit c9123c6

Please sign in to comment.